mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-07 18:50:27 +08:00
cc2增加忽略常见文件扩展名选项
This commit is contained in:
@@ -5,14 +5,28 @@ package checkpoints
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/ttlcache"
|
"github.com/TeaOSLab/EdgeNode/internal/ttlcache"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||||
|
"github.com/TeaOSLab/EdgeNode/internal/zero"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ccCache = ttlcache.NewCache()
|
var ccCache = ttlcache.NewCache()
|
||||||
|
|
||||||
|
var commonFileExtensionsMap = map[string]zero.Zero{
|
||||||
|
".ico": zero.New(),
|
||||||
|
".jpg": zero.New(),
|
||||||
|
".jpeg": zero.New(),
|
||||||
|
".gif": zero.New(),
|
||||||
|
".png": zero.New(),
|
||||||
|
".webp": zero.New(),
|
||||||
|
".woff2": zero.New(),
|
||||||
|
".js": zero.New(),
|
||||||
|
".css": zero.New(),
|
||||||
|
}
|
||||||
|
|
||||||
// CC2Checkpoint 新的CC
|
// CC2Checkpoint 新的CC
|
||||||
type CC2Checkpoint struct {
|
type CC2Checkpoint struct {
|
||||||
Checkpoint
|
Checkpoint
|
||||||
@@ -38,6 +52,20 @@ func (this *CC2Checkpoint) RequestValue(req requests.Request, param string, opti
|
|||||||
threshold = 1000
|
threshold = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ignoreCommonFiles = options.GetBool("ignoreCommonFiles")
|
||||||
|
if ignoreCommonFiles {
|
||||||
|
var rawReq = req.WAFRaw()
|
||||||
|
if len(rawReq.Referer()) > 0 {
|
||||||
|
var ext = filepath.Ext(rawReq.URL.Path)
|
||||||
|
if len(ext) > 0 {
|
||||||
|
_, ok := commonFileExtensionsMap[strings.ToLower(ext)]
|
||||||
|
if ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
value = ccCache.IncreaseInt64("WAF-CC-"+strings.Join(keyValues, "@"), 1, time.Now().Unix()+period, false)
|
value = ccCache.IncreaseInt64("WAF-CC-"+strings.Join(keyValues, "@"), 1, time.Now().Unix()+period, false)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user