pong adjust

master
sre 4 years ago
parent bdae617801
commit 225d6e7819

@ -5,6 +5,8 @@ import (
"encoding/binary"
"fmt"
"net"
"os"
"os/signal"
"time"
)
@ -147,6 +149,12 @@ func Ping(domain string, PS int) {
}
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
s := <-c
fmt.Println("Got signal:", s)
fmt.Printf("--- %s ping statistics ---\n", raddr.String())
fmt.Printf("%d packets transmitted, %f lost, %.2f%% packet loss, time 1000ms\n", icmp_seq, dropPack, dropPack/float64(icmp_seq)*100)
@ -162,3 +170,7 @@ func Ping(domain string, PS int) {
fmt.Printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f ms", min_lan, avg_lan, max_lan)
}
func foot() {
}

@ -1,9 +1,19 @@
package goping
import (
"fmt"
"os"
"os/signal"
"testing"
)
func TestSign(tt *testing.T) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
s := <-c
fmt.Println("Got signal:", s)
}
func TestPing(tt *testing.T) {
//if len(os.Args) < 3 {
// fmt.Printf("Param domain |data package Sizeof|trace times\n Ex: ./Ping www.so.com 100 4\n")
@ -19,6 +29,6 @@ func TestPing(tt *testing.T) {
// fmt.Println("you need input correct Counts")
// os.Exit(1)
//}
Ping("www.baidu.com", 48, 5)
Ping("www.baidu.com", 48)
//Ping("www.baidu.com", 48, 5)
}

@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"os"
"os/signal"
"pong/dial"
"pong/goping"
"strconv"
@ -21,6 +22,13 @@ pong -a www.baidu.com -p 443 -k tcp -t 3
`
func main() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
s := <-c
fmt.Println("Got signal:", s)
}
func main1() {
address := flag.String("a", "", "domain or ip address")
port := flag.Int("p", 0, "port")
protocol := flag.String("k", "tcp", "protocol kind")

@ -9,12 +9,12 @@ pong -a www.baidu.com -p 443 -k tcp -t 3
## build
cd /root
rm -rf pong
git clone https://sre:N7q5BcbQrjpEav_iRCKBta_pVyFhUE_V@git.sre.ink/sre/pong.git
git clone https://git.sre.ink/sre/pong.git
cd pong
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on GOPROXY="https://goproxy.cn,direct" go build -v -a -o pong pong.go
rm -rf /usr/bin/pong
mv pong /usr/bin/
pong www.baidu.com
pong www.baidu.com 443

Loading…
Cancel
Save