mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-03 16:13:30 +08:00
fix: fix package name rules match
This commit is contained in:
parent
923f3cc1e3
commit
320b3babc1
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,14 +621,25 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
||||
|
||||
if attemptProcessLookup && !findProcessMode.Off() && (findProcessMode.Always() || rule.ShouldFindProcess()) {
|
||||
attemptProcessLookup = false
|
||||
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: %v", metadata.String(), err)
|
||||
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
|
||||
} else {
|
||||
metadata.Process = filepath.Base(path)
|
||||
metadata.ProcessPath = path
|
||||
metadata.Uid = uid
|
||||
}
|
||||
} else {
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matched, ada := rule.Match(metadata); matched {
|
||||
|
Loading…
x
Reference in New Issue
Block a user