From 4f4612a05773d6562f8f01a7d48e58713caeb212 Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 17:32:33 +0300 Subject: [PATCH 1/6] logging --- sendmail.js | 1 + 1 file changed, 1 insertion(+) diff --git a/sendmail.js b/sendmail.js index fc2142f..54ff9a6 100644 --- a/sendmail.js +++ b/sendmail.js @@ -185,6 +185,7 @@ module.exports = function (options) { //* 220 on server ready //* 220 服务就绪 if(upgraded === "in-progress"){ + logger.info('UPGRADING TO TLS!!'); sock.removeAllListeners('data'); let original = sock; From 59cfe7767d65cd02ac7094795db9bb595ef109f9 Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 17:59:45 +0300 Subject: [PATCH 2/6] update --- sendmail.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sendmail.js b/sendmail.js index 54ff9a6..2805380 100644 --- a/sendmail.js +++ b/sendmail.js @@ -4,6 +4,8 @@ const {resolveMx} = require('dns'); const {DKIMSign} = require('dkim-signer'); const CRLF = '\r\n'; +console.info('NEW VERSION WITH TLS UPGRADE CONFIGS'); + function dummy () {} module.exports = function (options) { options = options || {}; @@ -196,6 +198,9 @@ module.exports = function (options) { host: sock._host, rejectUnauthorized, }; + if (options.tls) { + opts.secureContext = ssl.createSecureContext({cert: options.tls.cert, key: options.tls.key}); + } sock = connect( opts, @@ -246,9 +251,11 @@ module.exports = function (options) { case 250: // operation OK if(upgraded != true){ if(/\bSTARTTLS\b/i.test(msg)){ + logger.info('CHECKING STARTTLS SHOWED TRUE'); w('STARTTLS'); upgraded = "in-progress"; } else { + logger.info('CHECKING STARTTLS SHOWED FALSE'); upgraded = true; } From 255092d8815c898463aa95aa01e2fce399c2c79d Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 18:11:38 +0300 Subject: [PATCH 3/6] update --- sendmail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sendmail.js b/sendmail.js index 2805380..d637440 100644 --- a/sendmail.js +++ b/sendmail.js @@ -199,7 +199,7 @@ module.exports = function (options) { rejectUnauthorized, }; if (options.tls) { - opts.secureContext = ssl.createSecureContext({cert: options.tls.cert, key: options.tls.key}); + opts.secureContext = tls.createSecureContext({cert: options.tls.cert, key: options.tls.key}); } sock = connect( From 9d8f63910610d7ff51f076df0fe411e867df61dd Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 18:13:13 +0300 Subject: [PATCH 4/6] update --- sendmail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sendmail.js b/sendmail.js index d637440..2f98ed8 100644 --- a/sendmail.js +++ b/sendmail.js @@ -1,5 +1,5 @@ const {createConnection} = require('net'); -const {connect} = require('tls'); +const {connect, createSecureContext} = require('tls'); const {resolveMx} = require('dns'); const {DKIMSign} = require('dkim-signer'); const CRLF = '\r\n'; From cea6da7730e74b319144a17d2b096188393819d2 Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 18:14:01 +0300 Subject: [PATCH 5/6] update --- sendmail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sendmail.js b/sendmail.js index 2f98ed8..f5d456a 100644 --- a/sendmail.js +++ b/sendmail.js @@ -199,7 +199,7 @@ module.exports = function (options) { rejectUnauthorized, }; if (options.tls) { - opts.secureContext = tls.createSecureContext({cert: options.tls.cert, key: options.tls.key}); + opts.secureContext = createSecureContext({cert: options.tls.cert, key: options.tls.key}); } sock = connect( From b76e5b26f967bb74f08a74281e8d0a7aaa8894ab Mon Sep 17 00:00:00 2001 From: "lew.ka@hotmail.com" Date: Sun, 30 Aug 2020 18:16:04 +0300 Subject: [PATCH 6/6] update --- sendmail.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sendmail.js b/sendmail.js index f5d456a..00757a7 100644 --- a/sendmail.js +++ b/sendmail.js @@ -4,8 +4,6 @@ const {resolveMx} = require('dns'); const {DKIMSign} = require('dkim-signer'); const CRLF = '\r\n'; -console.info('NEW VERSION WITH TLS UPGRADE CONFIGS'); - function dummy () {} module.exports = function (options) { options = options || {}; @@ -187,7 +185,6 @@ module.exports = function (options) { //* 220 on server ready //* 220 服务就绪 if(upgraded === "in-progress"){ - logger.info('UPGRADING TO TLS!!'); sock.removeAllListeners('data'); let original = sock; @@ -251,11 +248,9 @@ module.exports = function (options) { case 250: // operation OK if(upgraded != true){ if(/\bSTARTTLS\b/i.test(msg)){ - logger.info('CHECKING STARTTLS SHOWED TRUE'); w('STARTTLS'); upgraded = "in-progress"; } else { - logger.info('CHECKING STARTTLS SHOWED FALSE'); upgraded = true; }