Skip to content

fix(socks-proxy-agent): trim brackets from IPv6 literal proxy hosts - #452

Open
rajanpanth wants to merge 1 commit into
TooTallNate:mainfrom
rajanpanth:fix/socks-ipv6-bracket-trim
Open

fix(socks-proxy-agent): trim brackets from IPv6 literal proxy hosts#452
rajanpanth wants to merge 1 commit into
TooTallNate:mainfrom
rajanpanth:fix/socks-ipv6-bracket-trim

Conversation

@rajanpanth

Copy link
Copy Markdown

Fixes #437.

WHATWG URL keeps the brackets in hostname for IPv6 literals (new URL('socks://[::1]:1080').hostname === '[::1]'), and parseSocksURL passed that straight through as the proxy host, so the socks connection tried to resolve [::1] as a name and failed with getaddrinfo ENOTFOUND [::1].

The fix mirrors the trim this monorepo already does in https-proxy-agent (same regex, same comment), so the two agents now treat IPv6 proxy URLs the same way:

// Trim off the brackets from IPv6 addresses
const host = url.hostname.replace(/^\[|\]$/g, '');

Non-bracketed hosts are untouched (127.0.0.1, hostnames), and a changeset is not included since I do not know the release cadence you want; happy to add one.

Test added asserting socks5h://[::1]:1080 produces proxy.host === '::1'. 13 passing; with the source change reverted, the new test fails.

WHATWG URL keeps the brackets in hostname for IPv6 literals, so
socks://[::1]:1080 passed [::1] to the socks connection and failed
with getaddrinfo ENOTFOUND. Mirrors the existing trim in
https-proxy-agent.

Fixes TooTallNate#437
@changeset-bot

changeset-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: aec7eb2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

socks-proxy-agent does not trim IPv6 literal brackets before connecting to proxy host

1 participant