UA名单支持批量添加关键词

This commit is contained in:
GoEdgeLab
2024-04-17 15:26:33 +08:00
parent 3071aa0ab6
commit 3cce95da45

View File

@@ -13,7 +13,7 @@ func (this *HTTPRequest) doCheckUserAgent() (shouldStop bool) {
const cacheSeconds = "3600" // 时间不能过长,防止修改设置后长期无法生效 const cacheSeconds = "3600" // 时间不能过长,防止修改设置后长期无法生效
if !this.web.UserAgent.AllowRequest(this.RawReq) { if this.web.UserAgent.MatchURL(this.URL()) && !this.web.UserAgent.AllowRequest(this.RawReq) {
this.tags = append(this.tags, "userAgentCheck") this.tags = append(this.tags, "userAgentCheck")
this.writer.Header().Set("Cache-Control", "max-age="+cacheSeconds) this.writer.Header().Set("Cache-Control", "max-age="+cacheSeconds)
this.writeCode(http.StatusForbidden, "The User-Agent has been blocked.", "当前访问已被UA名单拦截。") this.writeCode(http.StatusForbidden, "The User-Agent has been blocked.", "当前访问已被UA名单拦截。")