Skip to content

Commit

Permalink
destroy smtp_client when remoteAddress undefined
Browse files Browse the repository at this point in the history
same fix as haraka#239

fixes haraka#1835
  • Loading branch information
msimerson committed Mar 4, 2017
1 parent 51589b3 commit cff7545
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions smtp_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ function SMTPClient (port, host, connect_timeout, idle_timeout) {
client.emit('auth_username');
return;
}
else if (code.match(/^3/) && msg === 'UGFzc3dvcmQ6') {
if (code.match(/^3/) && msg === 'UGFzc3dvcmQ6') {
client.emit('auth_password');
return;
} else if (code.match(/^2/) && client.authenticating) {
//TODO: logging
}
if (code.match(/^2/) && client.authenticating) {
logger.loginfo('AUTHENTICATED');
client.authenticating = false;
client.authenticated = true;
Expand Down Expand Up @@ -143,13 +143,12 @@ function SMTPClient (port, host, connect_timeout, idle_timeout) {
client.socket.on('connect', function () {
// Remove connection timeout and set idle timeout
client.socket.setTimeout(((idle_timeout) ? idle_timeout : 300) * 1000);
if (client.socket.remoteAddress) {
if (!client.socket.remoteAddress) {
// "Value may be undefined if the socket is destroyed"
client.remote_ip = ipaddr.process(client.socket.remoteAddress).toString();
}
else {
logger.logerror('client.socket.remoteAddress undefined!');
client.destroy();
return;
}
client.remote_ip = ipaddr.process(client.socket.remoteAddress).toString();
});

var closed = function (msg) {
Expand Down

0 comments on commit cff7545

Please sign in to comment.