Skip to content

feat(proxy): accept socks5h: proxy URLs - #6085

Open
petrroll wants to merge 1 commit into
nodejs:mainfrom
petrroll:feat-socks5h-proxy
Open

petrroll wants to merge 1 commit into
nodejs:mainfrom
petrroll:feat-socks5h-proxy

Conversation

@petrroll

@petrroll petrroll commented Oct 23, 2026 •

Copy link
Copy Markdown

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 in HTTP_PROXY/HTTPS_PROXY/ALL_PROXY, and ProxyAgent/EnvHttpProxyAgent/Socks5ProxyAgent currently reject it.

Undici already implements socks5h semantics for every SOCKS URL: target host names are never resolved locally. parseAddress in lib/core/socks5-utils.js sends IP literals as ATYP 0x01/0x04 and everything else as ATYP 0x03 (domain name), so the proxy does the DNS lookup. socks5: and socks: therefore already behave like socks5h:, and accepting socks5h: as an alias changes nothing on the wire.

Changes

Features

  • Accept socks5h: proxy URLs in ProxyAgent, EnvHttpProxyAgent (via ProxyAgent) and Socks5ProxyAgent.
  • Centralize the SOCKS scheme check in an internal isSocks5Protocol() helper in lib/core/socks5-utils.js, with a comment explaining that all three schemes behave like socks5h:.
  • Docs for ProxyAgent and Socks5ProxyAgent list socks5h: and state that host names are always resolved by the proxy.
  • Tests: Socks5ProxyAgent constructor accepts socks5h://; end-to-end requests through Socks5ProxyAgent, ProxyAgent and EnvHttpProxyAgent with a socks5h:// 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 its supportedProxyProtocols list; I will rebase this PR accordingly.

Status

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.

This branch has not been deployed

No deployments
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.

1 participant