fix middleware
This commit is contained in:
parent
5ae2e3fae1
commit
29b0eaa6b3
@ -26,9 +26,12 @@ func ValidateBlackIPMiddleware(code interface{}, httpCode int, validateFunc defi
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
if validateFunc(ctx, networkUtil.IP.GetRemoteIP(ctx.Request)) {
|
||||
remoteIp := networkUtil.IP.GetRemoteIP(ctx.Request)
|
||||
if validateFunc(ctx, remoteIp) {
|
||||
// 命中黑名单
|
||||
response.Send(ctx, code, httpCode, nil)
|
||||
response.Send(ctx, code, httpCode, map[string]any{
|
||||
"remote_ip": remoteIp,
|
||||
}, nil)
|
||||
ctx.Abort()
|
||||
return
|
||||
}
|
||||
@ -48,9 +51,12 @@ func ValidateWhiteIPMiddleware(code interface{}, httpCode int, validateFunc defi
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
if !validateFunc(ctx, networkUtil.IP.GetRemoteIP(ctx.Request)) {
|
||||
remoteIp := networkUtil.IP.GetRemoteIP(ctx.Request)
|
||||
if !validateFunc(ctx, remoteIp) {
|
||||
// 非名单
|
||||
response.Send(ctx, code, httpCode, nil)
|
||||
response.Send(ctx, code, httpCode, map[string]any{
|
||||
"remote_ip": remoteIp,
|
||||
}, nil)
|
||||
ctx.Abort()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user