| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,10 @@ Object.defineProperty(exports, 'localhostIPv4', { | |||
| 180 | 180 | } | |
| 181 | 181 | }); | |
| 182 | 182 | ||
| 183 | + Object.defineProperty(exports, 'localhostIPv6', { | ||
| 184 | + get: () => '::1' | ||
| 185 | + }); | ||
| 186 | + | ||
| 183 | 187 | // opensslCli defined lazily to reduce overhead of spawnSync | |
| 184 | 188 | Object.defineProperty(exports, 'opensslCli', { get: function() { | |
| 185 | 189 | if (opensslCli !== null) return opensslCli; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,20 +6,39 @@ const net = require('net'); | |||
| 6 | 6 | // EADDRINUSE is expected to occur on FreeBSD | |
| 7 | 7 | // Ref: https://github.com/nodejs/node/issues/13055 | |
| 8 | 8 | const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; | |
| 9 | - const client = net.connect({ | ||
| 9 | + | ||
| 10 | + const optionsIPv4 = { | ||
| 10 | 11 | port: common.PORT, | |
| 11 | 12 | localPort: common.PORT + 1, | |
| 12 | 13 | localAddress: common.localhostIPv4 | |
| 13 | - }); | ||
| 14 | + }; | ||
| 15 | + | ||
| 16 | + const optionsIPv6 = { | ||
| 17 | + host: common.localhostIPv6, | ||
| 18 | + port: common.PORT + 2, | ||
| 19 | + localPort: common.PORT + 3, | ||
| 20 | + localAddress: common.localhostIPv6 | ||
| 21 | + }; | ||
| 14 | 22 | ||
| 15 | - client.on('error', common.mustCall(function onError(err) { | ||
| 23 | + function onError(err, options) { | ||
| 16 | 24 | assert.ok(expectedErrorCodes.includes(err.code)); | |
| 17 | 25 | assert.strictEqual(err.syscall, 'connect'); | |
| 18 | - assert.strictEqual(err.localPort, common.PORT + 1); | ||
| 19 | - assert.strictEqual(err.localAddress, common.localhostIPv4); | ||
| 26 | + assert.strictEqual(err.localPort, options.localPort); | ||
| 27 | + assert.strictEqual(err.localAddress, options.localAddress); | ||
| 20 | 28 | assert.strictEqual( | |
| 21 | 29 | err.message, | |
| 22 | 30 | `connect ${err.code} ${err.address}:${err.port} ` + | |
| 23 | 31 | `- Local (${err.localAddress}:${err.localPort})` | |
| 24 | 32 | ); | |
| 25 | - })); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + const clientIPv4 = net.connect(optionsIPv4); | ||
| 36 | + clientIPv4.on('error', common.mustCall((err) => onError(err, optionsIPv4))); | ||
| 37 | + | ||
| 38 | + if (!common.hasIPv6) { | ||
| 39 | + common.printSkipMessage('ipv6 part of test, no IPv6 support'); | ||
| 40 | + return; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + const clientIPv6 = net.connect(optionsIPv6); | ||
| 44 | + clientIPv6.on('error', common.mustCall((err) => onError(err, optionsIPv6))); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments