Skip to content

Commit

Permalink
fix: disable rate limiting when interval is less than 1
Browse files Browse the repository at this point in the history
  • Loading branch information
iczc committed Sep 16, 2021
1 parent 2b2beba commit 7c3e7fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/server/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func (l *Limiter) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Ha
http.Error(w, "invalid address", http.StatusBadRequest)
return
}
clintIP := getClientIPFromRequest(l.proxyCount, r)
if l.ttl <= 0 {
next.ServeHTTP(w, r)
return
}

clintIP := getClientIPFromRequest(l.proxyCount, r)
l.mutex.Lock()
if l.limitByKey(w, address) || l.limitByKey(w, clintIP) {
l.mutex.Unlock()
Expand Down

0 comments on commit 7c3e7fe

Please sign in to comment.