summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-connect-address-family.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-05-09 16:35:20 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2016-05-28 22:49:36 +0200
commitfb19b800b8fa1385e1e5b8d86bd03bf6e972348c (patch)
treee0b91ab679c3f958b74bb1883a2e62b8675eb496 /test/parallel/test-tls-connect-address-family.js
parent313ef544173965309a5b24e3bf3a7f57af397c01 (diff)
downloadandroid-node-v8-fb19b800b8fa1385e1e5b8d86bd03bf6e972348c.tar.gz
android-node-v8-fb19b800b8fa1385e1e5b8d86bd03bf6e972348c.tar.bz2
android-node-v8-fb19b800b8fa1385e1e5b8d86bd03bf6e972348c.zip
tls,https: respect address family when connecting
Respect the `{ family: 6 }` address family property when connecting to a remote peer over TLS. Fixes: https://github.com/nodejs/node/issues/4139 Fixes: https://github.com/nodejs/node/issues/6440 PR-URL: https://github.com/nodejs/node/pull/6654 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-connect-address-family.js')
-rw-r--r--test/parallel/test-tls-connect-address-family.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js
new file mode 100644
index 0000000000..665a71dfe6
--- /dev/null
+++ b/test/parallel/test-tls-connect-address-family.js
@@ -0,0 +1,27 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const tls = require('tls');
+
+if (!common.hasIPv6) {
+ common.skip('no IPv6 support');
+ return;
+}
+
+const ciphers = 'AECDH-NULL-SHA';
+tls.createServer({ ciphers }, function() {
+ this.close();
+}).listen(common.PORT, '::1', function() {
+ const options = {
+ host: 'localhost',
+ port: common.PORT,
+ family: 6,
+ ciphers: ciphers,
+ rejectUnauthorized: false,
+ };
+ // Will fail with ECONNREFUSED if the address family is not honored.
+ tls.connect(options).once('secureConnect', common.mustCall(function() {
+ assert.strictEqual('::1', this.remoteAddress);
+ this.destroy();
+ }));
+});