onur-ozkan / nestjs-rate-limiter

Highly configurable and extensible rate limiter library
https://npmjs.com/package/nestjs-rate-limiter
MIT License
238 stars 43 forks source link

Does this library limit per-ip? #70

Closed gaggle closed 3 years ago

gaggle commented 3 years ago

Maybe this sounds odd, but I can't figure out if this library limits per-IP, per rate limiting instance, or if it's global (that is, if I have multiple rate-limited endpoints and they all use the same keyPrefix, is the rate-limit applied per unique IP, per endpoint (because each endpoint has its own Ratelimit instance), or globally for that process?)

I can't figure out what the intent is for this code: https://github.com/ozkanonur/nestjs-rate-limiter/blame/master/lib/rate-limiter.interceptor.ts#L169. The line looks like it intends to be per-IP, but is the regex-replace not removing everything except for anything that comes after the last : character? So 0.0.0.0:5000 would turn to 5000? Or what am I misunderstanding?

onur-ozkan commented 3 years ago

Maybe this sounds odd, but I can't figure out if this library limits per-IP, per rate limiting instance, or if it's global (that is, if I have multiple rate-limited endpoints and they all use the same keyPrefix, is the rate-limit applied per unique IP, per endpoint (because each endpoint has its own Ratelimit instance), or globally for that process?)

I can't figure out what the intent is for this code: https://github.com/ozkanonur/nestjs-rate-limiter/blame/master/lib/rate-limiter.interceptor.ts#L169. The line looks like it intends to be per-IP, but is the regex-replace not removing everything except for anything that comes after the last : character? So 0.0.0.0:5000 would turn to 5000? Or what am I misunderstanding?

1: You can either set rate limiter globally to client or give different rate limiters for each endpoint to the client by giving different values to keyPrefix.

2: That was insanely wrong, thank you for letting me know.