Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iroh-net): Ensure netcheck finishes once it has results #2027

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all 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
21 changes: 14 additions & 7 deletions iroh-net/src/netcheck/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ struct Actor {
last_report: Option<Arc<Report>>,
/// The portmapper client, if there is one.
port_mapper: Option<portmapper::Client>,
/// Whether the actor should try to reach things other than localhost.
///
/// This is set to true in tests to avoid probing the local LAN's router etc.
///
/// TODO: currently this only skips the portmapper, but still does STUN, HTTP and ICMP
/// probes. Furthermore none of our tests actually use this feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, just delete it, we can bring it back if we ever need to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, fair enough. i'll do that in a separate PR though.

skip_external_network: bool,
/// The DERP configuration.
derp_map: DerpMap,
Expand Down Expand Up @@ -266,7 +272,6 @@ impl Actor {
self.report.portmap_probe = pm;
port_mapping.inner = None;
self.outstanding_tasks.port_mapper = false;
trace!("portmapper future done");
}

// Check for probes finishing.
Expand Down Expand Up @@ -418,10 +423,11 @@ impl Actor {
// duration of the slowest derp. For initial ones, double that.
let enough_derps = std::cmp::min(self.derp_map.len(), ENOUGH_NODES);
if self.report.derp_latency.len() == enough_derps {
let mut timeout = self.report.derp_latency.max_latency();
if !self.incremental {
timeout *= 2;
}
let timeout = self.report.derp_latency.max_latency();
let timeout = match self.incremental {
true => timeout,
false => timeout * 2,
};
let reportcheck = self.addr();
debug!(
reports=self.report.derp_latency.len(),
Expand Down Expand Up @@ -474,12 +480,13 @@ impl Actor {
/// Stops further probes.
///
/// This makes sure that no further probes are run and also cancels the captive portal
/// task if there were successful probes. Be sure to only handle this after all the
/// required [`ProbeReport`]s have been processed.
/// and portmapper tasks if there were successful probes. Be sure to only handle this
/// after all the required [`ProbeReport`]s have been processed.
fn handle_abort_probes(&mut self) {
trace!("handle abort probes");
self.outstanding_tasks.probes = false;
if self.report.udp {
self.outstanding_tasks.port_mapper = false;
self.outstanding_tasks.captive_task = false;
}
}
Expand Down
Loading