Skip to content

Commit 65d7229

Browse files
committed
.address() returned server ip >_<, solved with this patch and adjusted the test
suite
1 parent e4ac72a commit 65d7229

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

lib/manager.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,16 @@ Manager.prototype.handshakeData = function (data) {
820820
var connection = data.request.connection
821821
, connectionAddress;
822822

823-
if (connection.address) {
824-
connectionAddress = connection.address();
825-
} else if (connection.socket && connection.socket.address) {
826-
connectionAddress = connection.socket.address()
823+
if (connection.remoteAddress) {
824+
connectionAddress = {
825+
remoteAddress: connection.remoteAddress
826+
, remotePort: connection.remotePort
827+
};
828+
} else if (connection.socket && connection.socket.remoteAddress) {
829+
connectionAddress = {
830+
remoteAddress: connection.socket.remoteAddress
831+
, remotePort: connection.socket.remotePort
832+
};
827833
}
828834

829835
return {

test/namespace.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ module.exports = {
8080
fn(null, true);
8181
})
8282
.on('connection', function (socket) {
83-
socket.handshake.address.address.should.equal('127.0.0.1');
84-
socket.handshake.address.port.should.equal(ports);
83+
(!!socket.handshake.address.remoteAddress).should.be.true;
84+
(!!socket.handshake.address.remotePort).should.be.true;
8585
socket.handshake.headers.host.should.equal('localhost');
8686
socket.handshake.headers.connection.should.equal('keep-alive');
8787
socket.handshake.time.should.match(/GMT/);

test/transports.websocket.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,8 @@ module.exports = {
14931493
, ws;
14941494

14951495
io.sockets.on('connection', function (socket) {
1496-
socket.handshake.address.address.should.equal('127.0.0.1');
1497-
socket.handshake.address.port.should.equal(ports);
1496+
(!!socket.handshake.address.remoteAddress).should.be.true;
1497+
(!!socket.handshake.address.remotePort).should.be.true;
14981498
socket.handshake.headers.host.should.equal('localhost');
14991499
socket.handshake.headers.connection.should.equal('keep-alive');
15001500
socket.handshake.time.should.match(/GMT/);

0 commit comments

Comments
 (0)