mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
chore: cleanup import path for component/process
This commit is contained in:
parent
8b32c4371e
commit
a3c023ae3e
@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/metacubex/mihomo/component/cidr"
|
"github.com/metacubex/mihomo/component/cidr"
|
||||||
"github.com/metacubex/mihomo/component/fakeip"
|
"github.com/metacubex/mihomo/component/fakeip"
|
||||||
"github.com/metacubex/mihomo/component/geodata"
|
"github.com/metacubex/mihomo/component/geodata"
|
||||||
P "github.com/metacubex/mihomo/component/process"
|
"github.com/metacubex/mihomo/component/process"
|
||||||
"github.com/metacubex/mihomo/component/resolver"
|
"github.com/metacubex/mihomo/component/resolver"
|
||||||
"github.com/metacubex/mihomo/component/sniffer"
|
"github.com/metacubex/mihomo/component/sniffer"
|
||||||
"github.com/metacubex/mihomo/component/trie"
|
"github.com/metacubex/mihomo/component/trie"
|
||||||
@ -57,7 +57,7 @@ type General struct {
|
|||||||
GeodataLoader string `json:"geodata-loader"`
|
GeodataLoader string `json:"geodata-loader"`
|
||||||
GeositeMatcher string `json:"geosite-matcher"`
|
GeositeMatcher string `json:"geosite-matcher"`
|
||||||
TCPConcurrent bool `json:"tcp-concurrent"`
|
TCPConcurrent bool `json:"tcp-concurrent"`
|
||||||
FindProcessMode P.FindProcessMode `json:"find-process-mode"`
|
FindProcessMode process.FindProcessMode `json:"find-process-mode"`
|
||||||
Sniffing bool `json:"sniffing"`
|
Sniffing bool `json:"sniffing"`
|
||||||
GlobalClientFingerprint string `json:"global-client-fingerprint"`
|
GlobalClientFingerprint string `json:"global-client-fingerprint"`
|
||||||
GlobalUA string `json:"global-ua"`
|
GlobalUA string `json:"global-ua"`
|
||||||
@ -420,7 +420,7 @@ type RawConfig struct {
|
|||||||
GeodataLoader string `yaml:"geodata-loader" json:"geodata-loader"`
|
GeodataLoader string `yaml:"geodata-loader" json:"geodata-loader"`
|
||||||
GeositeMatcher string `yaml:"geosite-matcher" json:"geosite-matcher"`
|
GeositeMatcher string `yaml:"geosite-matcher" json:"geosite-matcher"`
|
||||||
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`
|
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`
|
||||||
FindProcessMode P.FindProcessMode `yaml:"find-process-mode" json:"find-process-mode"`
|
FindProcessMode process.FindProcessMode `yaml:"find-process-mode" json:"find-process-mode"`
|
||||||
GlobalClientFingerprint string `yaml:"global-client-fingerprint" json:"global-client-fingerprint"`
|
GlobalClientFingerprint string `yaml:"global-client-fingerprint" json:"global-client-fingerprint"`
|
||||||
GlobalUA string `yaml:"global-ua" json:"global-ua"`
|
GlobalUA string `yaml:"global-ua" json:"global-ua"`
|
||||||
ETagSupport bool `yaml:"etag-support" json:"etag-support"`
|
ETagSupport bool `yaml:"etag-support" json:"etag-support"`
|
||||||
@ -479,7 +479,7 @@ func DefaultRawConfig() *RawConfig {
|
|||||||
Proxy: []map[string]any{},
|
Proxy: []map[string]any{},
|
||||||
ProxyGroup: []map[string]any{},
|
ProxyGroup: []map[string]any{},
|
||||||
TCPConcurrent: false,
|
TCPConcurrent: false,
|
||||||
FindProcessMode: P.FindProcessStrict,
|
FindProcessMode: process.FindProcessStrict,
|
||||||
GlobalUA: "clash.meta/" + C.Version,
|
GlobalUA: "clash.meta/" + C.Version,
|
||||||
ETagSupport: true,
|
ETagSupport: true,
|
||||||
DNS: RawDNS{
|
DNS: RawDNS{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/metacubex/mihomo/common/utils"
|
"github.com/metacubex/mihomo/common/utils"
|
||||||
"github.com/metacubex/mihomo/component/loopback"
|
"github.com/metacubex/mihomo/component/loopback"
|
||||||
"github.com/metacubex/mihomo/component/nat"
|
"github.com/metacubex/mihomo/component/nat"
|
||||||
P "github.com/metacubex/mihomo/component/process"
|
"github.com/metacubex/mihomo/component/process"
|
||||||
"github.com/metacubex/mihomo/component/resolver"
|
"github.com/metacubex/mihomo/component/resolver"
|
||||||
"github.com/metacubex/mihomo/component/slowdown"
|
"github.com/metacubex/mihomo/component/slowdown"
|
||||||
"github.com/metacubex/mihomo/component/sniffer"
|
"github.com/metacubex/mihomo/component/sniffer"
|
||||||
@ -59,7 +59,7 @@ var (
|
|||||||
// default timeout for UDP session
|
// default timeout for UDP session
|
||||||
udpTimeout = 60 * time.Second
|
udpTimeout = 60 * time.Second
|
||||||
|
|
||||||
findProcessMode = atomic.NewInt32Enum(P.FindProcessStrict)
|
findProcessMode = atomic.NewInt32Enum(process.FindProcessStrict)
|
||||||
|
|
||||||
snifferDispatcher *sniffer.Dispatcher
|
snifferDispatcher *sniffer.Dispatcher
|
||||||
sniffingEnable = false
|
sniffingEnable = false
|
||||||
@ -263,13 +263,13 @@ func SetMode(m TunnelMode) {
|
|||||||
mode = m
|
mode = m
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindProcessMode() P.FindProcessMode {
|
func FindProcessMode() process.FindProcessMode {
|
||||||
return findProcessMode.Load()
|
return findProcessMode.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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(mode P.FindProcessMode) {
|
func SetFindProcessMode(mode process.FindProcessMode) {
|
||||||
findProcessMode.Store(mode)
|
findProcessMode.Store(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ func resolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err erro
|
|||||||
attemptProcessLookup = false
|
attemptProcessLookup = false
|
||||||
if !features.CMFA {
|
if !features.CMFA {
|
||||||
// normal check for process
|
// normal check for process
|
||||||
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort))
|
uid, path, err := process.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
|
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
|
||||||
} else {
|
} else {
|
||||||
@ -366,13 +366,13 @@ func resolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err erro
|
|||||||
metadata.ProcessPath = path
|
metadata.ProcessPath = path
|
||||||
metadata.Uid = uid
|
metadata.Uid = uid
|
||||||
|
|
||||||
if pkg, err := P.FindPackageName(metadata); err == nil { // for android (not CMFA) package names
|
if pkg, err := process.FindPackageName(metadata); err == nil { // for android (not CMFA) package names
|
||||||
metadata.Process = pkg
|
metadata.Process = pkg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check package names
|
// check package names
|
||||||
pkg, err := P.FindPackageName(metadata)
|
pkg, err := process.FindPackageName(metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
|
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
|
||||||
} else {
|
} else {
|
||||||
@ -384,10 +384,10 @@ func resolveMetadata(metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch FindProcessMode() {
|
switch FindProcessMode() {
|
||||||
case P.FindProcessAlways:
|
case process.FindProcessAlways:
|
||||||
helper.FindProcess()
|
helper.FindProcess()
|
||||||
helper.FindProcess = nil
|
helper.FindProcess = nil
|
||||||
case P.FindProcessOff:
|
case process.FindProcessOff:
|
||||||
helper.FindProcess = nil
|
helper.FindProcess = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user