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>
29 lines
696 B
JavaScript
29 lines
696 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const https = require('https');
|
|
|
|
if (!common.hasIPv6) {
|
|
common.skip('no IPv6 support');
|
|
return;
|
|
}
|
|
|
|
const ciphers = 'AECDH-NULL-SHA';
|
|
https.createServer({ ciphers }, function(req, res) {
|
|
this.close();
|
|
res.end();
|
|
}).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.
|
|
https.get(options, common.mustCall(function() {
|
|
assert.strictEqual('::1', this.socket.remoteAddress);
|
|
this.destroy();
|
|
}));
|
|
});
|