digineo / go-ping

A simple ping library using ICMP echo requests.
MIT License
234 stars 32 forks source link

Pinger.New() can only create privileged icmp.PacketConn #12

Open realnedsanders opened 5 years ago

realnedsanders commented 5 years ago

Pinger.New() runs connectICMP() which runs icmp.ListenPacket(network, address) using static value "ip4:icmp" as network. Per icmp.ListenPacket() def, this only allows usage of privileged endpoints.

ListenPacket listens for incoming ICMP packets addressed to address. See net.Dial for the syntax of address.

For non-privileged datagram-oriented ICMP endpoints, network must be "udp4" or "udp6". The endpoint allows to read, write a few limited ICMP messages such as echo request and echo reply. Currently only Darwin and Linux support this.