fix(client): allow hostnames in server address configuration#2923
fix(client): allow hostnames in server address configuration#2923felixfaisal wants to merge 2 commits intoapache:masterfrom
Conversation
Signed-off-by: Faisal Ahmed <faisalahmedfarooq46@gmail.com>
Signed-off-by: Faisal Ahmed <faisalahmedfarooq46@gmail.com>
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
hubcio
left a comment
There was a problem hiding this comment.
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.
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
SocketAddrparsing, 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
AI Usage
If AI tools were used, please answer:
cargo buildTCPConfigBuilderand added an additional unit test, also modifying another