mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 07:23:17 +08:00
fix: fix package name rules match
This commit is contained in:
parent
b5a8f0fce1
commit
aa3c1ac623
@ -3,7 +3,6 @@ package inbound
|
|||||||
import (
|
import (
|
||||||
C "github.com/metacubex/mihomo/constant"
|
C "github.com/metacubex/mihomo/constant"
|
||||||
"github.com/metacubex/mihomo/transport/socks5"
|
"github.com/metacubex/mihomo/transport/socks5"
|
||||||
"github.com/metacubex/mihomo/constant/features"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPacket is PacketAdapter generator
|
// NewPacket is PacketAdapter generator
|
||||||
|
@ -3,6 +3,7 @@ package process
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"github.com/metacubex/mihomo/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -19,3 +20,7 @@ const (
|
|||||||
func FindProcessName(network string, srcIP netip.Addr, srcPort int) (uint32, string, error) {
|
func FindProcessName(network string, srcIP netip.Addr, srcPort int) (uint32, string, error) {
|
||||||
return findProcessName(network, srcIP, srcPort)
|
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/resolver"
|
||||||
"github.com/metacubex/mihomo/component/sniffer"
|
"github.com/metacubex/mihomo/component/sniffer"
|
||||||
C "github.com/metacubex/mihomo/constant"
|
C "github.com/metacubex/mihomo/constant"
|
||||||
|
"github.com/metacubex/mihomo/constant/features"
|
||||||
"github.com/metacubex/mihomo/constant/provider"
|
"github.com/metacubex/mihomo/constant/provider"
|
||||||
icontext "github.com/metacubex/mihomo/context"
|
icontext "github.com/metacubex/mihomo/context"
|
||||||
"github.com/metacubex/mihomo/log"
|
"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()) {
|
if attemptProcessLookup && !findProcessMode.Off() && (findProcessMode.Always() || rule.ShouldFindProcess()) {
|
||||||
attemptProcessLookup = false
|
attemptProcessLookup = false
|
||||||
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort))
|
if !features.Contains("cmfa") {
|
||||||
if err != nil {
|
// normal check for process
|
||||||
log.Debugln("[Process] find process %s: %v", metadata.String(), err)
|
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 {
|
} else {
|
||||||
metadata.Process = filepath.Base(path)
|
// check package names
|
||||||
metadata.ProcessPath = path
|
pkg, err := P.FindPackageName(metadata)
|
||||||
metadata.Uid = uid
|
if err != nil {
|
||||||
|
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
|
||||||
|
} else {
|
||||||
|
metadata.Process = pkg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user