@@ -4,9 +4,10 @@ var fs = require('fs');
4
4
var path = require ( 'path' ) ;
5
5
var dns = require ( 'dns' ) ;
6
6
var net = require ( 'net' ) ;
7
- var util = require ( " util" ) ;
8
- var events = require ( " events" ) ;
7
+ var util = require ( ' util' ) ;
8
+ var events = require ( ' events' ) ;
9
9
var os = require ( 'os' ) ;
10
+
10
11
var utils = require ( './utils' ) ;
11
12
var sock = require ( './line_socket' ) ;
12
13
var logger = require ( './logger' ) ;
@@ -28,7 +29,7 @@ var core_consts = require('constants');
28
29
var WRITE_EXCL = core_consts . O_CREAT | core_consts . O_TRUNC | core_consts . O_WRONLY | core_consts . O_EXCL ;
29
30
30
31
var MAX_UNIQ = 10000 ;
31
- var host = require ( 'os' ) . hostname ( ) . replace ( / \\ / , '\\057' ) . replace ( / : / , '\\072' ) ;
32
+ var my_hostname = require ( 'os' ) . hostname ( ) . replace ( / \\ / , '\\057' ) . replace ( / : / , '\\072' ) ;
32
33
var fn_re = / ^ ( \d + ) _ ( \d + ) _ / ; // I like how this looks like a person
33
34
34
35
// TODO: For testability, this should be accessible
@@ -340,7 +341,7 @@ function _next_uniq () {
340
341
341
342
function _fname ( ) {
342
343
var time = new Date ( ) . getTime ( ) ;
343
- return time + '_0_' + process . pid + "_" + _next_uniq ( ) + '.' + host ;
344
+ return time + '_0_' + process . pid + "_" + _next_uniq ( ) + '.' + my_hostname ;
344
345
}
345
346
346
347
exports . send_email = function ( ) {
@@ -640,13 +641,13 @@ exports.TODOItem = TODOItem;
640
641
641
642
var dummy_func = function ( ) { } ;
642
643
643
- function HMailItem ( filename , path , notes ) {
644
+ function HMailItem ( filename , filePath , notes ) {
644
645
events . EventEmitter . call ( this ) ;
645
646
var matches = filename . match ( fn_re ) ;
646
647
if ( ! matches ) {
647
648
throw new Error ( "Bad filename: " + filename ) ;
648
649
}
649
- this . path = path ;
650
+ this . path = filePath ;
650
651
this . filename = filename ;
651
652
this . next_process = matches [ 1 ] ;
652
653
this . num_failures = matches [ 2 ] ;
@@ -666,22 +667,22 @@ exports.HMailItem = HMailItem;
666
667
// populate log functions - so we can use hooks
667
668
for ( var key in logger ) {
668
669
if ( key . match ( / ^ l o g \w / ) ) {
669
- exports [ key ] = ( function ( key ) {
670
+ exports [ key ] = ( function ( key2 ) {
670
671
return function ( ) {
671
672
var args = [ "[outbound] " ] ;
672
673
for ( var i = 0 , l = arguments . length ; i < l ; i ++ ) {
673
674
args . push ( arguments [ i ] ) ;
674
675
}
675
- logger [ key ] . apply ( logger , args ) ;
676
+ logger [ key2 ] . apply ( logger , args ) ;
676
677
} ;
677
678
} ) ( key ) ;
678
- HMailItem . prototype [ key ] = ( function ( key ) {
679
+ HMailItem . prototype [ key ] = ( function ( key2 ) {
679
680
return function ( ) {
680
681
var args = [ this ] ;
681
682
for ( var i = 0 , l = arguments . length ; i < l ; i ++ ) {
682
683
args . push ( arguments [ i ] ) ;
683
684
}
684
- logger [ key ] . apply ( logger , args ) ;
685
+ logger [ key2 ] . apply ( logger , args ) ;
685
686
} ;
686
687
} ) ( key ) ;
687
688
}
@@ -879,13 +880,13 @@ exports.lookup_mx = function lookup_mx (domain, cb) {
879
880
// wrap_mx() to return same thing as resolveMx() does.
880
881
wrap_mx = function ( a ) { return { priority :0 , exchange :a } ; } ;
881
882
// IS: IPv6 compatible
882
- dns . resolve ( domain , function ( err , addresses ) {
883
- if ( process_dns ( err , addresses ) ) {
883
+ dns . resolve ( domain , function ( err2 , addresses2 ) {
884
+ if ( process_dns ( err2 , addresses2 ) ) {
884
885
return ;
885
886
}
886
- err = new Error ( "Found nowhere to deliver to" ) ;
887
- err . code = 'NOMX' ;
888
- cb ( err ) ;
887
+ err2 = new Error ( "Found nowhere to deliver to" ) ;
888
+ err2 . code = 'NOMX' ;
889
+ cb ( err2 ) ;
889
890
} ) ;
890
891
} ) ;
891
892
} ;
@@ -987,8 +988,8 @@ HMailItem.prototype.try_deliver = function () {
987
988
988
989
this . loginfo ( "Looking up " + family + " records for: " + host ) ;
989
990
990
- // now we have a host, we have to lookup the addresses for that host
991
- // and try each one in order they appear
991
+ // we have a host, look up the addresses for the host
992
+ // and try each in order they appear
992
993
// IS: IPv6 compatible
993
994
dns . resolve ( host , family , function ( err , addresses ) {
994
995
if ( err ) {
@@ -1050,7 +1051,9 @@ HMailItem.prototype.try_deliver_host_on_socket = function (mx, host, port, socke
1050
1051
var self = this ;
1051
1052
var processing_mail = true ;
1052
1053
1053
- this . loginfo ( "Attempting to deliver to: " + host + ":" + port + ( mx . using_lmtp ? " using LMTP" : "" ) + " (" + delivery_queue . length ( ) + ") (" + temp_fail_queue . length ( ) + ")" ) ;
1054
+ this . loginfo ( "Attempting to deliver to: " + host + ":" + port +
1055
+ ( mx . using_lmtp ? " using LMTP" : "" ) + " (" + delivery_queue . length ( ) +
1056
+ ") (" + temp_fail_queue . length ( ) + ")" ) ;
1054
1057
1055
1058
socket . on ( 'error' , function ( err ) {
1056
1059
if ( processing_mail ) {
@@ -1192,8 +1195,8 @@ HMailItem.prototype.try_deliver_host_on_socket = function (mx, host, port, socke
1192
1195
1193
1196
if ( ! mx . auth_type || ( mx . auth_type && smtp_properties . auth . indexOf ( mx . auth_type . toUpperCase ( ) ) === - 1 ) ) {
1194
1197
// No compatible authentication types offered by the server
1195
- self . logwarn ( 'AUTH configured for domain ' + self . todo . domain + ' but host ' + host +
1196
- 'did not offer any compatible types' +
1198
+ self . logwarn ( 'AUTH configured for domain ' + self . todo . domain + ' but host ' +
1199
+ host + 'did not offer any compatible types' +
1197
1200
( ( mx . auth_type ) ? ' (requested: ' + mx . auth_type + ')' : '' ) +
1198
1201
' (offered: ' + smtp_properties . auth . join ( ',' ) + ')' ) ;
1199
1202
// Proceed without authentication
@@ -1404,9 +1407,9 @@ HMailItem.prototype.try_deliver_host_on_socket = function (mx, host, port, socke
1404
1407
process_ehlo_data ( ) ;
1405
1408
break ;
1406
1409
case 'starttls' :
1407
- var key = config . get ( 'tls_key.pem' , 'binary' ) ;
1408
- var cert = config . get ( 'tls_cert.pem' , 'binary' ) ;
1409
- var tls_options = ( key && cert ) ? { key : key , cert : cert } : { } ;
1410
+ var tkey = config . get ( 'tls_key.pem' , 'binary' ) ;
1411
+ var tcert = config . get ( 'tls_cert.pem' , 'binary' ) ;
1412
+ var tls_options = ( tkey && tcert ) ? { key : tkey , cert : tcert } : { } ;
1410
1413
var config_options = [ 'ciphers' , 'requestCert' , 'rejectUnauthorized' ] ;
1411
1414
1412
1415
for ( var i = 0 ; i < config_options . length ; i ++ ) {
@@ -1779,12 +1782,12 @@ HMailItem.prototype.bounce_respond = function (retval, msg) {
1779
1782
1780
1783
var from = new Address ( '<>' ) ;
1781
1784
var recip = new Address ( this . todo . mail_from . user , this . todo . mail_from . host ) ;
1782
- this . populate_bounce_message ( from , recip , err , function ( err , data_lines ) {
1783
- if ( err ) {
1784
- return self . double_bounce ( "Error populating bounce message: " + err ) ;
1785
+ this . populate_bounce_message ( from , recip , err , function ( err2 , data_lines ) {
1786
+ if ( err2 ) {
1787
+ return self . double_bounce ( "Error populating bounce message: " + err2 ) ;
1785
1788
}
1786
1789
1787
- exports . send_email ( from , recip , data_lines . join ( '' ) , function ( code , msg ) {
1790
+ exports . send_email ( from , recip , data_lines . join ( '' ) , function ( code , msg2 ) {
1788
1791
if ( code === constants . deny ) {
1789
1792
// failed to even queue the mail
1790
1793
return self . double_bounce ( "Unable to queue the bounce message. Not sending bounce!" ) ;
0 commit comments