Repository navigation
feat(destination): add a shared outbound destination policy - #372
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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}withCheck,Control(anet.Dialer.Controlhook),Dialer,TransportandClient. Metadata is denied unlessAllowCloudMetadatais set, even when an allow prefix covers it.Transport/Clientrefuse 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) withCheckandPolicy().PolicyandErrDeniedrather thanDestinationPolicy/ErrDestinationDeniedto 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-lintandgosecpass. 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/netfirst.🤖 Generated with Claude Code