diff --git a/remote_judger/package-lock.json b/remote_judger/package-lock.json index d66645f..ee07390 100644 --- a/remote_judger/package-lock.json +++ b/remote_judger/package-lock.json @@ -12,6 +12,7 @@ "crlf-normalize": "^1.0.18", "fs-extra": "^11.1.0", "jsdom": "^21.0.0", + "lodash.flattendeep": "^4.4.0", "math-sum": "^2.0.0", "reggol": "^1.3.4", "superagent": "^8.0.6", @@ -21,6 +22,7 @@ "@types/fs-extra": "^11.0.1", "@types/js-yaml": "^4.0.5", "@types/jsdom": "^20.0.1", + "@types/lodash.flattendeep": "^4.4.7", "@types/node": "^18.11.18", "@types/superagent": "^4.1.16", "@types/superagent-proxy": "^3.0.0", @@ -78,6 +80,21 @@ "@types/node": "*" } }, + "node_modules/@types/lodash": { + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", + "dev": true + }, + "node_modules/@types/lodash.flattendeep": { + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.7.tgz", + "integrity": "sha512-1h6GW/AeZw/Wej6uxrqgmdTDZX1yFS39lRsXYkg+3kWvOWWrlGCI6H7lXxlUHOzxDT4QeYGmgPpQ3BX9XevzOg==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -790,6 +807,11 @@ "node": ">= 0.8.0" } }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1567,6 +1589,21 @@ "@types/node": "*" } }, + "@types/lodash": { + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", + "dev": true + }, + "@types/lodash.flattendeep": { + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.7.tgz", + "integrity": "sha512-1h6GW/AeZw/Wej6uxrqgmdTDZX1yFS39lRsXYkg+3kWvOWWrlGCI6H7lXxlUHOzxDT4QeYGmgPpQ3BX9XevzOg==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -2113,6 +2150,11 @@ "type-check": "~0.3.2" } }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", diff --git a/remote_judger/package.json b/remote_judger/package.json index 86ff0e9..3d1d50d 100644 --- a/remote_judger/package.json +++ b/remote_judger/package.json @@ -15,6 +15,7 @@ "crlf-normalize": "^1.0.18", "fs-extra": "^11.1.0", "jsdom": "^21.0.0", + "lodash.flattendeep": "^4.4.0", "math-sum": "^2.0.0", "reggol": "^1.3.4", "superagent": "^8.0.6", @@ -24,6 +25,7 @@ "@types/fs-extra": "^11.0.1", "@types/js-yaml": "^4.0.5", "@types/jsdom": "^20.0.1", + "@types/lodash.flattendeep": "^4.4.7", "@types/node": "^18.11.18", "@types/superagent": "^4.1.16", "@types/superagent-proxy": "^3.0.0", diff --git a/remote_judger/src/providers/luogu.ts b/remote_judger/src/providers/luogu.ts index 7932499..237b291 100644 --- a/remote_judger/src/providers/luogu.ts +++ b/remote_judger/src/providers/luogu.ts @@ -4,7 +4,7 @@ import proxy from 'superagent-proxy'; import Logger from '../utils/logger'; import { IBasicProvider, RemoteAccount, USER_AGENT } from '../interface'; import sleep from '../utils/sleep'; -import flattenDeep from '../utils/flattenDeep'; +import flattenDeep from 'lodash.flattendeep'; proxy(superagent); const logger = new Logger('remote/luogu'); @@ -106,6 +106,23 @@ export default class LuoguProvider implements IBasicProvider { return req; } + async safeGet(url: string) { + const res = await this.get(url); + + if (res.text.startsWith('