Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit d820b64

Browse files
committed
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.
1 parent 8123560 commit d820b64

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

doc/api/tls.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ The string representation of the remote IP address. For example,
557557

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

560+
### cleartextStream.localAddress
561+
562+
The string representation of the local IP address.
563+
564+
### cleartextStream.localPort
565+
566+
The numeric representation of the local port.
567+
560568
[OpenSSL cipher list format documentation]: http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT
561569
[BEAST attacks]: http://blog.ivanristic.com/2011/10/mitigating-the-beast-attack-on-tls.html
562570
[CleartextStream]: #tls_class_tls_cleartextstream

lib/tls.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,17 @@ CleartextStream.prototype.__defineGetter__('remotePort', function() {
695695
return this.socket && this.socket.remotePort;
696696
});
697697

698+
699+
CleartextStream.prototype.__defineGetter__('localAddress', function() {
700+
return this.socket && this.socket.localAddress;
701+
});
702+
703+
704+
CleartextStream.prototype.__defineGetter__('localPort', function() {
705+
return this.socket && this.socket.localPort;
706+
});
707+
708+
698709
function EncryptedStream(pair, options) {
699710
CryptoStream.call(this, pair, options);
700711
}

test/simple/test-tls-remote.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ var server = tls.Server(options, function(s) {
4141

4242
assert.equal(s.remoteAddress, s.socket.remoteAddress);
4343
assert.equal(s.remotePort, s.socket.remotePort);
44+
45+
assert.equal(s.localAddress, s.socket.localAddress);
46+
assert.equal(s.localPort, s.socket.localPort);
4447
s.end();
4548
});
4649

0 commit comments

Comments
 (0)