feat(hostmatch): match rules by source IP / CIDR#191
Open
drewstone wants to merge 1 commit into
Open
Conversation
Add an optional `source_ip` field to rule config so a rule can match on the client source address (CIDR or single IP) in addition to host. This lets a single proxy apply different allowlists/transforms per source — the routing primitive for a shared, multi-tenant egress proxy fronting many isolated clients. Adds Matcher.MatchesIP and a SourceMatcher on the compiled rule; behaviour is unchanged when source_ip is unset.
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.
What
Adds an optional
source_ipfield to a rule's config so a rule can match on the client source address (a CIDR or single IP) in addition tohost. AddsMatcher.MatchesIPand aSourceMatcheron the compiledRule.Why
We run iron-proxy as the egress filter in front of many mutually-isolated sandbox containers. Matching on source IP lets a single proxy apply a different allowlist / secret-injection transform per source, instead of one proxy process per client — the routing primitive for a shared, multi-tenant egress proxy. We've carried this as a local patch in production; upstreaming so we can drop it.
Compatibility
Behaviour is unchanged when
source_ipis unset — existing host-only rules match exactly as before.Tests
This patch is production-proven in our fork but does not yet add unit tests for the source-IP path. Happy to add
hostmatchtable tests forMatchesIP+ the combined host/source matching if you'd like them in this PR.