| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0111c61 commit fd4d1e2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2782,7 +2782,16 @@ function connect(authority, options, listener) { | |||
| 2782 | 2782 | const protocol = authority.protocol || options.protocol || 'https:'; | |
| 2783 | 2783 | const port = '' + (authority.port !== '' ? | |
| 2784 | 2784 | authority.port : (authority.protocol === 'http:' ? 80 : 443)); | |
| 2785 | - const host = authority.hostname || authority.host || 'localhost'; | ||
| 2785 | + let host = 'localhost'; | ||
| 2786 | + | ||
| 2787 | + if (authority.hostname) { | ||
| 2788 | + host = authority.hostname; | ||
| 2789 | + | ||
| 2790 | + if (host[0] === '[') | ||
| 2791 | + host = host.slice(1, -1); | ||
| 2792 | + } else if (authority.host) { | ||
| 2793 | + host = authority.host; | ||
| 2794 | + } | ||
| 2786 | 2795 | ||
| 2787 | 2796 | let socket; | |
| 2788 | 2797 | if (typeof options.createConnection === 'function') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const { mustCall, hasCrypto, skip, expectsError } = require('../common'); | ||
| 3 | + const { | ||
| 4 | + mustCall, | ||
| 5 | + hasCrypto, | ||
| 6 | + hasIPv6, | ||
| 7 | + skip, | ||
| 8 | + expectsError | ||
| 9 | + } = require('../common'); | ||
| 4 | 10 | if (!hasCrypto) | |
| 5 | 11 | skip('missing crypto'); | |
| 6 | 12 | const { createServer, connect } = require('http2'); | |
@@ -73,3 +79,25 @@ const { connect: netConnect } = require('net'); | |||
| 73 | 79 | type: Error | |
| 74 | 80 | }); | |
| 75 | 81 | } | |
| 82 | + | ||
| 83 | + // Check for literal IPv6 addresses in URL's | ||
| 84 | + if (hasIPv6) { | ||
| 85 | + const server = createServer(); | ||
| 86 | + server.listen(0, '::1', mustCall(() => { | ||
| 87 | + const { port } = server.address(); | ||
| 88 | + const clients = new Set(); | ||
| 89 | + | ||
| 90 | + clients.add(connect(`http://[::1]:${port}`)); | ||
| 91 | + clients.add(connect(new URL(`http://[::1]:${port}`))); | ||
| 92 | + | ||
| 93 | + for (const client of clients) { | ||
| 94 | + client.once('connect', mustCall(() => { | ||
| 95 | + client.close(); | ||
| 96 | + clients.delete(client); | ||
| 97 | + if (clients.size === 0) { | ||
| 98 | + server.close(); | ||
| 99 | + } | ||
| 100 | + })); | ||
| 101 | + } | ||
| 102 | + })); | ||
| 103 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments