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

rate limiting by IP address prefix #36

Closed
ammmir opened this issue Jun 7, 2018 · 5 comments
Closed

rate limiting by IP address prefix #36

ammmir opened this issue Jun 7, 2018 · 5 comments

Comments

@ammmir
Copy link

ammmir commented Jun 7, 2018

For IPv6, it doesn't make sense to rate limit individual /128 addresses since end hosts often get a huge prefix assigned to them, making it easy to bypass rate limits. Instead, how about adding a normalization prefix (default /32 for IPv4 and /128 IPv6 to keep existing functionality)?

It can be trivially accomplished by masking the desired number of bits for the prefix and using that as the IP key, for example:

IPv4: 192.0.2.123 with a /24 prefix: becomes192.0.2.0
IPv6: 2001:db8:cafe:1234:beef::fafa with /48 prefix becomes 2001:db8:cafe::

@novln
Copy link
Contributor

novln commented Jun 7, 2018

Hello,

Thank you for this suggestion 😃

Any thought @nleof @thoas & @toxinu ?

@anacrolix
Copy link

You could apply net.IP.Mask before passing the resulting net.IP.String() to Limiter.Get.

@novln
Copy link
Contributor

novln commented Jun 20, 2018

We are not against this evolution but currently I don't have the bandwidth to implement this...
So don't hesitate to submit a pull request, I'll be glad to help you anyway I can.

Cheers,

@novln
Copy link
Contributor

novln commented Aug 3, 2018

@ammmir & @anacrolix:
Does 3b3ac78 resolves your issue ? Or not quite ?

@anacrolix
Copy link

Looks about right.

@novln novln mentioned this issue Nov 8, 2018
@novln novln closed this as completed in #39 Jan 9, 2019
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