add
This commit is contained in:
parent
a8ea8a358a
commit
50fb2fdb4e
11
client.go
11
client.go
@ -156,6 +156,15 @@ func (p *Client) Accept() error {
|
|||||||
|
|
||||||
func (p *Client) processPacket(packet *Packet) {
|
func (p *Client) processPacket(packet *Packet) {
|
||||||
|
|
||||||
|
if packet.msgType == PING {
|
||||||
|
t := time.Time{}
|
||||||
|
t.UnmarshalBinary(packet.data)
|
||||||
|
d := time.Now().Sub(t)
|
||||||
|
fmt.Printf("pong from %s %s %d\n", packet.src.String(), d.String(), packet.rproto)
|
||||||
|
sendICMP(*p.conn, packet.src, "", "", (uint32)(DATA), packet.data, packet.rproto, 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("processPacket %s %s %d\n", packet.id, packet.src.String(), len(packet.data))
|
fmt.Printf("processPacket %s %s %d\n", packet.id, packet.src.String(), len(packet.data))
|
||||||
|
|
||||||
clientConn := p.localIdToConnMap[packet.id]
|
clientConn := p.localIdToConnMap[packet.id]
|
||||||
@ -205,5 +214,5 @@ func (p *Client) ping() {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
b, _ := now.MarshalBinary()
|
b, _ := now.MarshalBinary()
|
||||||
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(PING), b, p.sproto, p.rproto)
|
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(PING), b, p.sproto, p.rproto)
|
||||||
fmt.Printf("ping %s %s\n", p.addrServer, now.String())
|
fmt.Printf("ping %s %s %d %d\n", p.addrServer, now.String(), p.sproto, p.rproto)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func (p *Server) processPacket(packet *Packet) {
|
|||||||
if packet.msgType == PING {
|
if packet.msgType == PING {
|
||||||
t := time.Time{}
|
t := time.Time{}
|
||||||
t.UnmarshalBinary(packet.data)
|
t.UnmarshalBinary(packet.data)
|
||||||
fmt.Printf("pong from %s %s\n", packet.src.String(), t.String())
|
fmt.Printf("ping from %s %s %d\n", packet.src.String(), t.String(), packet.rproto)
|
||||||
sendICMP(*p.conn, packet.src, "", "", (uint32)(DATA), packet.data, packet.rproto, 0)
|
sendICMP(*p.conn, packet.src, "", "", (uint32)(DATA), packet.data, packet.rproto, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user