Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handshakeData.address is undefined, "version": "0.9.16" #1376

Closed
gruntfuddler opened this issue Dec 19, 2013 · 2 comments
Closed

handshakeData.address is undefined, "version": "0.9.16" #1376

gruntfuddler opened this issue Dec 19, 2013 · 2 comments

Comments

@gruntfuddler
Copy link

In the callback for io.set("authorization", fn(handshakeData, callback){...});
The handshakeData.address is undefined in some logged connection requests.

In Manager.prototype.handshakeData, should there be a check for data.request.socket.address?

var connection = data.request.connection,
socket = data.request.socket

...
else if (socket && socket.remoteAddress) {
connectionAddress = {
address: socket.remoteAddress
, port: socket.remotePort
};
}

@3rd-Eden
Copy link
Contributor

In Primus, which wraps socket.io i use: https://github.com/primus/primus/blob/master/forwarded.js to extract IP address information. Might be useful for you as well.

@gruntfuddler
Copy link
Author

What the current handshakeData prototype is doing, what I am asking is whether there is another source of the address, as per my previous post, it seems that yours is doing what I suggest.

Manager.prototype.handshakeData = function (data) {
var connection = data.request.connection
, connectionAddress
, date = new Date;

if (connection.remoteAddress) {
connectionAddress = {
address: connection.remoteAddress
, port: connection.remotePort
};
} else if (connection.socket && connection.socket.remoteAddress) {
connectionAddress = {
address: connection.socket.remoteAddress
, port: connection.socket.remotePort
};
}
return {
headers: data.headers
, address: connectionAddress
, time: date.toString()
, query: data.query
, url: data.request.url
, xdomain: !!data.request.headers.origin
, secure: data.request.connection.secure
, issued: +date
};
};

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants