go-ping / ping

ICMP Ping library for Go
MIT License
1.31k stars 344 forks source link

Fix non-privileged (UDP) ping response parsing for OSes not supporting STRIPHDR sock option #218

Closed emakeev closed 1 year ago

emakeev commented 2 years ago

It could be related to the issues #180 & #216. I noticed that on Mac OS 12.5, MacBook Pro M1 non-privileged pings do not work on remote IPs (pinging local loopback interfaces works fine). While I can see correct ICMP requests & responses with tcpdump, ping discards responses because they include unexpected IP headers.

It looks like STRIPHDR socket option is not working as expected on some darwin setups: https://go.googlesource.com/net/+/master/icmp/listen_posix.go#75.

The workaround fixes the issue on Mac & doesn't break working loopback pings, but it wasn't tested on Windows or linux.

SuperQ commented 1 year ago

See https://github.com/go-ping/ping/pull/226