github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/checkpoints/request_is_cname.go (about) 1 package checkpoints 2 3 import ( 4 "github.com/TeaOSLab/EdgeNode/internal/waf/requests" 5 "github.com/TeaOSLab/EdgeNode/internal/waf/utils" 6 "github.com/iwind/TeaGo/maps" 7 ) 8 9 type RequestIsCNAMECheckpoint struct { 10 Checkpoint 11 } 12 13 func (this *RequestIsCNAMECheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) { 14 if req.Format("${cname}") == req.Format("${host}") { 15 value = 1 16 } else { 17 value = 0 18 } 19 return 20 } 21 22 func (this *RequestIsCNAMECheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) { 23 if this.IsRequest() { 24 return this.RequestValue(req, param, options, ruleId) 25 } 26 return 27 } 28 29 func (this *RequestIsCNAMECheckpoint) CacheLife() utils.CacheLife { 30 return utils.CacheLongLife 31 }