Add option to disable SartTLS for SMTP Server
+ make it so "alarm event" header or subject line is used for SMTP trigger eventmerge-requests/98/merge
parent
55b8aafb0f
commit
2736f3a79d
|
@ -179,9 +179,11 @@ module.exports = function(s,config,lang,app,io){
|
|||
// SMTP Server
|
||||
// allow starting SMTP server without dropInEventServer
|
||||
if(config.smtpServer === true){
|
||||
if(config.smtpServerHideStartTls === undefined)config.smtpServerHideStartTls = null
|
||||
var SMTPServer = require("smtp-server").SMTPServer;
|
||||
if(!config.smtpServerPort && (config.smtpServerSsl && config.smtpServerSsl.enabled !== false || config.ssl)){config.smtpServerPort = 465}else if(!config.smtpServerPort){config.smtpServerPort = 25}
|
||||
var smtpOptions = {
|
||||
hideSTARTTLS: config.smtpServerHideStartTls,
|
||||
onAuth(auth, session, callback) {
|
||||
var username = auth.username
|
||||
var password = auth.password
|
||||
|
@ -198,20 +200,60 @@ module.exports = function(s,config,lang,app,io){
|
|||
var monitorId = split[0]
|
||||
var ke = session.user
|
||||
if(s.group[ke].rawMonitorConfigurations[monitorId] && s.group[ke].activeMonitors[monitorId].isStarted === true){
|
||||
s.triggerEvent({
|
||||
id: monitorId,
|
||||
ke: ke,
|
||||
details: {
|
||||
confidence: 100,
|
||||
name: address.address,
|
||||
plug: "dropInEvent",
|
||||
reason: "smtpServer"
|
||||
}
|
||||
},config.dropInEventForceSaveEvent)
|
||||
session.monitorId = monitorId
|
||||
}else{
|
||||
return callback(new Error(lang['No Monitor Exists with this ID.']))
|
||||
}
|
||||
callback()
|
||||
},
|
||||
onData(stream, session, callback) {
|
||||
if(session.monitorId){
|
||||
var ke = session.user
|
||||
var monitorId = session.monitorId
|
||||
var reasonTag = 'smtpServer'
|
||||
var text = ''
|
||||
stream.on('data',function(data){
|
||||
text += data.toString()
|
||||
}) // print message to console
|
||||
stream.on("end", function(){
|
||||
var contentPart = text.split('--PartBoundary12345678')
|
||||
contentPart.forEach(function(part){
|
||||
var parsed = {}
|
||||
var lines = part.split(/\r?\n/)
|
||||
lines.forEach(function(line,n){
|
||||
var pieces = line.split(':')
|
||||
if(pieces[1]){
|
||||
var nextLine = lines[n + 1]
|
||||
var keyName = pieces[0].trim().toLowerCase()
|
||||
pieces.shift()
|
||||
var parsedValue = pieces.join(':')
|
||||
parsed[keyName] = parsedValue
|
||||
}
|
||||
})
|
||||
if(parsed['content-type'] && parsed['content-type'].indexOf('image/jpeg') > -1){
|
||||
// console.log(lines)
|
||||
}
|
||||
if(parsed['alarm event']){
|
||||
reasonTag = parsed['alarm event']
|
||||
}else if(parsed.subject){
|
||||
reasonTag = parsed.subject
|
||||
}
|
||||
})
|
||||
s.triggerEvent({
|
||||
id: monitorId,
|
||||
ke: ke,
|
||||
details: {
|
||||
confidence: 100,
|
||||
name: 'smtpServer',
|
||||
plug: "dropInEvent",
|
||||
reason: reasonTag
|
||||
}
|
||||
},config.dropInEventForceSaveEvent)
|
||||
callback()
|
||||
})
|
||||
}else{
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
if(config.smtpServerSsl && config.smtpServerSsl.enabled !== false || config.ssl && config.ssl.cert && config.ssl.key){
|
||||
|
|
Loading…
Reference in New Issue