net: add remoteFamily for socket
Signed-off-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
parent
2bb4867312
commit
e1ce8ba639
@ -449,6 +449,10 @@ the socket is `ref`d calling `ref` again will have no effect.
|
||||
The string representation of the remote IP address. For example,
|
||||
`'74.125.127.100'` or `'2001:4860:a005::68'`.
|
||||
|
||||
### socket.remoteFamily
|
||||
|
||||
The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
||||
|
||||
### socket.remotePort
|
||||
|
||||
The numeric representation of the remote port. For example,
|
||||
|
@ -772,6 +772,10 @@ object with three properties, e.g.
|
||||
The string representation of the remote IP address. For example,
|
||||
`'74.125.127.100'` or `'2001:4860:a005::68'`.
|
||||
|
||||
### tlsSocket.remoteFamily
|
||||
|
||||
The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
||||
|
||||
### tlsSocket.remotePort
|
||||
|
||||
The numeric representation of the remote port. For example, `443`.
|
||||
|
@ -552,6 +552,9 @@ CleartextStream.prototype.__defineGetter__('remoteAddress', function() {
|
||||
return this.socket && this.socket.remoteAddress;
|
||||
});
|
||||
|
||||
CleartextStream.prototype.__defineGetter__('remoteFamily', function() {
|
||||
return this.socket && this.socket.remoteFamily;
|
||||
});
|
||||
|
||||
CleartextStream.prototype.__defineGetter__('remotePort', function() {
|
||||
return this.socket && this.socket.remotePort;
|
||||
|
@ -570,6 +570,9 @@ Socket.prototype.__defineGetter__('remoteAddress', function() {
|
||||
return this._getpeername().address;
|
||||
});
|
||||
|
||||
Socket.prototype.__defineGetter__('remoteFamily', function() {
|
||||
return this._getpeername().family;
|
||||
});
|
||||
|
||||
Socket.prototype.__defineGetter__('remotePort', function() {
|
||||
return this._getpeername().port;
|
||||
|
@ -35,6 +35,7 @@ server.listen(common.PORT, function() {
|
||||
// client is still attempting to connect
|
||||
assert.doesNotThrow(function() {
|
||||
client.remoteAddress;
|
||||
client.remoteFamily;
|
||||
client.remotePort;
|
||||
});
|
||||
accessedProperties = true;
|
||||
|
@ -29,6 +29,7 @@ var conns = 0, conns_closed = 0;
|
||||
var server = net.createServer(function(socket) {
|
||||
conns++;
|
||||
assert.equal('127.0.0.1', socket.remoteAddress);
|
||||
assert.equal('IPv4', socket.remoteFamily);
|
||||
assert.ok(socket.remotePort);
|
||||
assert.notEqual(socket.remotePort, common.PORT);
|
||||
socket.on('end', function() {
|
||||
@ -42,11 +43,13 @@ server.listen(common.PORT, 'localhost', function() {
|
||||
var client2 = net.createConnection(common.PORT);
|
||||
client.on('connect', function() {
|
||||
assert.equal('127.0.0.1', client.remoteAddress);
|
||||
assert.equal('IPv4', client.remoteFamily);
|
||||
assert.equal(common.PORT, client.remotePort);
|
||||
client.end();
|
||||
});
|
||||
client2.on('connect', function() {
|
||||
assert.equal('127.0.0.1', client2.remoteAddress);
|
||||
assert.equal('IPv4', client.remoteFamily);
|
||||
assert.equal(common.PORT, client2.remotePort);
|
||||
client2.end();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user