|
@ -1,6 +1,4 @@ |
|
|
const https = require("https"); |
|
|
const https = require("https"); |
|
|
const HttpProxyAgent = require("http-proxy-agent"); |
|
|
|
|
|
const HttpsProxyAgent = require("https-proxy-agent"); |
|
|
|
|
|
const dayjs = require("dayjs"); |
|
|
const dayjs = require("dayjs"); |
|
|
const utc = require("dayjs/plugin/utc"); |
|
|
const utc = require("dayjs/plugin/utc"); |
|
|
let timezone = require("dayjs/plugin/timezone"); |
|
|
let timezone = require("dayjs/plugin/timezone"); |
|
@ -13,6 +11,7 @@ const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalCli |
|
|
const { R } = require("redbean-node"); |
|
|
const { R } = require("redbean-node"); |
|
|
const { BeanModel } = require("redbean-node/dist/bean-model"); |
|
|
const { BeanModel } = require("redbean-node/dist/bean-model"); |
|
|
const { Notification } = require("../notification"); |
|
|
const { Notification } = require("../notification"); |
|
|
|
|
|
const { Proxy } = require("../proxy"); |
|
|
const { demoMode } = require("../config"); |
|
|
const { demoMode } = require("../config"); |
|
|
const version = require("../../package.json").version; |
|
|
const version = require("../../package.json").version; |
|
|
const apicache = require("../modules/apicache"); |
|
|
const apicache = require("../modules/apicache"); |
|
@ -170,31 +169,13 @@ class Monitor extends BeanModel { |
|
|
const proxy = await R.load("proxy", this.proxy_id); |
|
|
const proxy = await R.load("proxy", this.proxy_id); |
|
|
|
|
|
|
|
|
if (proxy && proxy.active) { |
|
|
if (proxy && proxy.active) { |
|
|
const httpProxyAgentOptions = { |
|
|
const { httpAgent, httpsAgent } = Proxy.createAgents(proxy, { |
|
|
protocol: proxy.protocol, |
|
|
httpsAgentOptions: httpsAgentOptions, |
|
|
host: proxy.host, |
|
|
}); |
|
|
port: proxy.port, |
|
|
|
|
|
}; |
|
|
|
|
|
const httpsProxyAgentOptions = { |
|
|
|
|
|
...httpsAgentOptions, |
|
|
|
|
|
protocol: proxy.protocol, |
|
|
|
|
|
hostname: proxy.host, |
|
|
|
|
|
port: proxy.port, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (proxy.auth) { |
|
|
|
|
|
httpProxyAgentOptions.auth = `${proxy.username}:${proxy.password}`; |
|
|
|
|
|
httpsProxyAgentOptions.auth = `${proxy.username}:${proxy.password}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
debug(`[${this.name}] HTTP options: ${JSON.stringify({ |
|
|
|
|
|
"http": httpProxyAgentOptions, |
|
|
|
|
|
"https": httpsProxyAgentOptions, |
|
|
|
|
|
})}`);
|
|
|
|
|
|
|
|
|
|
|
|
options.proxy = false; |
|
|
options.proxy = false; |
|
|
options.httpAgent = new HttpProxyAgent(httpProxyAgentOptions); |
|
|
options.httpAgent = httpAgent; |
|
|
options.httpsAgent = new HttpsProxyAgent(httpsProxyAgentOptions); |
|
|
options.httpsAgent = httpsAgent; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|