fix: preserve original hostname on HTTP socket when using DNS interceptor#5581
Closed
mcollina wants to merge 1 commit into
Closed
fix: preserve original hostname on HTTP socket when using DNS interceptor#5581mcollina wants to merge 1 commit into
mcollina wants to merge 1 commit into
Conversation
…ptor When the DNS interceptor resolves the hostname and replaces the connection origin with the resolved IP address, the original hostname was lost for HTTP connections. For HTTPS, the hostname was still available through TLS SNI (servername), but for plain HTTP it was nowhere accessible on the socket. This fix: 1. Sets client[kServerName] for HTTP connections when request.servername differs (the DNS interceptor already sets servername in dispatch opts) 2. Overrides socket._host with the original hostname for HTTP connections when servername is provided Fixes: #5573
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5581 +/- ##
==========================================
+ Coverage 93.44% 93.46% +0.02%
==========================================
Files 110 110
Lines 37443 37601 +158
==========================================
+ Hits 34987 35144 +157
- Misses 2456 2457 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
#5573
Problem
When the DNS interceptor resolves a hostname and replaces the connection origin with the resolved IP address, the original hostname is lost for HTTP connections. For HTTPS, the hostname remains accessible through TLS SNI (servername), but for plain HTTP it is nowhere available on the socket.
This breaks diagnostics channel instrumentation that relies on the original hostname for metrics attribution.
Changes
lib/dispatcher/client.js: Sets
client[kServerName]for HTTP connections whenrequest.servernamediffers (the DNS interceptor already setsservernamein dispatch opts)lib/core/connect.js: Overrides
socket._hostwith the original hostname for HTTP connections whenservernameis providedtest/interceptors/dns.js: Adds test verifying
socket._hostis the original hostname when using the DNS interceptor with HTTPVerification
All existing DNS interceptor tests pass.