Add wildcard forced hosts (fix #1587)#1826
Open
lllincoln wants to merge 10 commits into
Open
Conversation
underscore11code
suggested changes
Jun 22, 2026
underscore11code
approved these changes
Jun 23, 2026
WouterGritter
requested changes
Jun 23, 2026
…ngPattern statically, import JUnit methods statically to match other tests
Member
|
This would most likely make #1730 redundant. |
Author
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.
I added wildcard support to
[forced-hosts], resolving #1587. Unit tests pass and checkstyle passes and I've tested this against my own running proxy. I'd appreciate feedback or additional testing if needed, especially from those on #1587 who submitted the issue.What this does
Consider the example from #1587
Now this can be changed to:
How matching works
I added
AddressUtil.isHostMatchingPattern(pattern, host). Patterns are matched on each label where*matches exactly one label. To be matched, patterns must have the same number of labels as the host. Matching is case insensitive. For example:*.example.commatchesa.example.combut notexample.com(fewer labels) orb.a.example.com(more labels).b.*.example.commatchesb.a.example.comMatching order
In both
ConnectedPlayerandServerListPingHandler, forced-host lookup now follows a hierarchy where exact matches always win over wildcards, so adding a*.example.comentry won't change routing for any host you've already defined explicitly.getAttemptConnectionOrder()inServerListPingHandler, or an empty collection inConnectedPlayer. this are both unchanged from what was before).Tests
I added
ForcedHostsTestcoveringisHostMatchingPatterncases for single and mid-pattern wildcards, label-count mismatches, and a non-matching domain.Potential issue
If two different wildcard patterns could match the same host, the one chosen depends on config map iteration order. Would like feedback on what the behavior should be here