Skip to content

Commit

Permalink
IPv6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
smfreegard committed Jul 19, 2012
1 parent 201e2c8 commit 72b94da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion config/smtp.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
; port to listen on
port=2525

; address to listen on (default: all addresses)
; address to listen on (default: all IPv4 addresses)
; set this to ::0 to listen on IPv6 and IPv4 (not all OSes)
;listen_host=0.0.0.0

; Time in seconds to let sockets be idle with no activity
Expand Down
3 changes: 2 additions & 1 deletion connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Address = require('./address').Address;
var uuid = require('./utils').uuid;
var outbound = require('./outbound');
var date_to_str = require('./utils').date_to_str;
var ipaddr = require('ipaddr.js');

var version = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'))).version;

Expand Down Expand Up @@ -43,7 +44,7 @@ for (var key in logger) {
}

function setupClient(self) {
self.remote_ip = self.client.remoteAddress;
self.remote_ip = ipaddr.process(self.client.remoteAddress).toString();
self.lognotice("connect ip=" + self.remote_ip);

self.client.on('end', function() {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"nopt" : ">= 1.0.5",
"generic-pool" : ">= 1.0.9",
"node-syslog" : ">= 1.1.2",
"iconv" : ">= 1.1.3"
"iconv" : ">= 1.1.3",
"ipaddr.js" : ">= 0.1.1"
},
"optionalDependencies": {
"nodeunit" : "https://github.com/godsflaw/nodeunit/tarball/master"
Expand Down
3 changes: 1 addition & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ Server.createServer = function (params) {
}
}

c.set('host', config_data.main.listen_host);
c.listen(parseInt(config_data.main.port));
c.listen(parseInt(config_data.main.port), config_data.main.listen_host);
c.on('listening', listening);
Server.cluster = c;
if (c.isMaster) {
Expand Down

0 comments on commit 72b94da

Please sign in to comment.