mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-26 21:45:57 +00:00
delint
This commit is contained in:
parent
16edd5932e
commit
ab0ba80db7
1 changed files with 20 additions and 8 deletions
|
@ -1,20 +1,32 @@
|
||||||
const { MonitorType } = require("./monitor-type");
|
const { MonitorType } = require("./monitor-type");
|
||||||
const { UP, log, evaluateJsonQuery } = require("../../src/util");
|
const { UP } = require("../../src/util");
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
class SMTPMonitorType extends MonitorType {
|
class SMTPMonitorType extends MonitorType {
|
||||||
name = "smtp";
|
name = "smtp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} smtpSecurity the user's SMTP security setting
|
||||||
|
* @returns {boolean} True if this should test SMTPS
|
||||||
|
*/
|
||||||
isSMTPS(smtpSecurity) {
|
isSMTPS(smtpSecurity) {
|
||||||
return smtpSecurity === 'secure';
|
return smtpSecurity === "secure";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} smtpSecurity the user's SMTP security setting
|
||||||
|
* @returns {boolean} True if this should not attempt STARTTLS, even if it is available
|
||||||
|
*/
|
||||||
isIgnoreTLS(smtpSecurity) {
|
isIgnoreTLS(smtpSecurity) {
|
||||||
return smtpSecurity === 'nostarttls';
|
return smtpSecurity === "nostarttls";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} smtpSecurity the user's SMTP security setting
|
||||||
|
* @returns {boolean} True if this should always test STARTTLS
|
||||||
|
*/
|
||||||
isRequireTLS(smtpSecurity) {
|
isRequireTLS(smtpSecurity) {
|
||||||
return smtpSecurity === 'starttls';
|
return smtpSecurity === "starttls";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,13 +39,13 @@ class SMTPMonitorType extends MonitorType {
|
||||||
secure: this.isSMTPS(monitor.smtpSecurity), // use SMTPS (not STARTTLS)
|
secure: this.isSMTPS(monitor.smtpSecurity), // use SMTPS (not STARTTLS)
|
||||||
ignoreTLS: this.isIgnoreTLS(monitor.smtpSecurity), // don't use STARTTLS even if it's available
|
ignoreTLS: this.isIgnoreTLS(monitor.smtpSecurity), // don't use STARTTLS even if it's available
|
||||||
requireTLS: this.isRequireTLS(monitor.smtpSecurity), // use STARTTLS or fail
|
requireTLS: this.isRequireTLS(monitor.smtpSecurity), // use STARTTLS or fail
|
||||||
}
|
};
|
||||||
let transporter = nodemailer.createTransport(options);
|
let transporter = nodemailer.createTransport(options);
|
||||||
try {
|
try {
|
||||||
await transporter.verify();
|
await transporter.verify();
|
||||||
|
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
heartbeat.msg = `SMTP connection verifies successfully`;
|
heartbeat.msg = "SMTP connection verifies successfully";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`SMTP connection doesn't verify: ${e}`);
|
throw new Error(`SMTP connection doesn't verify: ${e}`);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Add table
Reference in a new issue