Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: omit server name when HTTP2 host is IP address #56530

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

islandryu
Copy link
Contributor

Fixes: #56189

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Jan 9, 2025
Comment on lines +639 to +645
let hostName = socket.servername;
if (hostName === null || hostName === false) {
if (socket.remoteFamily === 'IPv6') {
hostName = `[${socket.remoteAddress}]`;
} else {
hostName = socket.remoteAddress;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host: the value sent in Server Name Indication (SNI) ([RFC6066],
Section 3) converted to lower case; if SNI is not present, the
remote address of the connection (i.e., the server's IP address)

According to RFC 8336, when the server name is not set, the server's address should be used instead.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.19%. Comparing base (67b647e) to head (72eb4dc).
Report is 93 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56530      +/-   ##
==========================================
+ Coverage   88.54%   89.19%   +0.65%     
==========================================
  Files         657      662       +5     
  Lines      190689   191808    +1119     
  Branches    36602    36926     +324     
==========================================
+ Hits       168844   171089    +2245     
+ Misses      15029    13564    -1465     
- Partials     6816     7155     +339     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 95.54% <100.00%> (+<0.01%) ⬆️

... and 140 files with indirect coverage changes

})
);
}, 2));
server.on('close', common.mustCall());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
server.on('close', common.mustCall());

let data = '';
req.setEncoding('utf8');
req.on('data', (d) => data += d);
req.on('end', common.mustCall(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the requests be done in parallel? Then server can be closed with something in the listeners of 'end' events

if (++done === 2) server.close();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some adjustments to process the requests in parallel.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 13, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 13, 2025
@nodejs-github-bot
Copy link
Collaborator

const ipv4Url = `https://127.0.0.1:${server.address().port}`;
const ipv6Url = `https://[::1]:${server.address().port}`;
handleRequest(ipv4Url);
if (common.hasIPv6) handleRequest(ipv6Url);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this branch because the EADDRNOTAVAIL error was occurring in the tests.

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 14, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 14, 2025
@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Jan 14, 2025
Comment on lines 42 to 45
if (++done === 2) server.close();
if (++done === testCount) server.close();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that the number of tests changes if you don't test for IPv6.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 14, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 14, 2025
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP2 client incorrectly sets TLS ServerName to an IP address
5 participants