fix: find pkg not work

This commit is contained in:
riolurs 2023-10-22 22:42:10 +08:00 committed by wwqgtxx
parent a883faae9d
commit 7d58238e06
2 changed files with 3 additions and 7 deletions

View file

@ -10,6 +10,5 @@ func FindPackageName(metadata *constant.Metadata) (string, error) {
if resolver := DefaultPackageNameResolver; resolver != nil { if resolver := DefaultPackageNameResolver; resolver != nil {
return resolver(metadata) return resolver(metadata)
} }
return "", ErrPlatformNotSupport return "", ErrPlatformNotSupport
} }

View file

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"net" "net"
"net/netip" "net/netip"
"path/filepath"
"runtime" "runtime"
"sync" "sync"
"time" "time"
@ -621,16 +620,14 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
} }
if !findProcessMode.Off() && !processFound && (findProcessMode.Always() || rule.ShouldFindProcess()) { if !findProcessMode.Off() && !processFound && (findProcessMode.Always() || rule.ShouldFindProcess()) {
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort)) pkg, err := P.FindPackageName(metadata)
if err != nil { if err != nil {
log.Debugln("[Process] find process %s: %v", metadata.String(), err) log.Debugln("[Process] find process %s: %v", metadata.String(), err)
} else { } else {
metadata.Process = filepath.Base(path) metadata.Process = pkg
metadata.ProcessPath = path
metadata.Uid = uid
processFound = true processFound = true
if procesCache != metadata.Process { if procesCache != metadata.Process {
log.Debugln("[Process] %s from process %s", metadata.String(), path) log.Debugln("[Process] %s from process %s", metadata.String(), metadata.Process)
} }
procesCache = metadata.Process procesCache = metadata.Process
} }