防盗链增加”同时检查Origin选项“

This commit is contained in:
GoEdgeLab
2023-05-02 17:06:24 +08:00
parent 3acc45ba87
commit 1373a20675
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -15,6 +15,13 @@ func (this *HTTPRequest) doCheckReferers() (shouldStop bool) {
const cacheSeconds = "3600" // 时间不能过长,防止修改设置后长期无法生效
var refererURL = this.RawReq.Header.Get("Referer")
if len(refererURL) == 0 && this.web.Referers.CheckOrigin {
var origin = this.RawReq.Header.Get("Origin")
if len(origin) > 0 && origin != "null" {
refererURL = "https://" + origin // 因为Origin都只有域名部分,所以为了下面的URL 分析需要加上https://
}
}
if len(refererURL) == 0 {
if this.web.Referers.MatchDomain(this.ReqHost, "") {
return