github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/checkpoints/request_referer_origin.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 RequestRefererOriginCheckpoint struct { 10 Checkpoint 11 } 12 13 func (this *RequestRefererOriginCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) { 14 var s []string 15 16 var referer = req.WAFRaw().Referer() 17 if len(referer) > 0 { 18 s = append(s, referer) 19 } 20 21 var origin = req.WAFRaw().Header.Get("Origin") 22 if len(origin) > 0 { 23 s = append(s, origin) 24 } 25 26 if len(s) > 0 { 27 value = s 28 } else { 29 value = "" 30 } 31 32 return 33 } 34 35 func (this *RequestRefererOriginCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) { 36 if this.IsRequest() { 37 return this.RequestValue(req, param, options, ruleId) 38 } 39 return 40 } 41 42 func (this *RequestRefererOriginCheckpoint) CacheLife() utils.CacheLife { 43 return utils.CacheMiddleLife 44 }