Skip to content

Commit

Permalink
Merge pull request #35 from minghinmatthewlam/main
Browse files Browse the repository at this point in the history
Fix typo
  • Loading branch information
iczc authored Oct 12, 2024
2 parents f9bd154 + b8bd532 commit cc5d9ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@ func (l *Limiter) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Ha
return
}

clintIP := getClientIPFromRequest(l.proxyCount, r)
clientIP := getClientIPFromRequest(l.proxyCount, r)
l.mutex.Lock()
if l.limitByKey(w, address) || l.limitByKey(w, clintIP) {
if l.limitByKey(w, address) || l.limitByKey(w, clientIP) {
l.mutex.Unlock()
return
}
l.cache.SetWithTTL(address, true, l.ttl)
l.cache.SetWithTTL(clintIP, true, l.ttl)
l.cache.SetWithTTL(clientIP, true, l.ttl)
l.mutex.Unlock()

next.ServeHTTP(w, r)
if w.(negroni.ResponseWriter).Status() != http.StatusOK {
l.cache.Remove(address)
l.cache.Remove(clintIP)
l.cache.Remove(clientIP)
return
}
log.WithFields(log.Fields{
"address": address,
"clientIP": clintIP,
"clientIP": clientIP,
}).Info("Maximum request limit has been reached")
}

Expand Down

0 comments on commit cc5d9ce

Please sign in to comment.