@@ -226,13 +226,18 @@ func (m *Me) dispatch(packet *head.Packet, addr p2p.EndPoint, index int, finish
226
226
}
227
227
switch packet .Proto {
228
228
case head .ProtoHello :
229
- n , err := p .WriteAndPut (head .NewPacket (head .ProtoHello , m .SrcPort (), p .peerip , m .DstPort (), nil ), false )
230
- if err == nil {
231
- if config .ShowDebugLog {
232
- logrus .Debugln ("[listen] @" , index , "send" , n , "bytes hello ack packet" )
229
+ switch {
230
+ case len (packet .Body ()) == 0 :
231
+ logrus .Warnln ("[listen] @" , index , "recv old hello packet, do nothing" )
232
+ case packet .Body ()[0 ] == byte (head .HelloPing ):
233
+ n , err := p .WriteAndPut (head .NewPacket (head .ProtoHello , m .SrcPort (), p .peerip , m .DstPort (), []byte {byte (head .HelloPong )}), false )
234
+ if err == nil {
235
+ logrus .Infoln ("[listen] @" , index , "recv hello, send" , n , "bytes hello ack packet" )
236
+ } else {
237
+ logrus .Errorln ("[listen] @" , index , "send hello ack packet error:" , err )
233
238
}
234
- } else {
235
- logrus .Errorln ("[listen] @" , index , "send hello ack packet error:" , err )
239
+ default :
240
+ logrus .Infoln ("[listen] @" , index , "recv hello ack packet, do nothing" )
236
241
}
237
242
packet .Put ()
238
243
case head .ProtoNotify :
0 commit comments