mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 14:12:45 +00:00

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>
28 lines
686 B
JavaScript
28 lines
686 B
JavaScript
'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();
|
|
}));
|
|
});
|