Use unix.SysctlRaw for macOS

This commit is contained in:
ruokeqx 2024-07-22 12:41:44 +08:00 committed by 世界
parent 1349acfd5a
commit e5991cae0b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -60,12 +60,12 @@ func findProcessName(network string, ip netip.Addr, port int) (string, error) {
isIPv4 := ip.Is4() isIPv4 := ip.Is4()
value, err := syscall.Sysctl(spath) value, err := unix.SysctlRaw(spath)
if err != nil { if err != nil {
return "", err return "", err
} }
buf := []byte(value) buf := value
// from darwin-xnu/bsd/netinet/in_pcblist.c:get_pcblist_n // from darwin-xnu/bsd/netinet/in_pcblist.c:get_pcblist_n
// size/offset are round up (aligned) to 8 bytes in darwin // size/offset are round up (aligned) to 8 bytes in darwin