Skip to content

Commit

Permalink
Fix ip limit
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jun 14, 2024
1 parent 8b17fdb commit fdc69bd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,12 @@ func (c *CRProxy) checkLimit(rw http.ResponseWriter, r *http.Request, info *Path
c.logger.Println("exceed limit", address, aver, *c.ipsSpeedLimit)
}
if c.limitDelay {
select {
case <-r.Context().Done():
return false
case <-time.After(bps.Next().Sub(time.Now())):
for bps.Aver() > *c.ipsSpeedLimit {
select {
case <-r.Context().Done():
return false
case <-time.After(bps.Next().Sub(time.Now())):
}
}
} else {
err := ErrorCodeTooManyRequests
Expand Down

0 comments on commit fdc69bd

Please sign in to comment.