Sha256: 44dfacdbace86bb9411a2c94f789a75e11ea2e56f3ce86526570a56a3aecb57e

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

'use strict';
const common = require('../common');
if (!common.hasCrypto) {
  common.skip('missing crypto');
  return;
}

if (!common.hasIPv6) {
  common.skip('no IPv6 support');
  return;
}

const assert = require('assert');
const tls = require('tls');
const dns = require('dns');

function runTest() {
  const ciphers = 'AECDH-NULL-SHA';
  tls.createServer({ ciphers }, common.mustCall(function() {
    this.close();
  })).listen(0, '::1', common.mustCall(function() {
    const options = {
      host: 'localhost',
      port: this.address().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();
    }));
  }));
}

dns.lookup('localhost', {family: 6, all: true}, (err, addresses) => {
  if (err) {
    if (err.code === 'ENOTFOUND') {
      common.skip('localhost does not resolve to ::1');
      return;
    }
    throw err;
  }

  if (addresses.some((val) => val.address === '::1'))
    runTest();
  else
    common.skip('localhost does not resolve to ::1');
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/parallel/test-tls-connect-address-family.js
node-compiler-0.9.0 vendor/node-v7.2.1/test/parallel/test-tls-connect-address-family.js