mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-05 17:40:26 +08:00
41 lines
951 B
Go
41 lines
951 B
Go
|
|
package checkpoints
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||
|
|
"github.com/iwind/TeaGo/maps"
|
||
|
|
"github.com/iwind/TeaGo/types"
|
||
|
|
)
|
||
|
|
|
||
|
|
type RequestGeneralHeaderLengthCheckpoint struct {
|
||
|
|
Checkpoint
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) IsComposed() bool {
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) RequestValue(req *requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
|
||
|
|
value = false
|
||
|
|
|
||
|
|
headers := options.GetSlice("headers")
|
||
|
|
if len(headers) == 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
length := options.GetInt("length")
|
||
|
|
|
||
|
|
for _, header := range headers {
|
||
|
|
v := req.Header.Get(types.String(header))
|
||
|
|
if len(v) > length {
|
||
|
|
value = true
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) ResponseValue(req *requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) {
|
||
|
|
return
|
||
|
|
}
|