fix process code
This commit is contained in:
parent
c3fa4a0121
commit
5c3b78e2fc
1 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,10 @@ const (
|
||||||
proccallnumpidinfo = 0x2
|
proccallnumpidinfo = 0x2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func resolveSocketByNetlink(network string, ip netip.Addr, srcPort int) (int32, int32, error) {
|
||||||
|
return 0, 0, ErrPlatformNotSupport
|
||||||
|
}
|
||||||
|
|
||||||
func findProcessName(network string, ip netip.Addr, port int) (int32, string, error) {
|
func findProcessName(network string, ip netip.Addr, port int) (int32, string, error) {
|
||||||
var spath string
|
var spath string
|
||||||
switch network {
|
switch network {
|
||||||
|
@ -78,7 +82,8 @@ func findProcessName(network string, ip netip.Addr, port int) (int32, string, er
|
||||||
if ip == srcIP {
|
if ip == srcIP {
|
||||||
// xsocket_n.so_last_pid
|
// xsocket_n.so_last_pid
|
||||||
pid := readNativeUint32(buf[so+68 : so+72])
|
pid := readNativeUint32(buf[so+68 : so+72])
|
||||||
return getExecPathFromPID(pid)
|
pp, err := getExecPathFromPID(pid)
|
||||||
|
return -1, pp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// udp packet connection may be not equal with srcIP
|
// udp packet connection may be not equal with srcIP
|
||||||
|
@ -88,10 +93,10 @@ func findProcessName(network string, ip netip.Addr, port int) (int32, string, er
|
||||||
}
|
}
|
||||||
|
|
||||||
if network == UDP && fallbackUDPProcess != "" {
|
if network == UDP && fallbackUDPProcess != "" {
|
||||||
return fallbackUDPProcess, nil
|
return -1, fallbackUDPProcess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", ErrNotFound
|
return -1, "", ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExecPathFromPID(pid uint32) (string, error) {
|
func getExecPathFromPID(pid uint32) (string, error) {
|
||||||
|
|
Loading…
Reference in a new issue