Due to setting the IP_STRPHDR socket option in darwin (macOS) environments,
reads on unprivileged sockets (udp) include the IP header before the ICMP header in the read bytes returned by icmp.ListenPacket(). As a result of this, pro-bing ends up discarding icmp echo replies due to the unexpected ip header bytes returned by icmp.ListenPacket().
While this problem needs to be addressed in go itself, this patch provides a work around until this issue is addressed.
TLDR: unprivileged icmp echo replies are discarded on macOS (darwin)
This is a patch to work around an issue described in https://github.com/golang/go/issues/47369 which can be summarized as follows:
Due to setting the IP_STRPHDR socket option in darwin (macOS) environments, reads on unprivileged sockets (udp) include the IP header before the ICMP header in the read bytes returned by
icmp.ListenPacket()
. As a result of this,pro-bing
ends up discarding icmp echo replies due to the unexpected ip header bytes returned byicmp.ListenPacket()
.While this problem needs to be addressed in go itself, this patch provides a work around until this issue is addressed.