Skip to content

fix(proxy): handle IPv6 literals in NO_PROXY host parsing#2976

Open
Tatlatat wants to merge 1 commit into
esengine:v1from
Tatlatat:fix/no-proxy-ipv6
Open

fix(proxy): handle IPv6 literals in NO_PROXY host parsing#2976
Tatlatat wants to merge 1 commit into
esengine:v1from
Tatlatat:fix/no-proxy-ipv6

Conversation

@Tatlatat
Copy link
Copy Markdown
Contributor

@Tatlatat Tatlatat commented Jun 3, 2026

What

buildPattern strips an optional :port from a NO_PROXY segment with
raw.lastIndexOf(":") plus a numeric-suffix check. That breaks IPv6 literals.

For the loopback ::1, the last colon is at index 2 and the suffix "1" is
numeric, so the host is truncated to "::". ::1 then never matches NO_PROXY
and IPv6 loopback is routed through the proxy — even though the function
comment lists "IP literals" as supported.

Fix

Parse the host port-aware of IPv6:

input host
::1 ::1 (was ::)
2001:db8::1 2001:db8::1
[::1]:8080 ::1
[2001:db8::1] 2001:db8::1
host:8080 host
192.168.0.1:443 192.168.0.1
  • Bracketed forms take the text between [ and ].
  • A bare host with exactly one colon and a numeric suffix keeps its :port
    stripped.
  • Anything else (a bare IPv6 literal, which has multiple colons) is left intact.

Test

Added NO_PROXY cases for bare IPv6, bracketed IPv6 with a port, and the
existing host:port case. Verified the IPv6 case fails on the old code and
passes on the fix (53 proxy tests pass).

Verification

npx vitest run tests/proxy.test.ts (53 passed); biome check clean on the
changed files.

buildPattern stripped an optional :port with raw.lastIndexOf(":") + a
numeric-suffix check. For the IPv6 loopback "::1" the last colon is at
index 2 and the suffix "1" is numeric, so the host was truncated to "::"
and "::1" never matched NO_PROXY — IPv6 loopback got routed through the
proxy despite the comment promising IP-literal support.

Parse the host port-aware of IPv6: bracketed forms ("[::1]:8080") take the
text between [ and ]; a bare host with exactly one colon and a numeric
suffix keeps its :port stripped ("host:8080" -> "host"); anything else
(bare IPv6 like "::1" or "2001:db8::1") is left intact. Add NO_PROXY tests
for bare and bracketed IPv6 and the existing host:port case.
@github-actions github-actions Bot added the v1 Legacy TypeScript line (0.x) — v1 branch, maintenance only label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Legacy TypeScript line (0.x) — v1 branch, maintenance only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant