From ecaf1d632a91cf89b60bbafc1eaffb7d569721ae Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 1 Sep 2019 15:25:37 +0800 Subject: [PATCH] get process name if monitor is enabled --- proxy/tcp.go | 5 +++-- proxy/udp.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/proxy/tcp.go b/proxy/tcp.go index 5542a0c..a0369fe 100644 --- a/proxy/tcp.go +++ b/proxy/tcp.go @@ -94,9 +94,10 @@ func (h *tcpHandler) Handle(conn net.Conn, target *net.TCPAddr) error { return err } - // Get name of the process - var process = lsof.GetProcessName(localConn.LocalAddr()) + var process = "N/A" if monitor != nil { + // Get name of the process + process = lsof.GetProcessName(localConn.LocalAddr()) session := &S.Session{ Process: process, Network: localConn.LocalAddr().Network(), diff --git a/proxy/udp.go b/proxy/udp.go index 299ecbb..2073ea7 100644 --- a/proxy/udp.go +++ b/proxy/udp.go @@ -78,9 +78,10 @@ func (h *udpHandler) Connect(conn core.UDPConn, target *net.UDPAddr) error { return err } - // Get name of the process - var process = lsof.GetProcessName(conn.LocalAddr()) + var process = "N/A" if monitor != nil { + // Get name of the process + process = lsof.GetProcessName(conn.LocalAddr()) session := &S.Session{ Process: process, Network: conn.LocalAddr().Network(),