mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-11-01 04:22:44 +08:00
fix process name empty
This commit is contained in:
@@ -93,13 +93,16 @@ func (h *tcpHandler) Handle(localConn net.Conn, target *net.TCPAddr) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var process = "N/A"
|
||||
var process string
|
||||
var sess *stats.Session
|
||||
if h.sessionStater != nil {
|
||||
// Get name of the process.
|
||||
localHost, localPortStr, _ := net.SplitHostPort(localConn.LocalAddr().String())
|
||||
localPortInt, _ := strconv.Atoi(localPortStr)
|
||||
process, _ = lsof.GetCommandNameBySocket(target.Network(), localHost, uint16(localPortInt))
|
||||
process, err = lsof.GetCommandNameBySocket(target.Network(), localHost, uint16(localPortInt))
|
||||
if err != nil {
|
||||
process = "N/A"
|
||||
}
|
||||
|
||||
sess = &stats.Session{
|
||||
ProcessName: process,
|
||||
|
||||
@@ -164,12 +164,15 @@ func (h *udpHandler) connectInternal(conn core.UDPConn, targetAddr string) error
|
||||
return err
|
||||
}
|
||||
|
||||
var process = "N/A"
|
||||
var process string
|
||||
if h.sessionStater != nil {
|
||||
// Get name of the process.
|
||||
localHost, localPortStr, _ := net.SplitHostPort(conn.LocalAddr().String())
|
||||
localPortInt, _ := strconv.Atoi(localPortStr)
|
||||
process, _ = lsof.GetCommandNameBySocket(conn.LocalAddr().Network(), localHost, uint16(localPortInt))
|
||||
process, err = lsof.GetCommandNameBySocket(conn.LocalAddr().Network(), localHost, uint16(localPortInt))
|
||||
if err != nil {
|
||||
process = "N/A"
|
||||
}
|
||||
|
||||
sess := &stats.Session{
|
||||
ProcessName: process,
|
||||
|
||||
Reference in New Issue
Block a user