fix: 兼容5和7的proxy依赖

This commit is contained in:
ikechan8370 2023-09-12 11:08:14 +08:00
parent 5e7d73908f
commit f620e10abb
8 changed files with 727 additions and 334 deletions

View file

@ -6,11 +6,11 @@ import fetch, {
} from 'node-fetch'
import crypto from 'crypto'
import WebSocket from 'ws'
import HttpsProxyAgent from 'https-proxy-agent'
import { Config, pureSydneyInstruction } from './config.js'
import { formatDate, getMasterQQ, isCN, getUserData } from './common.js'
import delay from 'delay'
import moment from 'moment'
import { getProxy } from './proxy.js'
if (!globalThis.fetch) {
globalThis.fetch = fetch
@ -19,12 +19,7 @@ if (!globalThis.fetch) {
globalThis.Response = Response
}
// workaround for ver 7.x and ver 5.x
let proxy = HttpsProxyAgent
if (typeof proxy !== 'function') {
proxy = (p) => {
return new HttpsProxyAgent.HttpsProxyAgent(p)
}
}
let proxy = getProxy()
async function getKeyv () {
let Keyv