-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added SMTP monitor #5489
Open
koehn
wants to merge
7
commits into
louislam:master
Choose a base branch
from
koehn:smtp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
added SMTP monitor #5489
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
712e345
added smtp monitor
koehn 340bfd7
Added changes from review
koehn 9c5b19c
fix dumb typo
koehn 142a820
Merge branch 'master' into smtp
koehn 3dacf72
Lint
koehn 2353ba5
Updated help text
koehn 1ab2839
Merge branch 'master' into smtp
koehn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
exports.up = function (knex) { | ||
return knex.schema | ||
.alterTable("monitor", function (table) { | ||
table.string("smtp_security").defaultTo(null); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.alterTable("monitor", function (table) { | ||
table.dropColumn("smtp_security"); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { MonitorType } = require("./monitor-type"); | ||
const { UP } = require("../../src/util"); | ||
const nodemailer = require("nodemailer"); | ||
|
||
class SMTPMonitorType extends MonitorType { | ||
name = "smtp"; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async check(monitor, heartbeat, _server) { | ||
let options = { | ||
port: monitor.port || 25, | ||
host: monitor.hostname, | ||
secure: monitor.smtpSecurity === "secure", // use SMTPS (not STARTTLS) | ||
ignoreTLS: monitor.smtpSecurity === "nostarttls", // don't use STARTTLS even if it's available | ||
requireTLS: monitor.smtpSecurity === "starttls", // use STARTTLS or fail | ||
}; | ||
let transporter = nodemailer.createTransport(options); | ||
try { | ||
await transporter.verify(); | ||
|
||
heartbeat.status = UP; | ||
heartbeat.msg = "SMTP connection verifies successfully"; | ||
} catch (e) { | ||
throw new Error(`SMTP connection doesn't verify: ${e}`); | ||
} finally { | ||
transporter.close(); | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
SMTPMonitorType, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a helptext what this monitor actually does.
People will infer that this is sending mails otherwise..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve pushed the changes based upon what I saw elsewhere in the file; let me know if they weren’t correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not what I meant.
I meant specifying as a helptext what kind of check the selected option does.
What does
Ignore STARTTLS
actually check?It does not send a mail as I would expect => please specify in the helptext that it just tries to connect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for clarifying.
I’ll describe them here, and also add them to the codebase:
Ignore STARTTLS
simply connects, saysHELO
and looks for a correct responseUse STARTTLS
connects, saysHELO
, looks forSTARTTLS
in the response, issues the command, and verifies the certificateSMTPS
connects over TLS, verifies the certificate, saysHELO
and looks for a correct responseDetails are here. Update to the code coming shortly.