Skip to content

Commit

Permalink
tls: add localAddress and localPort properties
Browse files Browse the repository at this point in the history
Add localAddress and localPort properties to tls.CleartextStream.
Like remoteAddress and localPort, delegate to the backing net.Socket
object.

Refs nodejs#5502.
  • Loading branch information
bnoordhuis committed May 20, 2013
1 parent 8123560 commit d820b64
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/api/tls.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ The string representation of the remote IP address. For example,

The numeric representation of the remote port. For example, `443`.

### cleartextStream.localAddress

The string representation of the local IP address.

### cleartextStream.localPort

The numeric representation of the local port.

[OpenSSL cipher list format documentation]: http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT
[BEAST attacks]: http://blog.ivanristic.com/2011/10/mitigating-the-beast-attack-on-tls.html
[CleartextStream]: #tls_class_tls_cleartextstream
Expand Down
11 changes: 11 additions & 0 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,17 @@ CleartextStream.prototype.__defineGetter__('remotePort', function() {
return this.socket && this.socket.remotePort;
});


CleartextStream.prototype.__defineGetter__('localAddress', function() {
return this.socket && this.socket.localAddress;
});


CleartextStream.prototype.__defineGetter__('localPort', function() {
return this.socket && this.socket.localPort;
});


function EncryptedStream(pair, options) {
CryptoStream.call(this, pair, options);
}
Expand Down
3 changes: 3 additions & 0 deletions test/simple/test-tls-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var server = tls.Server(options, function(s) {

assert.equal(s.remoteAddress, s.socket.remoteAddress);
assert.equal(s.remotePort, s.socket.remotePort);

assert.equal(s.localAddress, s.socket.localAddress);
assert.equal(s.localPort, s.socket.localPort);
s.end();
});

Expand Down

0 comments on commit d820b64

Please sign in to comment.