Fix remoteFamily on Node v0.10

This commit is contained in:
Ian Scott 2016-05-16 09:45:39 -07:00
parent a42f043768
commit 1f5e2310a6

View file

@ -39,7 +39,8 @@ XClient.prototype.init = function(stream)
this.stream = stream;
this.authHost = stream.remoteAddress;
this.authFamily = stream.remoteFamily;
// Node v0.10.x does not have stream.remoteFamily, so dig in to find it
this.authFamily = stream._getpeername ? stream._getpeername().family : stream.remoteFamily;
if (!this.authHost || this.authHost === '127.0.0.1' || this.authHost === '::1') {
this.authHost = os.hostname();
this.authFamily = null;