爬虫规则中将php改为php\b,避免屏蔽某些安卓WebView

This commit is contained in:
GoEdgeLab
2023-08-30 10:13:16 +08:00
parent 3689417e38
commit 87a5aee982
2 changed files with 20 additions and 1 deletions

View File

@@ -457,7 +457,7 @@ func HTTPFirewallTemplate() *HTTPFirewallPolicy {
IsOn: true,
Param: "${userAgent}",
Operator: HTTPFirewallRuleOperatorMatch,
Value: `python|pycurl|http-client|httpclient|apachebench|nethttp|http_request|java|perl|ruby|scrapy|php|rust`,
Value: `python|pycurl|http-client|httpclient|apachebench|nethttp|http_request|java|perl|ruby|scrapy|php\b|rust`,
IsCaseInsensitive: true,
})
set.AddRule(&HTTPFirewallRule{

View File

@@ -0,0 +1,19 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package firewallconfigs_test
import (
"github.com/iwind/TeaGo/assert"
"regexp"
"testing"
)
func TestUserAgentMatch_PHP(t *testing.T) {
var a = assert.NewAssertion(t)
var expr = `python|pycurl|http-client|httpclient|apachebench|nethttp|http_request|java|perl|ruby|scrapy|php\b|rust`
var reg = regexp.MustCompile(expr)
a.IsTrue(reg.MatchString("php"))
a.IsTrue(reg.MatchString("php/5.0"))
a.IsFalse(reg.MatchString("php110"))
}