Skip to content

feat(destination): add a shared outbound destination policy - #372

Merged
patdowney merged 1 commit into
masterfrom
feat/destination-policy
Nov 15, 2026
Merged

patdowney merged 1 commit into
masterfrom
feat/destination-policy

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

Closes #367.

Changes

New package destination:

  • IsPublicAddress / IsCloudMetadataAddress: special-use ranges from connect's socks5 guard, IPv4-mapped and NAT64 unwrapping, AWS IPv6 metadata range.
  • Policy{AllowPrefixes, OnlyPrefixes, AllowedPorts, AllowCloudMetadata} with Check, Control (a net.Dialer.Control hook), Dialer, Transport and Client. Metadata is denied unless AllowCloudMetadata is set, even when an allow prefix covers it.
  • Transport/Client refuse non-http(s) schemes, ignore proxy environment variables and limit redirects; a redirect to a denied address fails at the dial.
  • Config (allow, only, allowed-ports, allow-cloud-metadata) with Check and Policy().
  • Named Policy and ErrDenied rather than DestinationPolicy/ErrDestinationDenied to avoid stutter; easy to rename if preferred.

Testing

Address-class table, policy rules, dial-time tests with local listeners (loopback refused/allowed, redirect to a denied address, hostname resolving to a denied address via a fake UDP resolver). go test -race ./..., golangci-lint and gosec pass. Parity with connect's existing socks5 and reverse-proxy tests has not been checked; that belongs to the connect migration.

Consumers need a release of dioad/net first.

🤖 Generated with Claude Code

Package destination classifies public addresses (special-use ranges, IPv4-mapped
and NAT64 unwrapping) and enforces a Policy at the socket through a
net.Dialer.Control hook, so redirects, DNS rebinding and multi-address
hostnames are covered. Policy supports allow exceptions, an only-list, ports and
an explicit cloud metadata switch, and offers a dialer, a scheme-checked
transport and a redirect-limited client plus a Config with Check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@patdowney
patdowney merged commit 3e6ba64 into master Nov 15, 2026
5 checks passed
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.

http: a shared outbound destination guard (public-address classification and dial-time Control)

1 participant