[build test]
This commit is contained in:
@ -44,7 +44,7 @@ func (dk *DomainKeyword) RuleExtra() *C.RuleExtra {
|
||||
return dk.ruleExtra
|
||||
}
|
||||
|
||||
func NewDomainKeyword(keyword string, adapter string) *DomainKeyword {
|
||||
func NewDomainKeyword(keyword string, adapter string, ruleExtra *C.RuleExtra) *DomainKeyword {
|
||||
return &DomainKeyword{
|
||||
keyword: strings.ToLower(keyword),
|
||||
adapter: adapter,
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/Dreamacro/clash/component/geodata"
|
||||
"github.com/Dreamacro/clash/component/geodata/router"
|
||||
"github.com/Dreamacro/clash/component/mmdb"
|
||||
"github.com/Dreamacro/clash/config"
|
||||
"strings"
|
||||
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
@ -18,6 +20,10 @@ type GEOIP struct {
|
||||
geoIPMatcher *router.GeoIPMatcher
|
||||
}
|
||||
|
||||
func (g *GEOIP) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *GEOIP) RuleType() C.RuleType {
|
||||
return C.GEOIP
|
||||
}
|
||||
@ -31,7 +37,10 @@ func (g *GEOIP) Match(metadata *C.Metadata) bool {
|
||||
if strings.EqualFold(g.country, "LAN") || C.TunBroadcastAddr.Equal(ip) {
|
||||
return ip.IsPrivate()
|
||||
}
|
||||
|
||||
if !config.GeodataMode {
|
||||
record, _ := mmdb.Instance().Country(ip)
|
||||
return strings.EqualFold(record.Country.IsoCode, g.country)
|
||||
}
|
||||
return g.geoIPMatcher.Match(ip)
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,10 @@ func (gs *GEOSITE) ShouldResolveIP() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (gs *GEOSITE) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (gs *GEOSITE) RuleExtra() *C.RuleExtra {
|
||||
return gs.ruleExtra
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ type NetworkType struct {
|
||||
adapter string
|
||||
}
|
||||
|
||||
func (n *NetworkType) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func NewNetworkType(network, adapter string) (*NetworkType, error) {
|
||||
ntType := new(NetworkType)
|
||||
ntType.adapter = adapter
|
||||
|
@ -21,6 +21,10 @@ type Port struct {
|
||||
ruleExtra *C.RuleExtra
|
||||
}
|
||||
|
||||
func (p *Port) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Port) RuleType() C.RuleType {
|
||||
if p.isSource {
|
||||
return C.SrcPort
|
||||
|
@ -16,9 +16,14 @@ var processCache = cache.NewLRUCache(cache.WithAge(2), cache.WithSize(64))
|
||||
type Process struct {
|
||||
adapter string
|
||||
process string
|
||||
nameOnly bool
|
||||
ruleExtra *C.RuleExtra
|
||||
}
|
||||
|
||||
func (ps *Process) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ps *Process) RuleType() C.RuleType {
|
||||
return C.Process
|
||||
}
|
||||
@ -70,10 +75,11 @@ func (ps *Process) RuleExtra() *C.RuleExtra {
|
||||
return ps.ruleExtra
|
||||
}
|
||||
|
||||
func NewProcess(process string, adapter string, ruleExtra *C.RuleExtra) (*Process, error) {
|
||||
func NewProcess(process string, adapter string, nameOnly bool, ruleExtra *C.RuleExtra) (*Process, error) {
|
||||
return &Process{
|
||||
adapter: adapter,
|
||||
process: process,
|
||||
nameOnly: nameOnly,
|
||||
ruleExtra: ruleExtra,
|
||||
}, nil
|
||||
}
|
||||
|
@ -9,6 +9,10 @@ type AND struct {
|
||||
needIP bool
|
||||
}
|
||||
|
||||
func (A *AND) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func NewAND(payload string, adapter string) (*AND, error) {
|
||||
and := &AND{payload: payload, adapter: adapter}
|
||||
rules, err := parseRuleByPayload(payload)
|
||||
|
@ -11,6 +11,10 @@ type NOT struct {
|
||||
adapter string
|
||||
}
|
||||
|
||||
func (not *NOT) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func NewNOT(payload string, adapter string) (*NOT, error) {
|
||||
not := &NOT{payload: payload, adapter: adapter}
|
||||
rule, err := parseRuleByPayload(payload)
|
||||
|
@ -9,6 +9,10 @@ type OR struct {
|
||||
needIP bool
|
||||
}
|
||||
|
||||
func (or *OR) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (or *OR) RuleType() C.RuleType {
|
||||
return C.OR
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ type RuleSet struct {
|
||||
ruleExtra *C.RuleExtra
|
||||
}
|
||||
|
||||
func (rs *RuleSet) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rs *RuleSet) RuleType() C.RuleType {
|
||||
return C.RuleSet
|
||||
}
|
||||
|
Reference in New Issue
Block a user