From 30b1cd117b4e3eec33ff444509b8c1f07bb6801e Mon Sep 17 00:00:00 2001 From: esrrhs Date: Fri, 1 Nov 2019 18:44:15 +0800 Subject: [PATCH] add --- client.go | 8 ++++++++ server.go | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index ef145f9..73bb1d6 100644 --- a/client.go +++ b/client.go @@ -557,6 +557,7 @@ func (p *Client) processPacket(packet *Packet) { clientConn := p.getClientConnById(packet.my.Id) if clientConn == nil { loggo.Debug("processPacket no conn %s ", packet.my.Id) + p.remoteError(packet.my.Id) return } @@ -711,3 +712,10 @@ func (p *Client) deleteClientConn(uuid string, addr string) { p.localIdToConnMap.Delete(uuid) p.localAddrToConnMap.Delete(addr) } + +func (p *Client) remoteError(uuid string) { + sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, "", uuid, (uint32)(MyMsg_KICK), []byte{}, + SEND_PROTO, RECV_PROTO, p.key, + 0, 0, 0, 0, 0, 0, + 0) +} diff --git a/server.go b/server.go index b16267b..14ae603 100644 --- a/server.go +++ b/server.go @@ -114,6 +114,15 @@ func (p *Server) processPacket(packet *Packet) { return } + if packet.my.Type == (int32)(MyMsg_KICK) { + localConn := p.getServerConnById(packet.my.Id) + if localConn != nil { + p.close(localConn) + loggo.Info("remote kick local %s", packet.my.Id) + } + return + } + loggo.Debug("processPacket %s %s %d", packet.my.Id, packet.src.String(), len(packet.my.Data)) now := time.Now() @@ -491,7 +500,7 @@ func (p *Server) deleteServerConn(uuid string) { } func (p *Server) remoteError(uuid string, packet *Packet) { - sendICMP(packet.echoId, packet.echoSeq, *p.conn, packet.src, "", uuid, (uint32)(MyMsg_KICK), packet.my.Data, + sendICMP(packet.echoId, packet.echoSeq, *p.conn, packet.src, "", uuid, (uint32)(MyMsg_KICK), []byte{}, (int)(packet.my.Rproto), -1, p.key, 0, 0, 0, 0, 0, 0, 0)