Merge remote branch

This commit is contained in:
yaling888
2021-10-21 22:37:30 +08:00
97 changed files with 1147 additions and 577 deletions

View File

@ -235,8 +235,6 @@ func (ac *ACAutomaton) Match(s string) bool {
if fullMatch {
return true
}
//default:
// //break // ineffective break statement, code "break" can not pass staticcheck check. don't sure that mean, so just block it.
}
}
return fullMatch && ac.exists[node].exist

View File

@ -49,7 +49,6 @@ func (gs *GEOSITE) RuleExtra() *C.RuleExtra {
func NewGEOSITE(country string, adapter string, ruleExtra *C.RuleExtra) (*GEOSITE, error) {
geoLoaderName := "standard"
//geoLoaderName := "memconservative"
geoLoader, err := geodata.GetGeoDataLoader(geoLoaderName)
if err != nil {
return nil, fmt.Errorf("load GeoSite data error, %s", err.Error())
@ -60,10 +59,11 @@ func NewGEOSITE(country string, adapter string, ruleExtra *C.RuleExtra) (*GEOSIT
return nil, fmt.Errorf("load GeoSite data error, %s", err.Error())
}
//linear: linear algorithm
//matcher, err := router.NewDomainMatcher(domains)
//mphminimal perfect hash algorithm
/**
linear: linear algorithm
matcher, err := router.NewDomainMatcher(domains)
mphminimal perfect hash algorithm
*/
matcher, err := router.NewMphMatcherGroup(domains)
if err != nil {
return nil, fmt.Errorf("load GeoSite data error, %s", err.Error())

View File

@ -68,7 +68,6 @@ func (p *Port) matchPortReal(portRef string) bool {
}
func NewPort(port string, adapter string, isSource bool, ruleExtra *C.RuleExtra) (*Port, error) {
//the port format should be like this: "123/136/137-139" or "[123]/[136-139]"
ports := strings.Split(port, "/")
if len(ports) > 28 {
return nil, fmt.Errorf("%s, too many ports to use, maximum support 28 ports", errPayload.Error())
@ -93,7 +92,6 @@ func NewPort(port string, adapter string, isSource bool, ruleExtra *C.RuleExtra)
if subPortsLen == 1 {
portList = append(portList, portReal{portStart, -1})
} else if subPortsLen == 2 {
portEnd, err1 := strconv.Atoi(strings.Trim(subPorts[1], "[ ]"))
if err1 != nil || portEnd < 0 || portEnd > 65535 {

View File

@ -24,9 +24,7 @@ func (ps *Process) RuleType() C.RuleType {
}
func (ps *Process) Match(metadata *C.Metadata) bool {
if metadata.Process != "" {
//log.Debugln("Use cache process: %s", metadata.Process)
return strings.EqualFold(metadata.Process, ps.process)
}

View File

@ -2,11 +2,12 @@ package rules
import (
"fmt"
"runtime"
"strings"
S "github.com/Dreamacro/clash/component/script"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log"
"runtime"
"strings"
)
type Script struct {