master
sre 4 years ago
parent 382b98da58
commit 1519d3cbf6

@ -112,6 +112,7 @@ func Ping(domain string, PS int) {
icmp_seq := 1 icmp_seq := 1
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
for { for {
/* /*
@ -147,11 +148,9 @@ func Ping(domain string, PS int) {
select { select {
case s := <-c: case s := <-c:
fmt.Println("777777777777777777777777")
signal.Notify(c, os.Interrupt, os.Kill)
fmt.Println("Got signal:", s)
foot(raddr.String(), icmp_seq, dropPack, min_lan, avg_lan, max_lan, ret_list) foot(raddr.String(), icmp_seq, dropPack, min_lan, avg_lan, max_lan, ret_list)
os.Exit(0) os.Exit(0)
fmt.Println("Got signal:", s)
default: default:
fmt.Printf("%d bytes from %s (%s): icmp_seq=%d ttl=53 time=%.3f ms\n", len, raddr.String(), raddr.String(), icmp_seq, dur) fmt.Printf("%d bytes from %s (%s): icmp_seq=%d ttl=53 time=%.3f ms\n", len, raddr.String(), raddr.String(), icmp_seq, dur)
//fmt.Printf("来自 %s 的回复: 大小 = %d byte 时间 = %.3fms\n", raddr.String(), len, dur) //fmt.Printf("来自 %s 的回复: 大小 = %d byte 时间 = %.3fms\n", raddr.String(), len, dur)

@ -22,7 +22,7 @@ pong www.baidu.com 443 -t 1 -k udp
pong -a www.baidu.com -p 443 -k tcp -t 3 pong -a www.baidu.com -p 443 -k tcp -t 3
` `
func main() { func main2() {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill) signal.Notify(c, os.Interrupt, os.Kill)
for { for {
@ -38,7 +38,7 @@ func main() {
} }
} }
func main3() { func main() {
address := flag.String("a", "", "domain or ip address") address := flag.String("a", "", "domain or ip address")
port := flag.Int("p", 0, "port") port := flag.Int("p", 0, "port")
protocol := flag.String("k", "tcp", "protocol kind") protocol := flag.String("k", "tcp", "protocol kind")

Loading…
Cancel
Save