mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
35 lines
989 B
Go
35 lines
989 B
Go
package checkpoints
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf/utils"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type RequestRawRemoteAddrCheckpoint struct {
|
|
Checkpoint
|
|
}
|
|
|
|
func (this *RequestRawRemoteAddrCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
|
|
host, _, err := net.SplitHostPort(req.WAFRaw().RemoteAddr)
|
|
if err == nil {
|
|
value = host
|
|
} else {
|
|
value = req.WAFRaw().RemoteAddr
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *RequestRawRemoteAddrCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
|
|
if this.IsRequest() {
|
|
return this.RequestValue(req, param, options, ruleId)
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *RequestRawRemoteAddrCheckpoint) CacheLife() utils.CacheLife {
|
|
return utils.CacheShortLife
|
|
}
|