]> 127.0.0.1 Git - part/.git/commitdiff
add v0.27.11
authorqydysky <qydysky@foxmail.com>
Tue, 23 May 2023 13:45:04 +0000 (21:45 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 23 May 2023 13:45:04 +0000 (21:45 +0800)
web/Web.go

index 0d99c9c70d4ddcee54e459aff598054dd9af3238..f6d9b974f0d592c3d7a94de7f69ba1e648613276 100644 (file)
@@ -172,6 +172,9 @@ func (t *CountLimits) SetMaxCount(cidr string, max int) {
 }
 
 func (t *CountLimits) IsOverflow(r *http.Request) (isOverflow bool) {
+       if len(t.g) == 0 {
+               return
+       }
        ip := net.ParseIP(strings.Split(r.RemoteAddr, ":")[0])
        t.l.RLock()
        defer t.l.RUnlock()
@@ -188,6 +191,9 @@ func (t *CountLimits) IsOverflow(r *http.Request) (isOverflow bool) {
 }
 
 func (t *CountLimits) AddOverflow(r *http.Request) (isOverflow bool) {
+       if len(t.g) == 0 {
+               return
+       }
        ip := net.ParseIP(strings.Split(r.RemoteAddr, ":")[0])
        t.l.Lock()
        defer t.l.Unlock()