mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-20 21:48:54 -04:00
added option to force ipv4 or ipv6 for http(s) monitor type (#5880)
Co-authored-by: Ionys <9364594+Ionys320@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
53e83e7722
commit
f282422b22
5 changed files with 54 additions and 0 deletions
|
@ -160,6 +160,7 @@ class Monitor extends BeanModel {
|
|||
smtpSecurity: this.smtpSecurity,
|
||||
rabbitmqNodes: JSON.parse(this.rabbitmqNodes),
|
||||
conditions: JSON.parse(this.conditions),
|
||||
ipFamily: this.ipFamily,
|
||||
|
||||
// ping advanced options
|
||||
ping_numeric: this.isPingNumeric(),
|
||||
|
@ -426,10 +427,26 @@ class Monitor extends BeanModel {
|
|||
}
|
||||
}
|
||||
|
||||
let agentFamily = undefined;
|
||||
if (this.ipFamily === "ipv4") {
|
||||
agentFamily = 4;
|
||||
}
|
||||
if (this.ipFamily === "ipv6") {
|
||||
agentFamily = 6;
|
||||
}
|
||||
|
||||
const httpsAgentOptions = {
|
||||
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
||||
rejectUnauthorized: !this.getIgnoreTls(),
|
||||
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT,
|
||||
autoSelectFamily: true,
|
||||
...(agentFamily ? { family: agentFamily } : {})
|
||||
};
|
||||
|
||||
const httpAgentOptions = {
|
||||
maxCachedSessions: 0,
|
||||
autoSelectFamily: true,
|
||||
...(agentFamily ? { family: agentFamily } : {})
|
||||
};
|
||||
|
||||
log.debug("monitor", `[${this.name}] Prepare Options for axios`);
|
||||
|
@ -491,6 +508,7 @@ class Monitor extends BeanModel {
|
|||
if (proxy && proxy.active) {
|
||||
const { httpAgent, httpsAgent } = Proxy.createAgents(proxy, {
|
||||
httpsAgentOptions: httpsAgentOptions,
|
||||
httpAgentOptions: httpAgentOptions,
|
||||
});
|
||||
|
||||
options.proxy = false;
|
||||
|
@ -499,6 +517,10 @@ class Monitor extends BeanModel {
|
|||
}
|
||||
}
|
||||
|
||||
if (!options.httpAgent) {
|
||||
options.httpAgent = new http.Agent(httpAgentOptions);
|
||||
}
|
||||
|
||||
if (!options.httpsAgent) {
|
||||
let jar = new CookieJar();
|
||||
let httpsCookieAgentOptions = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue