This commit is contained in:
esrrhs committed 2019-10-30 19:45:19 +08:00
1 parent a4573f1540
commit 160d6efc89
3 files changed
+44 -10

No files matched your search

+6 -2
View File
@@ -12,6 +12,7 @@ import (
"golang.org/x/net/ipv4"
"io"
"net"
"sync"
"syscall"
"time"
)
@@ -77,10 +78,13 @@ func sendICMP(id int, sequence int, conn icmp.PacketConn, server *net.IPAddr, ta
return
}
func recvICMP(conn icmp.PacketConn, recv chan<- *Packet) {
func recvICMP(workResultLock *sync.WaitGroup, exit *bool, conn icmp.PacketConn, recv chan<- *Packet) {
(*workResultLock).Add(1)
defer (*workResultLock).Done()
bytes := make([]byte, 10240)
for {
for !*exit {
conn.SetReadDeadline(time.Now().Add(time.Millisecond * 100))
n, srcaddr, err := conn.ReadFrom(bytes)