mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-12 14:30:54 +08:00
防盗链增加”同时检查Origin选项“
This commit is contained in:
@@ -18,7 +18,14 @@ type RequestRefererBlockCheckpoint struct {
|
||||
// RequestValue 计算checkpoint值
|
||||
// 选项:allowEmpty, allowSameDomain, allowDomains
|
||||
func (this *RequestRefererBlockCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value interface{}, hasRequestBody bool, sysErr error, userErr error) {
|
||||
var checkOrigin = options.GetBool("checkOrigin")
|
||||
var referer = req.WAFRaw().Referer()
|
||||
if len(referer) == 0 && checkOrigin {
|
||||
var origin = req.WAFRaw().Header.Get("Origin")
|
||||
if len(origin) > 0 && origin != "null" {
|
||||
referer = "https://" + origin // 因为Origin都只有域名部分,所以为了下面的URL 分析需要加上https://
|
||||
}
|
||||
}
|
||||
|
||||
if len(referer) == 0 {
|
||||
if options.GetBool("allowEmpty") {
|
||||
|
||||
Reference in New Issue
Block a user