|
@ -58,6 +58,8 @@ class Monitor extends BeanModel { |
|
|
method: this.method, |
|
|
method: this.method, |
|
|
body: this.body, |
|
|
body: this.body, |
|
|
headers: this.headers, |
|
|
headers: this.headers, |
|
|
|
|
|
basic_auth_user: this.basic_auth_user, |
|
|
|
|
|
basic_auth_pass: this.basic_auth_pass, |
|
|
hostname: this.hostname, |
|
|
hostname: this.hostname, |
|
|
port: this.port, |
|
|
port: this.port, |
|
|
maxretries: this.maxretries, |
|
|
maxretries: this.maxretries, |
|
@ -80,6 +82,15 @@ class Monitor extends BeanModel { |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Encode user and password to Base64 encoding |
|
|
|
|
|
* for HTTP "basic" auth, as per RFC-7617 |
|
|
|
|
|
* @returns {string} |
|
|
|
|
|
*/ |
|
|
|
|
|
encodeB64(user, pass) { |
|
|
|
|
|
return btoa(user + ":" + pass); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Parse to boolean |
|
|
* Parse to boolean |
|
|
* @returns {boolean} |
|
|
* @returns {boolean} |
|
@ -141,7 +152,16 @@ class Monitor extends BeanModel { |
|
|
// Do not do any queries/high loading things before the "bean.ping"
|
|
|
// Do not do any queries/high loading things before the "bean.ping"
|
|
|
let startTime = dayjs().valueOf(); |
|
|
let startTime = dayjs().valueOf(); |
|
|
|
|
|
|
|
|
|
|
|
// HTTP basic auth
|
|
|
|
|
|
let basicAuthHeader = {}; |
|
|
|
|
|
if (this.basic_auth_user) { |
|
|
|
|
|
basicAuthHeader = { |
|
|
|
|
|
"Authorization": "Basic " + this.encodeB64(this.basic_auth_user, this.basic_auth_pass), |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
debug(`[${this.name}] Prepare Options for axios`); |
|
|
debug(`[${this.name}] Prepare Options for axios`); |
|
|
|
|
|
|
|
|
const options = { |
|
|
const options = { |
|
|
url: this.url, |
|
|
url: this.url, |
|
|
method: (this.method || "get").toLowerCase(), |
|
|
method: (this.method || "get").toLowerCase(), |
|
@ -151,6 +171,7 @@ class Monitor extends BeanModel { |
|
|
"Accept": "*/*", |
|
|
"Accept": "*/*", |
|
|
"User-Agent": "Uptime-Kuma/" + version, |
|
|
"User-Agent": "Uptime-Kuma/" + version, |
|
|
...(this.headers ? JSON.parse(this.headers) : {}), |
|
|
...(this.headers ? JSON.parse(this.headers) : {}), |
|
|
|
|
|
...(basicAuthHeader), |
|
|
}, |
|
|
}, |
|
|
httpsAgent: new https.Agent({ |
|
|
httpsAgent: new https.Agent({ |
|
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
|
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
|
|