Repository navigation
Conversation
|
can you solve the conflicts? |
socks5h: is the conventional scheme for a SOCKS5 proxy that resolves target host names (curl, socks-proxy-agent). It is common in HTTP_PROXY/HTTPS_PROXY/ALL_PROXY, but ProxyAgent, EnvHttpProxyAgent and Socks5ProxyAgent rejected it. Undici never resolves target host names locally: they are always sent to the proxy as domain names (ATYP 0x03). So socks5: and socks: already have socks5h: semantics, and socks5h: can be accepted as an alias with no behavior difference. Refs nodejs#6082.
89310c4 to
f038c6e
Compare
|
@metcoder95 rebased |
There was a problem hiding this comment.
🟡 Changes recommended
The new test can fail when NO_PROXY includes localhost because its dispatcher does not explicitly set noProxy: '', allowing the request to bypass the SOCKS proxy and leave targets empty.
1 open issue
What changed in this PR
Adds socks5h: as an alias for Undici’s existing SOCKS5 proxy support, preserving its current proxy-side hostname resolution behavior.
Changes:
- Centralizes SOCKS protocol checks and accepts
socks5h:across all three proxy agents. - Documents the alias and hostname-resolution behavior.
- Adds constructor and end-to-end tests that verify hostnames reach the SOCKS proxy.
| File | Description |
|---|---|
test/socks5-proxy-agent.js |
Tests alias acceptance and hostname forwarding across three agents. |
lib/dispatcher/socks5-proxy-agent.js |
Accepts the alias and updates the validation error. |
lib/dispatcher/proxy-agent.js |
Uses the shared helper to select SOCKS handling. |
lib/core/socks5-utils.js |
Adds the shared protocol helper and explains resolution semantics. |
docs/docs/api/Socks5ProxyAgent.md |
Documents accepted schemes and proxy-side hostname resolution. |
docs/docs/api/ProxyAgent.md |
Lists socks5h: among supported SOCKS schemes. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6085 +/- ##
=======================================
Coverage 91.80% 91.81%
=======================================
Files 113 113
Lines 44961 44978 +17
=======================================
+ Hits 41278 41295 +17
Misses 3683 3683 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Update EnvHttpProxyAgent instantiation to include noProxy option. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@mcollina applies copilot suggestion for test stability |

This relates to...
Refs #6082. Optional follow-up to #6083 (independent of it, can be merged on its own or not at all).
Rationale
socks5h://is the conventional scheme for a SOCKS5 proxy that resolves target host names (curl,socks-proxy-agent, most proxy tooling). Users commonly have it inHTTP_PROXY/HTTPS_PROXY/ALL_PROXY, andProxyAgent/EnvHttpProxyAgent/Socks5ProxyAgentcurrently reject it.Undici already implements
socks5hsemantics for every SOCKS URL: target host names are never resolved locally.parseAddressinlib/core/socks5-utils.jssends IP literals as ATYP 0x01/0x04 and everything else as ATYP 0x03 (domain name), so the proxy does the DNS lookup.socks5:andsocks:therefore already behave likesocks5h:, and acceptingsocks5h:as an alias changes nothing on the wire.Changes
Features
socks5h:proxy URLs inProxyAgent,EnvHttpProxyAgent(viaProxyAgent) andSocks5ProxyAgent.isSocks5Protocol()helper inlib/core/socks5-utils.js, with a comment explaining that all three schemes behave likesocks5h:.ProxyAgentandSocks5ProxyAgentlistsocks5h:and state that host names are always resolved by the proxy.Socks5ProxyAgentconstructor acceptssocks5h://; end-to-end requests throughSocks5ProxyAgent,ProxyAgentandEnvHttpProxyAgentwith asocks5h://proxy, asserting the proxy receives the target as a domain name (localhost).Bug Fixes
N/A
Breaking Changes and Deprecations
None.
If #6083 lands first,
socks5h:also needs adding to itssupportedProxyProtocolslist; I will rebase this PR accordingly.Status