加开关中间件网关登录策略-IP限制
This commit is contained in:
@@ -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, " - ")
|
||||
|
||||
Reference in New Issue
Block a user