Skip to content

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

Closed
islandryu wants to merge 4 commits into
nodejs:mainfrom
islandryu:fix/http2
Closed

http2: omit server name when HTTP2 host is IP address#56530
islandryu wants to merge 4 commits into
nodejs:mainfrom
islandryu:fix/http2

Conversation

@islandryu

Copy link
Copy Markdown
Member

Fixes: #56189

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues and 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
Copy Markdown
Member 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.

@codecov

codecov Bot commented Jan 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.19%. Comparing base (67b647e) to head (72eb4dc).
Report is 131 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member 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.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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. Only starts once the PR has an approving review. label Jan 13, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 13, 2025
@nodejs-github-bot

Copy link
Copy Markdown
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);

ghost Jan 14, 2025

Copy link
Copy Markdown
Member 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.

Comment thread test/parallel/test-http2-ip-address-host.js Outdated
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>

ghost left a comment

Copy link
Copy Markdown
Member

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. Only starts once the PR has an approving review. label Jan 14, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 14, 2025
@nodejs-github-bot

ghost commented Jan 14, 2025

Copy link
Copy Markdown
Collaborator

@lpinca lpinca added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Jan 14, 2025
Comment on lines +42 to +45
if (++done === 2) server.close();
if (++done === testCount) server.close();

ghost Jan 14, 2025

Copy link
Copy Markdown
Member 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. Only starts once the PR has an approving review. label Jan 14, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 14, 2025
@nodejs-github-bot

ghost commented Jan 14, 2025

Copy link
Copy Markdown
Collaborator

@lpinca lpinca added the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 18, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Jan 18, 2025
@nodejs-github-bot

ghost commented Jan 18, 2025

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/56530
✔  Done loading data for nodejs/node/pull/56530
----------------------------------- PR info ------------------------------------
Title      http2: omit server name when HTTP2 host is IP address (#56530)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     islandryu:fix/http2 -> nodejs:main
Labels     http2, needs-ci, commit-queue-squash
Commits    4
 - http2: omit server name when HTTP2 host is IP address
 - fix test
 - Update test/parallel/test-http2-ip-address-host.js
 - fix test
Committers 2
 - islandryu <shimaryuhei@gmail.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/56530
Fixes: https://github.com/nodejs/node/issues/56189
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/56530
Fixes: https://github.com/nodejs/node/issues/56189
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - fix test
   ℹ  This PR was created on Thu, 09 Jan 2025 08:41:18 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/56530#pullrequestreview-2546485278
   ✔  - Yongsheng Zhang (@ZYSzys): https://github.com/nodejs/node/pull/56530#pullrequestreview-2548929308
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/56530#pullrequestreview-2548972673
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-01-14T13:02:02Z: https://ci.nodejs.org/job/node-test-pull-request/64501/
- Querying data for job/node-test-pull-request/64501/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/12846830944

@islandryu

ghost commented Jan 20, 2025

Copy link
Copy Markdown
Member Author

@lpinca @mcollina @ZYSzys
Commit queue is failing.
Is there anything I need to do with this PR?

@jasnell

ghost commented Jan 20, 2025

Copy link
Copy Markdown
Member

Landed in fdad2fa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. commit-queue-squash PRs the Commit Queue should land as one squashed commit. http2 Issues and 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

6 participants