klw-account2 d6dae3bab7 feature: 增加网络诊断服务 | 2 tuần trước cách đây | |
---|---|---|
.. | ||
pb | 2 tuần trước cách đây | |
NetworkDiagnosticServer.go | 2 tuần trước cách đây | |
ping_test.go | 2 tuần trước cách đây | |
readme.md | 2 tuần trước cách đây |
This library attempts to send an "unprivileged" ping via UDP. On Linux, this must be enabled with the following sysctl command:
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
If you do not wish to do this, you can call pinger.SetPrivileged(true)
in your code and then use setcap on your binary to allow it to bind to raw sockets (or just run it as root):
setcap cap_net_raw=+ep /path/to/your/compiled/binary
See this blog and the Go x/net/icmp package for more details.
You must use pinger.SetPrivileged(true)
, otherwise you will receive the following error:
socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Despite the method name, this should work without the need to elevate privileges and has been tested on Windows 10. Please note that accessing packet TTL values is not supported due to limitations in the Go x/net/ipv4 and x/net/ipv6 packages.
There is no support for Plan 9. This is because the entire x/net/ipv4
and x/net/ipv6
packages are not implemented by the Go programming language.