Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
esrrhs committed Dec 20, 2018
1 parent 3ed77ca commit ab09358
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ func (p *Client) Run() {
interval := time.NewTicker(time.Second)
defer interval.Stop()

intervalPing := time.NewTicker(time.Second * 10)
defer interval.Stop()

for {
select {
case <-interval.C:
p.checkTimeoutConn()
p.showNet()
case <-intervalPing.C:
p.ping()
p.showNet()
case r := <-recv:
p.processPacket(r)
}
Expand Down Expand Up @@ -231,10 +227,12 @@ func (p *Client) checkTimeoutConn() {
}

func (p *Client) ping() {
now := time.Now()
b, _ := now.MarshalBinary()
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(PING), b, p.sproto, p.rproto)
fmt.Printf("ping %s %s %d %d\n", p.addrServer, now.String(), p.sproto, p.rproto)
if p.sendPacket == 0 && p.recvPacket == 0 {
now := time.Now()
b, _ := now.MarshalBinary()
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(PING), b, p.sproto, p.rproto)
fmt.Printf("ping %s %s %d %d\n", p.addrServer, now.String(), p.sproto, p.rproto)
}
}

func (p *Client) showNet() {
Expand Down

0 comments on commit ab09358

Please sign in to comment.