From bb9fac37ae5b7db87df3c6e255d3c96190de5663 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 14 Jun 2022 23:14:43 +0800 Subject: [PATCH] fix: find process error --- tunnel/tunnel.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 7096811b..53617d76 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -386,18 +386,16 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) { resolved = true } - if !foundProcess && alwaysFindProcess && rule.ShouldFindProcess() { + if !foundProcess && (alwaysFindProcess || rule.ShouldFindProcess()) { srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16) - if err == nil && P.ShouldFindProcess(metadata) { - uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort)) - if err != nil { - log.Debugln("[Process] find process %s: %v", metadata.String(), err) - } else { - process = filepath.Base(path) - processPath = path - processUid = uid - foundProcess = true - } + uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort)) + if err != nil { + log.Debugln("[Process] find process %s: %v", metadata.String(), err) + } else { + process = filepath.Base(path) + processPath = path + processUid = uid + foundProcess = true } }