From a442584b892dd394d8027c6d8527f67d2d1f6063 Mon Sep 17 00:00:00 2001 From: esrrhs Date: Sat, 22 Dec 2018 18:20:58 +0800 Subject: [PATCH] add --- client.go | 6 ++---- cmd/main.go | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index 94bab01..6f7b70b 100644 --- a/client.go +++ b/client.go @@ -9,7 +9,7 @@ import ( "time" ) -func NewClient(addr string, server string, target string, timeout int, sproto int, rproto int, hb int) (*Client, error) { +func NewClient(addr string, server string, target string, timeout int, sproto int, rproto int) (*Client, error) { ipaddr, err := net.ResolveUDPAddr("udp", addr) if err != nil { @@ -32,7 +32,6 @@ func NewClient(addr string, server string, target string, timeout int, sproto in timeout: timeout, sproto: sproto, rproto: rproto, - hb: hb, }, nil } @@ -43,7 +42,6 @@ type Client struct { timeout int sproto int rproto int - hb int ipaddr *net.UDPAddr addr string @@ -237,7 +235,7 @@ func (p *Client) checkTimeoutConn() { } func (p *Client) ping() { - if p.sendPacket == 0 && p.recvPacket == 0 { + if p.sendPacket == 0 { now := time.Now() b, _ := now.MarshalBinary() sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(PING), b, p.sproto, p.rproto) diff --git a/cmd/main.go b/cmd/main.go index e9f6124..97ffac0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -36,8 +36,6 @@ Usage: -rproto 客户端接收ping协议的协议,默认是0 The protocol that the client receives the ping. The default is 0. - - -hb 客户端自动保持每秒发到服务器的心跳包,用于在某些网络下更新服务器的id和seq,以接收到服务器的reply,默认0关闭 ` func main() { @@ -49,7 +47,6 @@ func main() { timeout := flag.Int("timeout", 60, "conn timeout") sproto := flag.Int("sproto", 8, "send ping proto") rproto := flag.Int("rproto", 0, "recv ping proto") - hb := flag.Int("hb", 0, "client heartbeat") flag.Usage = func() { fmt.Printf(usage) } @@ -79,7 +76,7 @@ func main() { fmt.Printf("server %s\n", *server) fmt.Printf("target %s\n", *target) - c, err := pingtunnel.NewClient(*listen, *server, *target, *timeout, *sproto, *rproto, *hb) + c, err := pingtunnel.NewClient(*listen, *server, *target, *timeout, *sproto, *rproto) if err != nil { fmt.Printf("ERROR: %s\n", err.Error()) return