diff --git a/adapter/inbound/packet.go b/adapter/inbound/packet.go index a87c6276..a10d402e 100644 --- a/adapter/inbound/packet.go +++ b/adapter/inbound/packet.go @@ -3,7 +3,6 @@ package inbound import ( C "github.com/metacubex/mihomo/constant" "github.com/metacubex/mihomo/transport/socks5" - "github.com/metacubex/mihomo/constant/features" ) // NewPacket is PacketAdapter generator diff --git a/component/process/process.go b/component/process/process.go index 76ec2c45..5b49134e 100644 --- a/component/process/process.go +++ b/component/process/process.go @@ -3,6 +3,7 @@ package process import ( "errors" "net/netip" + "github.com/metacubex/mihomo/constant" ) var ( @@ -19,3 +20,7 @@ const ( func FindProcessName(network string, srcIP netip.Addr, srcPort int) (uint32, string, error) { return findProcessName(network, srcIP, srcPort) } + +func FindPackageName(metadata *constant.Metadata) (string, error) { + return "", nil +} diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 596e26d7..bbc2d1a1 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -18,6 +18,7 @@ import ( "github.com/metacubex/mihomo/component/resolver" "github.com/metacubex/mihomo/component/sniffer" C "github.com/metacubex/mihomo/constant" + "github.com/metacubex/mihomo/constant/features" "github.com/metacubex/mihomo/constant/provider" icontext "github.com/metacubex/mihomo/context" "github.com/metacubex/mihomo/log" @@ -620,13 +621,24 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) { if attemptProcessLookup && !findProcessMode.Off() && (findProcessMode.Always() || rule.ShouldFindProcess()) { attemptProcessLookup = false - uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort)) - if err != nil { - log.Debugln("[Process] find process %s: %v", metadata.String(), err) + if !features.Contains("cmfa") { + // normal check for process + uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort)) + if err != nil { + log.Debugln("[Process] find process %s error: %v", metadata.String(), err) + } else { + metadata.Process = filepath.Base(path) + metadata.ProcessPath = path + metadata.Uid = uid + } } else { - metadata.Process = filepath.Base(path) - metadata.ProcessPath = path - metadata.Uid = uid + // check package names + pkg, err := P.FindPackageName(metadata) + if err != nil { + log.Debugln("[Process] find process %s error: %v", metadata.String(), err) + } else { + metadata.Process = pkg + } } }