Skip to content

feat(http): add ClientAddr and ClientIPConfig for trusted-proxy client addresses - #371

Merged
patdowney merged 1 commit into
masterfrom
feat/trusted-client-addr
Nov 15, 2026
Merged

patdowney merged 1 commit into
masterfrom
feat/trusted-client-addr

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

Closes #369.

Changes

  • ClientIPResolver.ClientAddr returns a netip.Addr; ClientIP is deprecated. PrincipalFunc uses it.
  • Trusted-proxy mode reads Forwarded for= when X-Forwarded-For is 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) with Check and Resolver(). trusted-proxies is []string, like NetworkACLConfig, to avoid depending on mapstructure decoding netip.Prefix.
  • GetClientIP docs point to the resolver; its behaviour is unchanged.

Notes

  • Behind the PROXY protocol RemoteAddr is already the real client, so the zero-config resolver applies. No end-to-end test through the PROXY listener is included.
  • Consumers need a release of dioad/net before they can adopt this.

Testing

go test -race ./..., golangci-lint and gosec pass.

🤖 Generated with Claude Code

…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>
@patdowney
patdowney merged commit 7d07749 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 trusted-proxy-aware client address; GetClientIP is spoofable and used as a rate-limit key

1 participant