diff --git a/lib/midware/arrow_ip_addr.go b/lib/midware/arrow_ip_addr.go index 042beb1b..2a516c7c 100644 --- a/lib/midware/arrow_ip_addr.go +++ b/lib/midware/arrow_ip_addr.go @@ -29,17 +29,29 @@ func ArrowIPAddr(next http.Handler) http.Handler { next.ServeHTTP(w, r) return } + + // 开关 + switchStr := data["switch"].(string) + if switchStr == "0" { + next.ServeHTTP(w, r) + return + } + ipRange := data["ipRange"].(string) logintimeRange := data["logintime_range"].(string) // 检查ip ips := strings.Split(ipRange, "/") + hasIP := false for _, ip := range ips { - if ipAddr != ip { - services.ResponseErrorWithJson(w, 502, "网关登录策略-IP限制: "+ipAddr) - return + if ipAddr == ip { + hasIP = true } } + if !hasIP { + services.ResponseErrorWithJson(w, 502, "网关登录策略-IP限制: "+ipAddr) + return + } // 检查开放时间 logintimeRangeArr := strings.Split(logintimeRange, " - ")