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

feat(iroh-net-report)!: add QUIC address discovery probes #3028

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions iroh-net-report/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ impl Client {
///
/// If these are not passed in this will bind sockets for STUN itself, though results
/// may not be as reliable.
///
/// The *quic_config* takes a [`QuicConfig`], a combination of a QUIC endpoint and
/// a client configuration that can be use for verifying the relay server connection.
/// When available, the report will attempt to get an observed public address
/// using QUIC address discovery.
///
/// When `None`, it will disable the QUIC address discovery probes.
pub async fn get_report(
&mut self,
dm: RelayMap,
Expand Down
13 changes: 9 additions & 4 deletions iroh-net-report/src/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,6 @@ async fn run_stun_probe(
}

/// Run a QUIC address discovery probe.
// TODO(ramfox): if this probe is aborted, then the connection will never be
// properly closed, possibly causing errors on the server.
async fn run_quic_probe(
quic_config: QuicConfig,
url: RelayUrl,
Expand All @@ -898,8 +896,15 @@ async fn run_quic_probe(
ProbeProto::QuicIpv6 => debug_assert!(relay_addr.is_ipv6()),
_ => debug_assert!(false, "wrong probe"),
}
// TODO(ramfox): what to put here if no host is given?
let host = url.host_str().unwrap_or("localhost");
let host = match url.host_str() {
Some(host) => host,
None => {
return Err(ProbeError::Error(
Copy link
Contributor

Choose a reason for hiding this comment

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

Hum, I believe this should be ProbeError::AbortSet? Why did you choose just this one? If the RelayUrl has no host none of the retries after a small delay will work either.

anyhow!("URL must have 'host' to use QUIC address discovery probes"),
probe.clone(),
));
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI this is a prime place for using the fancy new-ish syntax of let Some(host) = url.host_str() else { return ... }; Not important enough to follow up on though.

let quic_client = iroh_relay::quic::QuicClient::new(quic_config.ep, quic_config.client_config)
.map_err(|e| ProbeError::Error(e, probe.clone()))?;
let (addr, latency) = quic_client
Expand Down
4 changes: 2 additions & 2 deletions iroh-net-report/src/reportgen/probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ pub(super) enum Probe {
delay: Duration,
node: Arc<RelayNode>,
},
#[display("QUIC Address Discovery Ivp4 after {delay:?} to {node}")]
#[display("QAD Ipv4 after {delay:?} to {node}")]
QuicIpv4 {
delay: Duration,
node: Arc<RelayNode>,
},
#[display("QUIC Address Discovery Ivp6 after {delay:?} to {node}")]
#[display("QAD Ipv6 after {delay:?} to {node}")]
QuicIpv6 {
delay: Duration,
node: Arc<RelayNode>,
Expand Down
Loading