Skip to content

Commit

Permalink
resolve host only if not an ip
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Rodriguez committed Jun 14, 2013
1 parent 2e28324 commit 226e330
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ function Node(spec, options) {
self.options[k] = options[k];
});

// Resolve host, to prevent false duplication
Node.resolveHost(this.host, function(err, host) {
if (err) {
return self.emit('error', err);
}
self.host = host;
self.connect();
});
if (this.host.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {
this.connect();
}
else {
// Resolve host, to prevent false duplication
Node.resolveHost(this.host, function(err, host) {
if (err) {
return self.emit('error', err);
}
self.host = host;
self.connect();
});
}
}
util.inherits(Node, EventEmitter);

Expand Down
3 changes: 2 additions & 1 deletion test/_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ idgen = require('idgen');
path = require('path');

servers = {};
ports = [6380, 6381, 6382];
ports = ['127.0.0.1:6380', 'localhost:6381', 6382];
testId = null;

makeServer = function (port, cb) {
Expand Down Expand Up @@ -49,6 +49,7 @@ makeServers = function (cb) {
testId = idgen(4);
var tasks = {};
ports.forEach(function (port) {
if (typeof port === 'string') port = Number(port.split(':')[1]);
tasks[port] = makeServer.bind(null, port);
});

Expand Down

0 comments on commit 226e330

Please sign in to comment.