Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #191 from safing/feature/improve-rate-limiting
Browse files Browse the repository at this point in the history
Improve rate limiting
  • Loading branch information
dhaavi authored Jan 18, 2024
2 parents c5915b7 + 04204ac commit 7283661
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions terminal/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
rateLimitMaxOpsPerSecond = 5

rateLimitMinSuspicion = 25
rateLimitMinPermaSuspicion = rateLimitMinSuspicion * 10
rateLimitMinPermaSuspicion = rateLimitMinSuspicion * 100
rateLimitMaxSuspicionPerSecond = 1

// Make this big enough to trigger suspicion limit in first blast.
Expand Down Expand Up @@ -105,9 +105,9 @@ func (s *Session) RateLimit() *Error {
}

// Permanently rate limit if suspicion goes over the perma min limit and
// the suspicion score is 50% or greater of the operation count.
// the suspicion score is greater than 80% of the operation count.
if score > rateLimitMinPermaSuspicion &&
score*2 > s.opCount.Load() {
score*5 > s.opCount.Load()*4 { // Think: 80*5 == 100*4
return ErrRateLimited
}
}
Expand Down

0 comments on commit 7283661

Please sign in to comment.