Repository navigation
feat(http): add ClientAddr and ClientIPConfig for trusted-proxy client addresses - #371
Merged
Merged
Conversation
…t addresses ClientIPResolver.ClientAddr returns a netip.Addr and ClientIP is deprecated. Trusted-proxy mode now reads Forwarded when X-Forwarded-For is absent, accepts entries with ports, and stops at a malformed hop instead of skipping it. ClientIPConfig takes the trust model from configuration. GetClientIP is documented as display and logging only. 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 #369.
Changes
ClientIPResolver.ClientAddrreturns anetip.Addr;ClientIPis deprecated.PrincipalFuncuses it.Forwardedfor=whenX-Forwarded-Foris absent, accepts entries with ports, handles repeated header lines, and ends the walk at a malformed hop instead of skipping it (an address left of a hop no trusted proxy vouched for is not trusted).ClientIPConfig(trusted-proxies,trusted-header) withCheckandResolver().trusted-proxiesis[]string, likeNetworkACLConfig, to avoid depending on mapstructure decodingnetip.Prefix.GetClientIPdocs point to the resolver; its behaviour is unchanged.Notes
RemoteAddris already the real client, so the zero-config resolver applies. No end-to-end test through the PROXY listener is included.dioad/netbefore they can adopt this.Testing
go test -race ./...,golangci-lintandgosecpass.🤖 Generated with Claude Code