GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: reapply servername on happy eyeballs connect · nodejs/node@fd2620d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _tls_wrap.js
  • test/parallel
    • test-https-autoselectfamily.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,14 @@ TLSSocket.prototype._init = function(socket, wrap) {
832832
}
833833
}
834834

835+
// We can only come here via [kWrapConnectedHandle]() call that happens
836+
// if the connection is established with `autoSelectFamily` set to `true`.
837+
const connectOptions = this[kConnectOptions];
838+
if (!options.isServer && connectOptions) {
839+
if (connectOptions.servername) {
840+
this.setServername(connectOptions.servername);
841+
}
842+
}
835843

836844
if (options.handshakeTimeout > 0)
837845
this.setTimeout(options.handshakeTimeout, this._handleTimeout);
Collapse file

‎test/parallel/test-https-autoselectfamily.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-https-autoselectfamily.js
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
7474
// Test that IPV4 is reached if IPV6 is not reachable
7575
{
7676
createDnsServer('::1', '127.0.0.1', common.mustCall(function({ dnsServer, lookup }) {
77-
const ipv4Server = createServer(options, common.mustCall((_, res) => {
77+
const ipv4Server = createServer(options, common.mustCall((req, res) => {
78+
assert.strictEqual(req.socket.servername, 'example.org');
7879
res.writeHead(200, { Connection: 'close' });
7980
res.end('response-ipv4');
8081
}));
@@ -86,6 +87,7 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
8687
lookup,
8788
rejectUnauthorized: false,
8889
autoSelectFamily: true,
90+
servername: 'example.org',
8991
},
9092
(res) => {
9193
assert.strictEqual(res.statusCode, 200);
@@ -111,12 +113,14 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
111113
// Test that IPV4 is NOT reached if IPV6 is reachable
112114
if (common.hasIPv6) {
113115
createDnsServer('::1', '127.0.0.1', common.mustCall(function({ dnsServer, lookup }) {
114-
const ipv4Server = createServer(options, common.mustNotCall((_, res) => {
116+
const ipv4Server = createServer(options, common.mustNotCall((req, res) => {
117+
assert.strictEqual(req.socket.servername, 'example.org');
115118
res.writeHead(200, { Connection: 'close' });
116119
res.end('response-ipv4');
117120
}));
118121

119-
const ipv6Server = createServer(options, common.mustCall((_, res) => {
122+
const ipv6Server = createServer(options, common.mustCall((req, res) => {
123+
assert.strictEqual(req.socket.servername, 'example.org');
120124
res.writeHead(200, { Connection: 'close' });
121125
res.end('response-ipv6');
122126
}));
@@ -131,6 +135,7 @@ if (common.hasIPv6) {
131135
lookup,
132136
rejectUnauthorized: false,
133137
autoSelectFamily: true,
138+
servername: 'example.org',
134139
},
135140
(res) => {
136141
assert.strictEqual(res.statusCode, 200);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.