-
Notifications
You must be signed in to change notification settings - Fork 0
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
Apply rate limiting to countries other than the target country #2
Conversation
3cbbbff
to
42effd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Another way to implement this would be to provide an API similar to hosts.allow/hosts.deny or iptables.
It can be realized with two []strings and a wildcard (*
).
Example
type CountryLimiter struct {
db *maxminddb.Reader
countries []string
skipCountries []string
BaseLimiter
}
Limit countries other than JP.
CountryLimiter{
db: db,
countries: ["*"],
skipCountries: ["JP"],
}
Pros of this proposal is that the meaning of the fields does not change.
It is also easy to understand if we want to change the settings.
Cons are that skipCountries is redundant.
This is because skipCountries is usually used only when expressing "other than ~".
country_limiter.go
Outdated
db *maxminddb.Reader | ||
countries []string | ||
db *maxminddb.Reader | ||
limitRateForOtherCountries bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea, how about specifying the type?
limitRateForOtherCountries bool | |
CondType CondType |
type CondType bool
var Target CondType = true
var Excect CondType = false
7bd9f85
to
0c9f99f
Compare
0c9f99f
to
4f7493a
Compare
Co-authored-by: Ken’ichiro Oyama <[email protected]>
Co-authored-by: Ken’ichiro Oyama <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GREAT! LGTM!!
指定した国以外にレートリミットを書けるケースを想定しています。サービスを提供する国以外からのアクセスに対して厳しいレートリミットをかけたいことがあります。
I am considering cases where rate limiting is applied to countries other than the specified one. Sometimes, we want to impose strict rate limits on access from countries where our service is not provided.