From d820b6441211ce79ed09ee3ef3992bc48e78bd93 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 20 May 2013 15:14:30 +0200 Subject: [PATCH] tls: add localAddress and localPort properties Add localAddress and localPort properties to tls.CleartextStream. Like remoteAddress and localPort, delegate to the backing net.Socket object. Refs #5502. --- doc/api/tls.markdown | 8 ++++++++ lib/tls.js | 11 +++++++++++ test/simple/test-tls-remote.js | 3 +++ 3 files changed, 22 insertions(+) diff --git a/doc/api/tls.markdown b/doc/api/tls.markdown index d99507cdc..00cacad28 100644 --- a/doc/api/tls.markdown +++ b/doc/api/tls.markdown @@ -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 diff --git a/lib/tls.js b/lib/tls.js index 0c5bb633b..c0b59d99b 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -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); } diff --git a/test/simple/test-tls-remote.js b/test/simple/test-tls-remote.js index c711a294a..3df83f8bc 100644 --- a/test/simple/test-tls-remote.js +++ b/test/simple/test-tls-remote.js @@ -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(); });