人机识别增加UA记录

This commit is contained in:
刘祥超
2023-11-16 08:44:07 +08:00
parent 30cd6373c5
commit eeacec1a4e
3 changed files with 14 additions and 6 deletions

View File

@@ -6,7 +6,10 @@ import (
"github.com/TeaOSLab/EdgeNode/internal/ttlcache"
"github.com/TeaOSLab/EdgeNode/internal/utils/cachehits"
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
"github.com/cespare/xxhash"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"strconv"
)
@@ -95,3 +98,8 @@ func MatchBytesCache(regex *re.Regexp, byteSlice []byte, cacheLife CacheLife) bo
cacheHits.IncreaseCached(regIdString)
return b
}
// ComposeIPType 组合IP类型
func ComposeIPType(setId int64, req requests.Request) string {
return "set:" + types.String(setId) + "@" + stringutil.Md5(req.WAFRaw().UserAgent())
}