cakturk / go-netstat

A netstat implementation written in Go
MIT License
237 stars 67 forks source link

Process.Name or Process.Pid can not be filtered #12

Open championwang2020 opened 4 years ago

championwang2020 commented 4 years ago

The following code will throw panic: "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pid == 6720 })" or "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pname == "chrome" })" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x511799]

Rex0519 commented 2 years ago

The following code will throw panic: "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pid == 6720 })" or "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pname == "chrome" })" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x511799]

Same issue. Always throws panic when runs TCPsocks but not UDPsocks.

zkscpqm commented 2 years ago

The following code will throw panic: "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pid == 6720 })" or "tabs, err := netstat.TCPSocks(func(s netstat.SockTabEntry) bool { return s.Process.Pname == "chrome" })" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x511799]

Same issue. Always throws panic when runs TCPsocks but not UDPsocks.

check https://github.com/cakturk/go-netstat/pull/13