Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
RUSTDOCFLAGS: -Dwarnings
MSRV: "1.81"
SCCACHE_CACHE_SIZE: "10G"
IROH_FORCE_STAGING_RELAYS: "1"
# IROH_FORCE_STAGING_RELAYS: "1"

jobs:
tests:
Expand Down
25 changes: 15 additions & 10 deletions iroh/src/magicsock/node_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use stun_rs::TransactionId;
use tracing::{debug, info, instrument, trace, warn};

use self::{
best_addr::ClearReason,
node_state::{NodeState, Options, PingHandled},
path_validity::ClearReason,
};
use super::{metrics::Metrics, ActorMessage, DiscoMessageSource, NodeIdMappedAddr};
#[cfg(any(test, feature = "test-utils"))]
Expand All @@ -23,9 +23,9 @@ use crate::{
watchable::Watcher,
};

mod best_addr;
mod node_state;
mod path_state;
mod path_validity;
mod udp_paths;

pub use node_state::{ConnectionType, ControlMsg, DirectAddrInfo, RemoteInfo};
Expand Down Expand Up @@ -199,7 +199,7 @@ impl NodeMap {
.expect("poisoned")
.get_mut(NodeStateKey::Idx(id))
{
ep.ping_timeout(tx_id);
ep.ping_timeout(tx_id, Instant::now());
}
}

Expand Down Expand Up @@ -276,9 +276,10 @@ impl NodeMap {
}

pub(super) fn reset_node_states(&self) {
let now = Instant::now();
let mut inner = self.inner.lock().expect("poisoned");
for (_, ep) in inner.node_states_mut() {
ep.note_connectivity_change();
ep.note_connectivity_change(now);
}
}

Expand Down Expand Up @@ -327,7 +328,7 @@ impl NodeMap {
self.inner
.lock()
.expect("poisoned")
.on_direct_addr_discovered(discovered);
.on_direct_addr_discovered(discovered, Instant::now());
}
}

Expand Down Expand Up @@ -388,18 +389,22 @@ impl NodeMapInner {
}

/// Prunes direct addresses from nodes that claim to share an address we know points to us.
pub(super) fn on_direct_addr_discovered(&mut self, discovered: BTreeSet<SocketAddr>) {
pub(super) fn on_direct_addr_discovered(
&mut self,
discovered: BTreeSet<SocketAddr>,
now: Instant,
) {
for addr in discovered {
self.remove_by_ipp(addr.into(), ClearReason::MatchesOurLocalAddr)
self.remove_by_ipp(addr.into(), ClearReason::MatchesOurLocalAddr, now)
}
}

/// Removes a direct address from a node.
fn remove_by_ipp(&mut self, ipp: IpPort, reason: ClearReason) {
fn remove_by_ipp(&mut self, ipp: IpPort, reason: ClearReason, now: Instant) {
if let Some(id) = self.by_ip_port.remove(&ipp) {
if let Entry::Occupied(mut entry) = self.by_id.entry(id) {
let node = entry.get_mut();
node.remove_direct_addr(&ipp, reason);
node.remove_direct_addr(&ipp, reason, now);
if node.direct_addresses().count() == 0 {
let node_id = node.public_key();
let mapped_addr = node.quic_mapped_addr();
Expand Down Expand Up @@ -852,7 +857,7 @@ mod tests {
}

info!("Pruning addresses");
endpoint.prune_direct_addresses();
endpoint.prune_direct_addresses(Instant::now());

// Half the offline addresses should have been pruned. All the active and alive
// addresses should have been kept.
Expand Down
222 changes: 0 additions & 222 deletions iroh/src/magicsock/node_map/best_addr.rs

This file was deleted.

Loading
Loading