@@ -4,7 +4,7 @@ use libp2p::swarm::{
4
4
dial_opts:: { DialOpts , PeerCondition } ,
5
5
SwarmEvent ,
6
6
} ;
7
- use libp2p:: { identify, noise, request_response, tcp, yamux} ;
7
+ use libp2p:: { autonat , identify, noise, request_response, tcp, yamux} ;
8
8
use libp2p:: { Multiaddr , PeerId , Swarm , SwarmBuilder } ;
9
9
use libp2p_identity:: Keypair ;
10
10
use std:: time:: Duration ;
@@ -90,6 +90,7 @@ impl DriaP2PClient {
90
90
91
91
// create p2p client itself
92
92
let ( reqres_tx, reqres_rx) = mpsc:: channel ( MSG_CHANNEL_BUFSIZE ) ;
93
+
93
94
let client = Self {
94
95
peer_id,
95
96
swarm,
@@ -241,17 +242,23 @@ impl DriaP2PClient {
241
242
} ) ) => self . handle_identify_event ( peer_id, info) ,
242
243
243
244
SwarmEvent :: NewListenAddr { address, .. } => {
244
- log:: warn!( "Local node is listening on {}" , address ) ;
245
+ log:: warn!( "Local node is listening on {address}" ) ;
245
246
}
246
247
SwarmEvent :: NewExternalAddrOfPeer { peer_id, address } => {
247
- log:: info!(
248
- "External address of peer {} confirmed: {}" ,
249
- peer_id,
250
- address
251
- ) ;
248
+ log:: info!( "External address of peer {peer_id} confirmed: {address}" ) ;
252
249
}
253
250
SwarmEvent :: ExternalAddrConfirmed { address } => {
254
- log:: info!( "External address confirmed: {}" , address) ;
251
+ log:: info!( "External address confirmed: {address}" ) ;
252
+ }
253
+
254
+ /*****************************************
255
+ * AutoNAT stuff *
256
+ *****************************************/
257
+ SwarmEvent :: Behaviour ( DriaBehaviourEvent :: Autonat ( autonat:: Event :: StatusChanged {
258
+ old,
259
+ new,
260
+ } ) ) => {
261
+ log:: info!( "AutoNAT status changed from {old:?} to {new:?}" ) ;
255
262
}
256
263
257
264
/*****************************************
@@ -303,7 +310,18 @@ impl DriaP2PClient {
303
310
) ;
304
311
}
305
312
306
- event => log:: trace!( "Unhandled Swarm Event: {:?}" , event) ,
313
+ SwarmEvent :: ExpiredListenAddr {
314
+ address,
315
+ listener_id,
316
+ } => {
317
+ log:: warn!( "Listener {listener_id} expired: {address}" ) ;
318
+ }
319
+
320
+ SwarmEvent :: ListenerError { listener_id, error } => {
321
+ log:: error!( "Listener {listener_id} error: {error}" ) ;
322
+ }
323
+
324
+ event => log:: debug!( "Unhandled Swarm Event: {:?}" , event) ,
307
325
}
308
326
}
309
327
@@ -313,6 +331,7 @@ impl DriaP2PClient {
313
331
///
314
332
/// - For Kademlia, we check the kademlia protocol and then add the address to the Kademlia routing table.
315
333
fn handle_identify_event ( & mut self , peer_id : PeerId , info : identify:: Info ) {
334
+ println ! ( "{}: {:?}" , peer_id, info. protocols) ;
316
335
// check identify protocol string
317
336
if info. protocol_version != self . protocol . identity {
318
337
log:: warn!(
0 commit comments