We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There's no way to handle the timeouts and when destination doesn't send any answers, it still seems like a success ping. example code:
pinger, err := probing.NewPinger(hostname) pinger.SetPrivileged(true) pinger.OnSetup = func() { fmt.Println("Setup") } pinger.OnSend = func(packet *probing.Packet) { fmt.Println("Sent: ", packet) } pinger.OnSendError = func(packet *probing.Packet, err error) { fmt.Errorf("Error sending packet: %v", err) } pinger.OnRecv = func(packet *probing.Packet) { fmt.Println("Received: ", packet) } pinger.OnRecvError = func(err error) { fmt.Errorf("Error receiving packet: %v", err) } pinger.OnFinish = func(stats *probing.Statistics) { fmt.Printf("Ping statistics for %s: rtt -> %.2f / %.2f / %.2f ms packet loss: %.2f%%\n", hostname, stats.MinRtt.Seconds()*1000, stats.AvgRtt.Seconds()*1000, stats.MaxRtt.Seconds()*1000, stats.PacketLoss) } pinger.OnDuplicateRecv = func(packet *probing.Packet) { fmt.Println("Duplicate: ", packet) } pinger.Count = 4 pinger.Timeout = 4 * time.Second bg := context.Background() ct, _ := context.WithTimeout(bg, 4*time.Second) err = pinger.RunWithContext(ct) // Blocks until finished. if err != nil { fmt.Println("ERROR PINGING..") fmt.Errorf("Error running pinger: %v", err) return false, err.Error(), err } fmt.Println("DONE!")
it triggers Setup and Recv events but no errors appear in failed pings
The text was updated successfully, but these errors were encountered:
/duplicate #19
Sorry, something went wrong.
No branches or pull requests
There's no way to handle the timeouts and when destination doesn't send any answers, it still seems like a success ping.
example code:
it triggers Setup and Recv events but no errors appear in failed pings
The text was updated successfully, but these errors were encountered: