File tree Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,19 @@ impl DriaP2PClient {
232
232
peer_id,
233
233
info,
234
234
..
235
- } ) ) => self . handle_identify_event ( peer_id, info) ,
235
+ } ) ) => {
236
+ if info. protocol_version != self . protocol . identity {
237
+ log:: warn!(
238
+ "Identify: Peer {} has different Identify protocol: (them {}, you {})" ,
239
+ peer_id,
240
+ info. protocol_version,
241
+ self . protocol. identity
242
+ ) ;
243
+
244
+ // disconnect them
245
+ let _ = self . swarm . disconnect_peer_id ( peer_id) ;
246
+ }
247
+ }
236
248
237
249
/*****************************************
238
250
* Connection events and errors handling *
@@ -337,23 +349,4 @@ impl DriaP2PClient {
337
349
event => log:: debug!( "Unhandled Swarm Event: {:?}" , event) ,
338
350
}
339
351
}
340
-
341
- /// Handles identify events.
342
- ///
343
- /// At the top level, we check the protocol string.
344
- ///
345
- /// - For Kademlia, we check the kademlia protocol and then add the address to the Kademlia routing table.
346
- fn handle_identify_event ( & mut self , peer_id : PeerId , info : identify:: Info ) {
347
- if info. protocol_version != self . protocol . identity {
348
- log:: warn!(
349
- "Identify: Peer {} has different Identify protocol: (them {}, you {})" ,
350
- peer_id,
351
- info. protocol_version,
352
- self . protocol. identity
353
- ) ;
354
-
355
- // disconnect them
356
- let _ = self . swarm . disconnect_peer_id ( peer_id) ;
357
- }
358
- }
359
352
}
You can’t perform that action at this time.
0 commit comments