@@ -450,6 +450,8 @@ pub struct DropPeer {
450
450
pub reason : DropReason ,
451
451
/// The address of the peer to drop
452
452
pub address : PeerAddress ,
453
+ /// The port of the peer to drop
454
+ pub port : u16 ,
453
455
/// The subsystem source that is dropping the peer
454
456
pub source : DropSource ,
455
457
}
@@ -459,6 +461,7 @@ impl From<&DropNeighbor> for DropPeer {
459
461
DropPeer {
460
462
reason : drop_neighbor. reason . clone ( ) ,
461
463
address : drop_neighbor. key . addrbytes ,
464
+ port : drop_neighbor. key . port ,
462
465
source : drop_neighbor. source . clone ( ) ,
463
466
}
464
467
}
@@ -1739,6 +1742,7 @@ impl PeerNetwork {
1739
1742
1740
1743
disconnect. push ( DropPeer {
1741
1744
address : neighbor_key. addrbytes ,
1745
+ port : neighbor_key. port ,
1742
1746
reason : DropReason :: BannedConnection ,
1743
1747
source : DropSource :: PeerNetwork ,
1744
1748
} ) ;
@@ -2087,14 +2091,15 @@ impl PeerNetwork {
2087
2091
pub fn deregister_peer ( & mut self , peer : DropPeer ) {
2088
2092
let reason = peer. reason ;
2089
2093
debug ! (
2090
- "{:?}: Disconnect peer {}" ,
2094
+ "{:?}: Disconnect peer {}:{} " ,
2091
2095
& self . local_peer,
2092
- peer. address. pretty_print( )
2096
+ peer. address. pretty_print( ) ,
2097
+ peer. port,
2093
2098
) ;
2094
2099
2095
2100
let mut nk_remove = vec ! [ ] ;
2096
2101
for ( neighbor_key, event_id) in self . events . iter ( ) {
2097
- if neighbor_key. addrbytes == peer. address {
2102
+ if neighbor_key. addrbytes == peer. address && neighbor_key . port == peer . port {
2098
2103
let pubkh = self
2099
2104
. get_p2p_convo ( * event_id)
2100
2105
. and_then ( |convo| convo. get_public_key_hash ( ) )
@@ -2166,6 +2171,7 @@ impl PeerNetwork {
2166
2171
reason,
2167
2172
address : neighbor. addrbytes ,
2168
2173
source,
2174
+ port : neighbor. port ,
2169
2175
} ) ;
2170
2176
}
2171
2177
@@ -2187,6 +2193,7 @@ impl PeerNetwork {
2187
2193
reason,
2188
2194
address : neighbor. addrbytes ,
2189
2195
source,
2196
+ port : neighbor. port ,
2190
2197
} ) ;
2191
2198
}
2192
2199
}
@@ -2466,6 +2473,7 @@ impl PeerNetwork {
2466
2473
if let Some ( convo) = convo {
2467
2474
to_remove. push ( DropPeer {
2468
2475
address : convo. peer_addrbytes ,
2476
+ port : convo. peer_port ,
2469
2477
reason : DropReason :: BrokenConnection ( format ! ( "Connection failed: {e}" ) ) ,
2470
2478
source : if ibd {
2471
2479
DropSource :: PeerNetworkInboundReadySocket
@@ -2487,6 +2495,7 @@ impl PeerNetwork {
2487
2495
if let Some ( convo) = convo {
2488
2496
to_remove. push ( DropPeer {
2489
2497
address : convo. peer_addrbytes ,
2498
+ port : convo. peer_port ,
2490
2499
reason : DropReason :: DeadConnection ( "Connection is no longer alive" . into ( ) ) ,
2491
2500
source : if ibd {
2492
2501
DropSource :: PeerNetworkInboundReadySocket
@@ -2598,6 +2607,7 @@ impl PeerNetwork {
2598
2607
) ;
2599
2608
to_remove. push ( DropPeer {
2600
2609
address : peer. nk . addrbytes ,
2610
+ port : peer. nk . port ,
2601
2611
reason : DropReason :: Unresponsive {
2602
2612
timeout : self . connection_opts . timeout ,
2603
2613
last_seen : peer. timestamp ,
@@ -2629,6 +2639,7 @@ impl PeerNetwork {
2629
2639
2630
2640
to_remove. push ( DropPeer {
2631
2641
address : convo. peer_addrbytes ,
2642
+ port : convo. peer_port ,
2632
2643
reason : DropReason :: Unresponsive {
2633
2644
timeout : self . connection_opts . timeout ,
2634
2645
last_seen : convo. peer_heartbeat . into ( ) ,
@@ -2651,6 +2662,7 @@ impl PeerNetwork {
2651
2662
2652
2663
to_remove. push ( DropPeer {
2653
2664
address : convo. peer_addrbytes ,
2665
+ port : convo. peer_port ,
2654
2666
reason : DropReason :: Unresponsive {
2655
2667
timeout : self . connection_opts . timeout ,
2656
2668
last_seen : convo. instantiated ,
@@ -2846,6 +2858,7 @@ impl PeerNetwork {
2846
2858
if let Some ( peer) = self . peers . get ( event_id) {
2847
2859
broken. push ( DropPeer {
2848
2860
address : peer. peer_addrbytes ,
2861
+ port : peer. peer_port ,
2849
2862
reason : DropReason :: BrokenConnection ( format ! (
2850
2863
"Relay handle broken: {e}"
2851
2864
) ) ,
@@ -2984,14 +2997,15 @@ impl PeerNetwork {
2984
2997
2985
2998
/// Disconnect from all peers
2986
2999
fn disconnect_all ( & mut self , reason : DropReason , source : DropSource ) {
2987
- let addresses : Vec < _ > = self
3000
+ let address_port_pairs : Vec < _ > = self
2988
3001
. peers
2989
3002
. values ( )
2990
- . map ( |convo| convo. peer_addrbytes )
3003
+ . map ( |convo| ( convo. peer_addrbytes , convo . peer_port ) )
2991
3004
. collect ( ) ;
2992
- for address in addresses {
3005
+ for ( address, port ) in address_port_pairs {
2993
3006
self . deregister_peer ( DropPeer {
2994
3007
address,
3008
+ port,
2995
3009
reason : reason. clone ( ) ,
2996
3010
source : source. clone ( ) ,
2997
3011
} ) ;
0 commit comments