Merge pull request #55 from braydonf/bug/addr-port
fixed bug with incoming connections not having a port on addr
This commit is contained in:
commit
fa06ce01e9
@ -366,6 +366,7 @@ Pool.prototype.listen = function() {
|
|||||||
} else {
|
} else {
|
||||||
addr.ip.v4 = socket.remoteAddress;
|
addr.ip.v4 = socket.remoteAddress;
|
||||||
}
|
}
|
||||||
|
addr.port = socket.remotePort;
|
||||||
|
|
||||||
addr = self._addAddr(addr);
|
addr = self._addAddr(addr);
|
||||||
self._addConnectedPeer(socket, addr);
|
self._addConnectedPeer(socket, addr);
|
||||||
|
|||||||
22
test/pool.js
22
test/pool.js
@ -486,6 +486,28 @@ describe('Pool', function() {
|
|||||||
pool.listen();
|
pool.listen();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('include port for addr on incoming connections', function(done) {
|
||||||
|
var port = 12345;
|
||||||
|
sinon.stub(net, 'createServer', function(callback) {
|
||||||
|
callback({
|
||||||
|
remoteAddress: '127.0.0.1',
|
||||||
|
remotePort: port
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
listen: sinon.stub()
|
||||||
|
};
|
||||||
|
});
|
||||||
|
var pool = new Pool({network: Networks.livenet, maxSize: 1});
|
||||||
|
pool._addAddr = function(addr) {
|
||||||
|
should.exist(addr.port);
|
||||||
|
addr.port.should.equal(port);
|
||||||
|
net.createServer.restore();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
pool._addConnectedPeer = sinon.stub();
|
||||||
|
pool.listen();
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle an ipv4 connection', function(done) {
|
it('should handle an ipv4 connection', function(done) {
|
||||||
var ipv4 = '127.0.0.1';
|
var ipv4 = '127.0.0.1';
|
||||||
sinon.stub(net, 'createServer', function(callback) {
|
sinon.stub(net, 'createServer', function(callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user