mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-23 07:00:25 +08:00
实现WAF
This commit is contained in:
30
internal/waf/checkpoints/request_headers.go
Normal file
30
internal/waf/checkpoints/request_headers.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package checkpoints
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type RequestHeadersCheckpoint struct {
|
||||
Checkpoint
|
||||
}
|
||||
|
||||
func (this *RequestHeadersCheckpoint) RequestValue(req *requests.Request, param string, options map[string]interface{}) (value interface{}, sysErr error, userErr error) {
|
||||
var headers = []string{}
|
||||
for k, v := range req.Header {
|
||||
for _, subV := range v {
|
||||
headers = append(headers, k+": "+subV)
|
||||
}
|
||||
}
|
||||
sort.Strings(headers)
|
||||
value = strings.Join(headers, "\n")
|
||||
return
|
||||
}
|
||||
|
||||
func (this *RequestHeadersCheckpoint) ResponseValue(req *requests.Request, resp *requests.Response, param string, options map[string]interface{}) (value interface{}, sysErr error, userErr error) {
|
||||
if this.IsRequest() {
|
||||
return this.RequestValue(req, param, options)
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user