mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
adjust limits on heartbeat uploads (#522)
This commit is contained in:
parent
43c302ed6a
commit
41ba00ace8
1 changed files with 7 additions and 3 deletions
|
|
@ -51,12 +51,16 @@ class Rack::Attack
|
|||
req.ip if req.path.in?([ "/login", "/signup", "/auth", "/sessions" ]) && req.post?
|
||||
end
|
||||
|
||||
Rack::Attack.throttle("api requests", limit: 600, period: 1.hour) do |req|
|
||||
Rack::Attack.throttle("api requests", limit: 10000, period: 1.hour) do |req|
|
||||
req.ip if req.path.start_with?("/api/")
|
||||
end
|
||||
|
||||
Rack::Attack.throttle("heartbeat api", limit: 10000, period: 1.hour) do |req|
|
||||
req.ip if req.path.start_with?("/api/hackatime/v1/users/current/heartbeats")
|
||||
# if ur stuff is going faster than this then we got a problem dude
|
||||
Rack::Attack.throttle("heartbeat uploads", limit: 360, period: 1.minute) do |req|
|
||||
req.ip if req.post? && (
|
||||
req.path =~ %r{^/api/hackatime/v1/users/\d+/heartbeats$} ||
|
||||
req.path == "/api/hackatime/v1/users/current/heartbeats"
|
||||
)
|
||||
end
|
||||
|
||||
# lets actually log things? thanks
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue