Fix: Remove EnableProcess from config.go and enable-process from config.yaml.
Fix: FindProcess is now enabled by default when the rule set contains process-name rules.
This commit is contained in:
parent
5bbf73e3b5
commit
8a7027e8d6
@ -53,7 +53,6 @@ type General struct {
|
|||||||
GeodataMode bool `json:"geodata-mode"`
|
GeodataMode bool `json:"geodata-mode"`
|
||||||
GeodataLoader string `json:"geodata-loader"`
|
GeodataLoader string `json:"geodata-loader"`
|
||||||
TCPConcurrent bool `json:"tcp-concurrent"`
|
TCPConcurrent bool `json:"tcp-concurrent"`
|
||||||
EnableProcess bool `json:"enable-process"`
|
|
||||||
FindProcessMode P.FindProcessMode `json:"find-process-mode"`
|
FindProcessMode P.FindProcessMode `json:"find-process-mode"`
|
||||||
Sniffing bool `json:"sniffing"`
|
Sniffing bool `json:"sniffing"`
|
||||||
EBpf EBpf `json:"-"`
|
EBpf EBpf `json:"-"`
|
||||||
@ -259,7 +258,6 @@ type RawConfig struct {
|
|||||||
GeodataMode bool `yaml:"geodata-mode"`
|
GeodataMode bool `yaml:"geodata-mode"`
|
||||||
GeodataLoader string `yaml:"geodata-loader"`
|
GeodataLoader string `yaml:"geodata-loader"`
|
||||||
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`
|
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`
|
||||||
EnableProcess bool `yaml:"enable-process" json:"enable-process"`
|
|
||||||
FindProcessMode P.FindProcessMode `yaml:"find-process-mode" json:"find-process-mode"`
|
FindProcessMode P.FindProcessMode `yaml:"find-process-mode" json:"find-process-mode"`
|
||||||
|
|
||||||
Sniffer RawSniffer `yaml:"sniffer"`
|
Sniffer RawSniffer `yaml:"sniffer"`
|
||||||
@ -337,7 +335,6 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
|||||||
Proxy: []map[string]any{},
|
Proxy: []map[string]any{},
|
||||||
ProxyGroup: []map[string]any{},
|
ProxyGroup: []map[string]any{},
|
||||||
TCPConcurrent: false,
|
TCPConcurrent: false,
|
||||||
EnableProcess: false,
|
|
||||||
FindProcessMode: P.FindProcessStrict,
|
FindProcessMode: P.FindProcessStrict,
|
||||||
Tun: RawTun{
|
Tun: RawTun{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
@ -555,7 +552,6 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
|||||||
GeodataMode: cfg.GeodataMode,
|
GeodataMode: cfg.GeodataMode,
|
||||||
GeodataLoader: cfg.GeodataLoader,
|
GeodataLoader: cfg.GeodataLoader,
|
||||||
TCPConcurrent: cfg.TCPConcurrent,
|
TCPConcurrent: cfg.TCPConcurrent,
|
||||||
EnableProcess: cfg.EnableProcess,
|
|
||||||
FindProcessMode: cfg.FindProcessMode,
|
FindProcessMode: cfg.FindProcessMode,
|
||||||
EBpf: cfg.EBpf,
|
EBpf: cfg.EBpf,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -102,5 +102,6 @@ type RuleProvider interface {
|
|||||||
Behavior() RuleType
|
Behavior() RuleType
|
||||||
Match(*constant.Metadata) bool
|
Match(*constant.Metadata) bool
|
||||||
ShouldResolveIP() bool
|
ShouldResolveIP() bool
|
||||||
|
ShouldFindProcess() bool
|
||||||
AsRule(adaptor string) constant.Rule
|
AsRule(adaptor string) constant.Rule
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,13 @@ mixed-port: 10801 # HTTP(S) 和 SOCKS 代理混合端口
|
|||||||
allow-lan: true # 允许局域网连接
|
allow-lan: true # 允许局域网连接
|
||||||
bind-address: "*" # 绑定IP地址,仅作用于 allow-lan 为 true,'*'表示所有地址
|
bind-address: "*" # 绑定IP地址,仅作用于 allow-lan 为 true,'*'表示所有地址
|
||||||
|
|
||||||
|
|
||||||
|
# find-process-mode has 3 values: always, strict, off
|
||||||
|
# - always, 开启,强制匹配所有进程
|
||||||
|
# - strict, 默认,由clash判断是否开启
|
||||||
|
# - off, 不匹配进程,推荐在路由器上使用此模式
|
||||||
|
find-process-mode: strict
|
||||||
|
|
||||||
mode: rule
|
mode: rule
|
||||||
|
|
||||||
log-level: debug # 日志等级 silent/error/warning/info/debug
|
log-level: debug # 日志等级 silent/error/warning/info/debug
|
||||||
|
@ -308,7 +308,7 @@ func updateTunnels(tunnels []LC.Tunnel) {
|
|||||||
|
|
||||||
func updateGeneral(general *config.General, force bool) {
|
func updateGeneral(general *config.General, force bool) {
|
||||||
tunnel.SetMode(general.Mode)
|
tunnel.SetMode(general.Mode)
|
||||||
tunnel.SetFindProcessMode(general.EnableProcess, general.FindProcessMode)
|
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||||
dialer.DisableIPv6 = !general.IPv6
|
dialer.DisableIPv6 = !general.IPv6
|
||||||
if !dialer.DisableIPv6 {
|
if !dialer.DisableIPv6 {
|
||||||
log.Infoln("Use IPv6")
|
log.Infoln("Use IPv6")
|
||||||
|
@ -42,6 +42,11 @@ func (c *classicalStrategy) OnUpdate(rules []string) {
|
|||||||
shouldResolveIP := false
|
shouldResolveIP := false
|
||||||
for _, rawRule := range rules {
|
for _, rawRule := range rules {
|
||||||
ruleType, rule, params := ruleParse(rawRule)
|
ruleType, rule, params := ruleParse(rawRule)
|
||||||
|
|
||||||
|
if ruleType == "PROCESS-NAME" {
|
||||||
|
c.shouldFindProcess = true
|
||||||
|
}
|
||||||
|
|
||||||
r, err := c.parse(ruleType, rule, "", params)
|
r, err := c.parse(ruleType, rule, "", params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnln("parse rule error:[%s]", err.Error())
|
log.Warnln("parse rule error:[%s]", err.Error())
|
||||||
|
@ -12,6 +12,10 @@ type domainStrategy struct {
|
|||||||
domainRules *trie.DomainTrie[struct{}]
|
domainRules *trie.DomainTrie[struct{}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *domainStrategy) ShouldFindProcess() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (d *domainStrategy) Match(metadata *C.Metadata) bool {
|
func (d *domainStrategy) Match(metadata *C.Metadata) bool {
|
||||||
return d.domainRules != nil && d.domainRules.Search(metadata.Host) != nil
|
return d.domainRules != nil && d.domainRules.Search(metadata.Host) != nil
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ type ipcidrStrategy struct {
|
|||||||
trie *trie.IpCidrTrie
|
trie *trie.IpCidrTrie
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *ipcidrStrategy) ShouldFindProcess() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (i *ipcidrStrategy) Match(metadata *C.Metadata) bool {
|
func (i *ipcidrStrategy) Match(metadata *C.Metadata) bool {
|
||||||
return i.trie != nil && i.trie.IsContain(metadata.DstIP.AsSlice())
|
return i.trie != nil && i.trie.IsContain(metadata.DstIP.AsSlice())
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ type ruleStrategy interface {
|
|||||||
Match(metadata *C.Metadata) bool
|
Match(metadata *C.Metadata) bool
|
||||||
Count() int
|
Count() int
|
||||||
ShouldResolveIP() bool
|
ShouldResolveIP() bool
|
||||||
|
ShouldFindProcess() bool
|
||||||
OnUpdate(rules []string)
|
OnUpdate(rules []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +87,10 @@ func (rp *ruleSetProvider) ShouldResolveIP() bool {
|
|||||||
return rp.strategy.ShouldResolveIP()
|
return rp.strategy.ShouldResolveIP()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rp *ruleSetProvider) ShouldFindProcess() bool {
|
||||||
|
return rp.strategy.ShouldFindProcess()
|
||||||
|
}
|
||||||
|
|
||||||
func (rp *ruleSetProvider) AsRule(adaptor string) C.Rule {
|
func (rp *ruleSetProvider) AsRule(adaptor string) C.Rule {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,11 @@ type RuleSet struct {
|
|||||||
adapter string
|
adapter string
|
||||||
ruleProvider P.RuleProvider
|
ruleProvider P.RuleProvider
|
||||||
noResolveIP bool
|
noResolveIP bool
|
||||||
|
shouldFindProcess bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RuleSet) ShouldFindProcess() bool {
|
func (rs *RuleSet) ShouldFindProcess() bool {
|
||||||
return false
|
return !rs.shouldFindProcess && rs.getProviders().ShouldFindProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RuleSet) RuleType() C.RuleType {
|
func (rs *RuleSet) RuleType() C.RuleType {
|
||||||
|
@ -148,13 +148,9 @@ func SetMode(m TunnelMode) {
|
|||||||
|
|
||||||
// SetFindProcessMode replace SetAlwaysFindProcess
|
// SetFindProcessMode replace SetAlwaysFindProcess
|
||||||
// always find process info if legacyAlways = true or mode.Always() = true, may be increase many memory
|
// always find process info if legacyAlways = true or mode.Always() = true, may be increase many memory
|
||||||
func SetFindProcessMode(legacyAlways bool, mode P.FindProcessMode) {
|
func SetFindProcessMode(mode P.FindProcessMode) {
|
||||||
if legacyAlways {
|
|
||||||
findProcessMode = P.FindProcessAlways
|
|
||||||
} else {
|
|
||||||
findProcessMode = mode
|
findProcessMode = mode
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// processUDP starts a loop to handle udp packet
|
// processUDP starts a loop to handle udp packet
|
||||||
func processUDP() {
|
func processUDP() {
|
||||||
|
Reference in New Issue
Block a user