mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-05-06 13:48:52 +00:00
improve: not block ip when ip changed
This commit is contained in:
@@ -75,6 +75,7 @@ func identityHandler() func(c *gin.Context) any {
|
|||||||
|
|
||||||
if tokenIP != currentIP {
|
if tokenIP != currentIP {
|
||||||
// IP地址不匹配,token无效
|
// IP地址不匹配,token无效
|
||||||
|
c.Set(model.CtxKeyIsIPMismatch, true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +204,9 @@ func fallbackAuthMiddleware(mw *jwt.GinJWTMiddleware) func(c *gin.Context) {
|
|||||||
model.UnblockIP(singleton.DB, realIP, model.BlockIDToken)
|
model.UnblockIP(singleton.DB, realIP, model.BlockIDToken)
|
||||||
c.Set(mw.IdentityKey, identity)
|
c.Set(mw.IdentityKey, identity)
|
||||||
} else {
|
} else {
|
||||||
if err := model.BlockIP(singleton.DB, realIP, model.WAFBlockReasonTypeBruteForceToken, model.BlockIDToken); err != nil {
|
isIpMismatch := c.GetBool(model.CtxKeyIsIPMismatch)
|
||||||
waf.ShowBlockPage(c, err)
|
if !isIpMismatch {
|
||||||
|
waf.ShowBlockPage(c, model.BlockIP(singleton.DB, realIP, model.WAFBlockReasonTypeBruteForceToken, model.BlockIDToken))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
CtxKeyAuthorizedUser = "ckau"
|
CtxKeyAuthorizedUser = "ckau"
|
||||||
CtxKeyRealIPStr = "ckri"
|
CtxKeyRealIPStr = "ckri"
|
||||||
|
CtxKeyIsIPMismatch = "ckipm"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user