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

Add lefthand-side wildcard support to descriptor values #458

Closed

Conversation

lukipro
Copy link

@lukipro lukipro commented Nov 15, 2023

Current wildcard implementation doesn't allow to have a following configuration:

domain: example-domain
descriptors:
  - key: HOST
    value: "*.example.com"
    rate_limit:
      unit: minute
      requests_per_unit: 20

This is useful if one needs to rate limit based on dynamic subdomains, like:
foo.example.com, bar.example.com, <unknown_yet>.example.com

@lukipro lukipro force-pushed the feature/support-leftmost-wildcards branch from 57551b1 to 366e127 Compare November 15, 2023 21:16
Signed-off-by: Luki Boras <[email protected]>
Signed-off-by: Luki Boras <[email protected]>
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Dec 16, 2023
@lukipro
Copy link
Author

lukipro commented Dec 19, 2023

Hello, any chance to get this merged?

@github-actions github-actions bot removed the stale label Dec 19, 2023
Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jan 18, 2024
Comment on lines +317 to +323
for _, wildcardValue := range prevDescriptor.wildcardValues {
wildcardKey := entry.Key + "_" + wildcardValue
if strings.HasSuffix(entry.Value, strings.TrimPrefix(wildcardValue, "*")) {
nextDescriptor = descriptorsMap[wildcardKey]
break
}
if strings.HasPrefix(entry.Value, strings.TrimSuffix(wildcardValue, "*")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any performance implications here due to the string comparison?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check that for two reasons:

  • I don't know how to perform a meaningful benchmark with regards to this piece of code
  • Current code is already doing a string comparison in the same way

Copy link

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot closed this Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants