mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-16 07:46:36 +08:00
人机识别验证成功后记录到Cookie,以便于在重启、切换节点时仍能恢复验证状态
This commit is contained in:
@@ -4,8 +4,10 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||
wafutils "github.com/TeaOSLab/EdgeNode/internal/waf/utils"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -130,6 +132,22 @@ func (this *CaptchaAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, req
|
||||
}
|
||||
}
|
||||
|
||||
// 检查Cookie值
|
||||
var fullCookieName = captchaCookiePrefix + "_" + types.String(set.Id)
|
||||
cookie, err := req.WAFRaw().Cookie(fullCookieName)
|
||||
if err == nil && cookie != nil && len(cookie.Value) > 0 {
|
||||
var info = &AllowCookieInfo{}
|
||||
err = info.Decode(cookie.Value)
|
||||
if err == nil && set.Id == info.SetId && info.ExpiresAt > fasttime.Now().Unix() {
|
||||
// 重新记录到白名单
|
||||
SharedIPWhiteList.RecordIP(wafutils.ComposeIPType(set.Id, req), this.Scope, req.WAFServerId(), req.WAFRemoteIP(), info.ExpiresAt, waf.Id, false, group.Id, set.Id, "")
|
||||
|
||||
return PerformResult{
|
||||
ContinueRequest: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var refURL = req.WAFRaw().URL.String()
|
||||
|
||||
// 覆盖配置
|
||||
|
||||
Reference in New Issue
Block a user