Skip to content

fix(client): allow hostnames in server address configuration#2923

Open
felixfaisal wants to merge 2 commits intoapache:masterfrom
felixfaisal:dev
Open

fix(client): allow hostnames in server address configuration#2923
felixfaisal wants to merge 2 commits intoapache:masterfrom
felixfaisal:dev

Conversation

@felixfaisal
Copy link

Which issue does this PR close?

Closes #2882

Rationale

Server address validation previously required a literal socket address, preventing the use of DNS hostnames. This change allows hostnames (e.g., localhost:8080) in addition to IP addresses.

What changed?

Server address validation previously relied on SocketAddr parsing, which only accepts literal IP addresses and rejected DNS hostnames (e.g., localhost:8080). This prevented using hostnames when configuring client connections.

Validation now uses ToSocketAddrs, which performs address resolution and returns the list of socket addresses for a given host. TcpStream::connect(...) already performs this resolution internally and attempts to connect to each resolved address.

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

If AI tools were used, please answer:

  1. Which tools? ChatGPT free version
  2. Scope of usage? Write documentations like comments
  3. How did you verify the generated code works correctly?
  • I built the code using cargo build
  • I ran the unit tests under TCPConfigBuilder and added an additional unit test, also modifying another
  • I then ran the server and ran the examples
  1. Can you explain every line of the code if asked? Yup

Signed-off-by: Faisal Ahmed <faisalahmedfarooq46@gmail.com>
Signed-off-by: Faisal Ahmed <faisalahmedfarooq46@gmail.com>
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.08%. Comparing base (261d255) to head (b515b76).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ebsocket_config/websocket_client_config_builder.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2923      +/-   ##
============================================
- Coverage     70.08%   70.08%   -0.01%     
  Complexity      776      776              
============================================
  Files          1028     1028              
  Lines         85279    85282       +3     
  Branches      62653    62668      +15     
============================================
+ Hits          59771    59772       +1     
+ Misses        22980    22977       -3     
- Partials       2528     2533       +5     
Flag Coverage Δ
csharp 67.43% <ø> (-0.19%) ⬇️
go 36.37% <ø> (ø)
java 56.26% <ø> (ø)
node 91.37% <ø> (-0.07%) ⬇️
python 81.43% <ø> (ø)
rust 70.66% <87.50%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...figuration/tcp_config/tcp_client_config_builder.rs 67.70% <100.00%> (+2.11%) ⬆️
...ebsocket_config/websocket_client_config_builder.rs 0.00% <0.00%> (ø)

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@hubcio hubcio left a comment

Choose a reason for hiding this comment

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

hey, thanks for the pr! the intent is solid but there's a fundamental issue with the approach.

to_socket_addrs() calls getaddrinfo() under the hood, which is a synchronous blocking dns lookup. doing this inside build() means config construction now requires network access and can block the thread for seconds if dns is slow. config builders hould be pure/deterministic - th quic builder already gets this right by doing zero address validation in build(). we cannot accept this resolution.

validate the format only (valid host:port structure, port is a valid u16) and leave actual dns resolution to connect time. TcpStream::connect already does resolution internally anyway.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust SDK: Support DNS addresses in client

2 participants