Skip to content

Commit

Permalink
Merge pull request haraka#1109 from smfreegard/tls_timeout
Browse files Browse the repository at this point in the history
TLS fixes: add timed_out flag and karma should not run deny hook on it.
  • Loading branch information
msimerson committed Aug 18, 2015
2 parents 2e9f3dc + ca0dd17 commit 1854e3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/karma.js
Expand Up @@ -19,7 +19,7 @@ exports.register = function () {
plugin.deny_exclude_hooks = utils.to_object('rcpt_to, queue');
plugin.deny_exclude_plugins = utils.to_object(
['access', 'helo.checks', 'data.headers', 'spamassassin',
'mail_from.is_resolvable', 'clamd']
'mail_from.is_resolvable', 'clamd', 'tls']
);

plugin.load_karma_ini();
Expand Down
3 changes: 3 additions & 0 deletions plugins/tls.js
Expand Up @@ -88,10 +88,12 @@ exports.tls_unrecognized_command = function (next, connection, params) {
connection.respond(220, "Go ahead.");

var plugin = this;
var timed_out = false;
// adjust plugin.timeout like so: echo '45' > config/tls.timeout
var timeout = plugin.timeout - 1;

var timer = setTimeout(function () {
timed_out = true;
connection.logerror(plugin, 'timeout');
return next(DENYSOFTDISCONNECT);
}, timeout * 1000);
Expand All @@ -101,6 +103,7 @@ exports.tls_unrecognized_command = function (next, connection, params) {
/* Upgrade the connection to TLS. */
connection.client.upgrade(plugin.tls_opts, function (authorized,
verifyError, cert, cipher) {
if (timed_out) { return; }
clearTimeout(timer);
connection.reset_transaction(function () {
connection.hello_host = undefined;
Expand Down

0 comments on commit 1854e3d

Please sign in to comment.