Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
30 changes: 16 additions & 14 deletions iroh/src/magicsock/node_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use serde::{Deserialize, Serialize};
use stun_rs::TransactionId;
use tracing::{debug, info, instrument, trace, warn};

use self::{
best_addr::ClearReason,
node_state::{NodeState, Options, PingHandled},
};
use self::node_state::{NodeState, Options, PingHandled};
use super::{metrics::Metrics, ActorMessage, DiscoMessageSource, NodeIdMappedAddr};
#[cfg(any(test, feature = "test-utils"))]
use crate::endpoint::PathSelection;
Expand All @@ -23,9 +20,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 +196,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 +273,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 +325,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,24 +386,28 @@ 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(), now, "matches our local addr")
}
}

/// 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, now: Instant, why: &'static str) {
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, now, why);
if node.direct_addresses().count() == 0 {
let node_id = node.public_key();
let mapped_addr = node.quic_mapped_addr();
self.by_node_key.remove(node_id);
self.by_quic_mapped_addr.remove(mapped_addr);
debug!(node_id=%node_id.fmt_short(), ?reason, "removing node");
debug!(node_id=%node_id.fmt_short(), why, "removing node");
entry.remove();
}
}
Expand Down Expand Up @@ -852,7 +854,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