diff --git a/goping/goping.go b/goping/goping.go index d81b969..a7654cb 100644 --- a/goping/goping.go +++ b/goping/goping.go @@ -122,14 +122,16 @@ func Ping(domain string, PS int) { 向目标地址发送二进制报文包 如果发送失败就丢包 ++ */ - if _, err := conn.Write(buffer.Bytes()); err != nil { + index, err := conn.Write(buffer.Bytes()) + if err != nil { fmt.Printf("%s\n", red("timeout")) dropPack++ time.Sleep(time.Second) fmt.Println("666666666666666666666666666") - continue } + fmt.Println(index, "index") + // 否则记录当前得时间 t_start := time.Now() conn.SetReadDeadline((time.Now().Add(time.Second * 3))) diff --git a/readme.md b/readme.md index ca0f368..254d92f 100644 --- a/readme.md +++ b/readme.md @@ -28,9 +28,10 @@ cd /root rm -rf pong git clone https://git.sre.ink/go/pong.git cd pong -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on GOPROXY="https://goproxy.cn,direct" go mod tidy -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on GOPROXY="https://goproxy.cn,direct" go build -v -a -o pong pong.go +make build-linux-amd64 rm -rf /usr/bin/pong mv pong /usr/bin/ pong www.baidu.com 443 ``` +# issue +pong www.baidu1.com 不会捕获ctrlc \ No newline at end of file