mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-11-02 21:04:01 +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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var process = "N/A"
|
var process string
|
||||||
var sess *stats.Session
|
var sess *stats.Session
|
||||||
if h.sessionStater != nil {
|
if h.sessionStater != nil {
|
||||||
// Get name of the process.
|
// Get name of the process.
|
||||||
localHost, localPortStr, _ := net.SplitHostPort(localConn.LocalAddr().String())
|
localHost, localPortStr, _ := net.SplitHostPort(localConn.LocalAddr().String())
|
||||||
localPortInt, _ := strconv.Atoi(localPortStr)
|
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{
|
sess = &stats.Session{
|
||||||
ProcessName: process,
|
ProcessName: process,
|
||||||
|
|||||||
@@ -164,12 +164,15 @@ func (h *udpHandler) connectInternal(conn core.UDPConn, targetAddr string) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var process = "N/A"
|
var process string
|
||||||
if h.sessionStater != nil {
|
if h.sessionStater != nil {
|
||||||
// Get name of the process.
|
// Get name of the process.
|
||||||
localHost, localPortStr, _ := net.SplitHostPort(conn.LocalAddr().String())
|
localHost, localPortStr, _ := net.SplitHostPort(conn.LocalAddr().String())
|
||||||
localPortInt, _ := strconv.Atoi(localPortStr)
|
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{
|
sess := &stats.Session{
|
||||||
ProcessName: process,
|
ProcessName: process,
|
||||||
|
|||||||
Reference in New Issue
Block a user