go-ping / ping

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

有时候莫名其妙的卡住 #215

Closed yl604636754 closed 1 year ago

yl604636754 commented 2 years ago

pinger, err := ping.NewPinger(item.Virtualip) if err != nil { fmt.Println("地域为:", item.Province, "n2n虚拟ip为:", item.Virtualip, "n2n虚拟mac为:", item.Virtualmac, "公网ip为:", item.Commonip, "ping报错:", err.Error()) return } c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { for = range c { pinger.Stop() } }() pinger.SetPrivileged(true) //pinger.Timeout = 10 time.Second pinger.Count = 5 pinger.OnRecv = func(pkt ping.Packet) { fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v\n", pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt) } 在onRecv有时候莫名其秒的卡住没有任何的显示消息。

YouZhengChuan commented 1 year ago

能不能把你的代码格式化一下再提交上来。lol

YouZhengChuan commented 1 year ago

pinger.Run没有调用啊