Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: have a wildcard domain matcher #645

Open
GlenDC opened this issue Apr 2, 2025 · 5 comments
Open

feature request: have a wildcard domain matcher #645

GlenDC opened this issue Apr 2, 2025 · 5 comments
Milestone

Comments

@GlenDC
Copy link
Contributor

GlenDC commented Apr 2, 2025

Currently, the domain matchers (e.g., used in route_upstream) support only child_match and exact_match. However, there’s no support for wildcard matching. For example, something like:

foo*.site.bar.com

would ideally match:

foo.site.bar.com  
foo1.site.bar.com  
foofoo.site.bar.com

The exact syntax or feature set isn’t particularly important to me—what matters more is having the capability to perform wildcard-based filtering, especially in cases where exact_match or child_match aren’t sufficient.

I understand that wildcard matching may be slower by nature, but I still believe it could be quite useful for certain edge cases.

@zh-jq-b
Copy link
Member

zh-jq-b commented Apr 3, 2025

Yes it would be useful. It can use a radix_trie::Trie<u8, ArcEscaper> to do the match check. Can you submit a PR?

@GlenDC
Copy link
Contributor Author

GlenDC commented Apr 3, 2025

At the moment, I’m unfortunately swamped. If you haven’t had a chance to get to it by the time I need it, I’ll definitely take care of it myself.

That said, could you elaborate a bit more on how exactly you envision this? Your proposal still leaves quite a bit of room for interpretation, and I’d like to make sure we’re aligned before moving forward.

@zh-jq-b
Copy link
Member

zh-jq-b commented Apr 3, 2025

The wildcard_match code would be much like the child_match code, the difference is:

child_match insert example.net as net.example. to a Trie<String, ArcEscaper>,
wildcard_match insert a*.example.net as net.example.a to a Trie<String, ArcEscaper>.

*.example.net seems to be a special case as it should match both example.net and a.example.net.

@zh-jq-b zh-jq-b added this to the g3proxy v1.12 milestone Apr 3, 2025
@zh-jq
Copy link
Collaborator

zh-jq commented Apr 13, 2025

I have added 'regex match' support in this PR #667. I think this can be used to do a wildcard match.

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

No branches or pull requests

3 participants