mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 23:57:26 +08:00
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"`
|
||||
GeodataLoader string `json:"geodata-loader"`
|
||||
TCPConcurrent bool `json:"tcp-concurrent"`
|
||||
EnableProcess bool `json:"enable-process"`
|
||||
FindProcessMode P.FindProcessMode `json:"find-process-mode"`
|
||||
Sniffing bool `json:"sniffing"`
|
||||
EBpf EBpf `json:"-"`
|
||||
@ -117,7 +116,7 @@ type Profile struct {
|
||||
}
|
||||
|
||||
type TLS struct {
|
||||
RawCert `yaml:",inline"`
|
||||
RawCert `yaml:",inline"`
|
||||
CustomTrustCert []RawCert `yaml:"custom-certifactes"`
|
||||
}
|
||||
|
||||
@ -259,7 +258,6 @@ type RawConfig struct {
|
||||
GeodataMode bool `yaml:"geodata-mode"`
|
||||
GeodataLoader string `yaml:"geodata-loader"`
|
||||
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"`
|
||||
|
||||
Sniffer RawSniffer `yaml:"sniffer"`
|
||||
@ -337,7 +335,6 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
||||
Proxy: []map[string]any{},
|
||||
ProxyGroup: []map[string]any{},
|
||||
TCPConcurrent: false,
|
||||
EnableProcess: false,
|
||||
FindProcessMode: P.FindProcessStrict,
|
||||
Tun: RawTun{
|
||||
Enable: false,
|
||||
@ -555,7 +552,6 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
||||
GeodataMode: cfg.GeodataMode,
|
||||
GeodataLoader: cfg.GeodataLoader,
|
||||
TCPConcurrent: cfg.TCPConcurrent,
|
||||
EnableProcess: cfg.EnableProcess,
|
||||
FindProcessMode: cfg.FindProcessMode,
|
||||
EBpf: cfg.EBpf,
|
||||
}, nil
|
||||
|
@ -102,5 +102,6 @@ type RuleProvider interface {
|
||||
Behavior() RuleType
|
||||
Match(*constant.Metadata) bool
|
||||
ShouldResolveIP() bool
|
||||
ShouldFindProcess() bool
|
||||
AsRule(adaptor string) constant.Rule
|
||||
}
|
||||
|
@ -9,6 +9,13 @@ mixed-port: 10801 # HTTP(S) 和 SOCKS 代理混合端口
|
||||
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
|
||||
|
||||
log-level: debug # 日志等级 silent/error/warning/info/debug
|
||||
|
@ -308,7 +308,7 @@ func updateTunnels(tunnels []LC.Tunnel) {
|
||||
|
||||
func updateGeneral(general *config.General, force bool) {
|
||||
tunnel.SetMode(general.Mode)
|
||||
tunnel.SetFindProcessMode(general.EnableProcess, general.FindProcessMode)
|
||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||
dialer.DisableIPv6 = !general.IPv6
|
||||
if !dialer.DisableIPv6 {
|
||||
log.Infoln("Use IPv6")
|
||||
|
@ -42,6 +42,11 @@ func (c *classicalStrategy) OnUpdate(rules []string) {
|
||||
shouldResolveIP := false
|
||||
for _, rawRule := range rules {
|
||||
ruleType, rule, params := ruleParse(rawRule)
|
||||
|
||||
if ruleType == "PROCESS-NAME" {
|
||||
c.shouldFindProcess = true
|
||||
}
|
||||
|
||||
r, err := c.parse(ruleType, rule, "", params)
|
||||
if err != nil {
|
||||
log.Warnln("parse rule error:[%s]", err.Error())
|
||||
|
@ -12,6 +12,10 @@ type domainStrategy struct {
|
||||
domainRules *trie.DomainTrie[struct{}]
|
||||
}
|
||||
|
||||
func (d *domainStrategy) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (d *domainStrategy) Match(metadata *C.Metadata) bool {
|
||||
return d.domainRules != nil && d.domainRules.Search(metadata.Host) != nil
|
||||
}
|
||||
|
@ -12,6 +12,10 @@ type ipcidrStrategy struct {
|
||||
trie *trie.IpCidrTrie
|
||||
}
|
||||
|
||||
func (i *ipcidrStrategy) ShouldFindProcess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *ipcidrStrategy) Match(metadata *C.Metadata) bool {
|
||||
return i.trie != nil && i.trie.IsContain(metadata.DstIP.AsSlice())
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ type ruleStrategy interface {
|
||||
Match(metadata *C.Metadata) bool
|
||||
Count() int
|
||||
ShouldResolveIP() bool
|
||||
ShouldFindProcess() bool
|
||||
OnUpdate(rules []string)
|
||||
}
|
||||
|
||||
@ -86,6 +87,10 @@ func (rp *ruleSetProvider) ShouldResolveIP() bool {
|
||||
return rp.strategy.ShouldResolveIP()
|
||||
}
|
||||
|
||||
func (rp *ruleSetProvider) ShouldFindProcess() bool {
|
||||
return rp.strategy.ShouldFindProcess()
|
||||
}
|
||||
|
||||
func (rp *ruleSetProvider) AsRule(adaptor string) C.Rule {
|
||||
panic("implement me")
|
||||
}
|
||||
|
@ -9,14 +9,15 @@ import (
|
||||
|
||||
type RuleSet struct {
|
||||
*common.Base
|
||||
ruleProviderName string
|
||||
adapter string
|
||||
ruleProvider P.RuleProvider
|
||||
noResolveIP bool
|
||||
ruleProviderName string
|
||||
adapter string
|
||||
ruleProvider P.RuleProvider
|
||||
noResolveIP bool
|
||||
shouldFindProcess bool
|
||||
}
|
||||
|
||||
func (rs *RuleSet) ShouldFindProcess() bool {
|
||||
return false
|
||||
return !rs.shouldFindProcess && rs.getProviders().ShouldFindProcess()
|
||||
}
|
||||
|
||||
func (rs *RuleSet) RuleType() C.RuleType {
|
||||
|
@ -148,12 +148,8 @@ func SetMode(m TunnelMode) {
|
||||
|
||||
// SetFindProcessMode replace SetAlwaysFindProcess
|
||||
// always find process info if legacyAlways = true or mode.Always() = true, may be increase many memory
|
||||
func SetFindProcessMode(legacyAlways bool, mode P.FindProcessMode) {
|
||||
if legacyAlways {
|
||||
findProcessMode = P.FindProcessAlways
|
||||
} else {
|
||||
findProcessMode = mode
|
||||
}
|
||||
func SetFindProcessMode(mode P.FindProcessMode) {
|
||||
findProcessMode = mode
|
||||
}
|
||||
|
||||
// processUDP starts a loop to handle udp packet
|
||||
|
Loading…
Reference in New Issue
Block a user