Skip to content

Commit 9d795d3

Browse files
Merge remote-tracking branch 'origin/main' into feat-multipath
2 parents e0f10ce + b7e5bb0 commit 9d795d3

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed

iroh-base/src/relay_url.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,22 @@ use url::Url;
66

77
/// A URL identifying a relay server.
88
///
9-
/// It is cheaply clonable, as the underlying type is wrapped into an `Arc`.
10-
/// The main type under the hood though is [`Url`], with a few custom tweaks:
11-
///
12-
/// - A relay URL is never a relative URL, so an implicit `.` is added at the end of the
13-
/// domain name if missing.
14-
///
15-
/// - [`fmt::Debug`] is implemented so it prints the URL rather than the URL struct fields.
16-
/// Useful when logging e.g. `Option<RelayUrl>`.
9+
/// It is cheaply clonable, as the underlying type is wrapped into an `Arc`. The main type
10+
/// under the hood though is [`Url`].
1711
///
1812
/// To create a [`RelayUrl`] use the `From<Url>` implementation.
13+
///
14+
/// It is encouraged to use a fully-qualified DNS domain name in the URL. Meaning a DNS
15+
/// name which ends in a `.`, e.g, in `relay.example.com.`. Otherwise the DNS resolution of
16+
/// your local host or network could interpret the DNS name as relative and in some
17+
/// configurations might cause additional delays or even connection problems.
1918
#[derive(
2019
Clone, derive_more::Display, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
2120
)]
2221
pub struct RelayUrl(Arc<Url>);
2322

2423
impl From<Url> for RelayUrl {
25-
fn from(mut url: Url) -> Self {
26-
if let Some(domain) = url.domain() {
27-
if !domain.ends_with('.') {
28-
let domain = String::from(domain) + ".";
29-
30-
// This can fail, though it is unlikely the resulting URL is usable as a
31-
// relay URL, probably it has the wrong scheme or is not a base URL or the
32-
// like. We don't do full URL validation however, so just silently leave
33-
// this bad URL in place. Something will fail later.
34-
url.set_host(Some(&domain)).ok();
35-
}
36-
}
24+
fn from(url: Url) -> Self {
3725
Self(Arc::new(url))
3826
}
3927
}
@@ -105,24 +93,24 @@ mod tests {
10593
fn test_relay_url_debug_display() {
10694
let url = RelayUrl::from(Url::parse("https://example.com").unwrap());
10795

108-
assert_eq!(format!("{url:?}"), r#"RelayUrl("https://example.com./")"#);
96+
assert_eq!(format!("{url:?}"), r#"RelayUrl("https://example.com/")"#);
10997

110-
assert_eq!(format!("{url}"), "https://example.com./");
98+
assert_eq!(format!("{url}"), "https://example.com/");
11199
}
112100

113101
#[test]
114102
fn test_relay_url_absolute() {
115103
let url = RelayUrl::from(Url::parse("https://example.com").unwrap());
116104

117-
assert_eq!(url.domain(), Some("example.com."));
105+
assert_eq!(url.domain(), Some("example.com"));
118106

119107
let url1 = RelayUrl::from(Url::parse("https://example.com.").unwrap());
120-
assert_eq!(url, url1);
108+
assert_eq!(url1.domain(), Some("example.com."));
121109

122110
let url2 = RelayUrl::from(Url::parse("https://example.com./").unwrap());
123-
assert_eq!(url, url2);
111+
assert_eq!(url2.domain(), Some("example.com."));
124112

125113
let url3 = RelayUrl::from(Url::parse("https://example.com/").unwrap());
126-
assert_eq!(url, url3);
114+
assert_eq!(url3.domain(), Some("example.com"));
127115
}
128116
}

iroh/bench/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl EndpointSelector {
9393
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
9494
EndpointSelector::Quinn(endpoint) => {
9595
endpoint.close(0u32.into(), b"");
96+
endpoint.wait_idle().await;
9697
}
9798
}
9899
}

iroh/src/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl Endpoint {
809809
}
810810

811811
/// Returns the current [`EndpointAddr`].
812-
/// As long as the endpoint was able to binde to a network interfaces, some
812+
/// As long as the endpoint was able to bind to a network interface, some
813813
/// local addresses will be available.
814814
///
815815
/// The state of other fields depends on the state of networking and connectivity.

iroh/src/magicsock/metrics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ pub struct Metrics {
7777
pub connection_handshake_success: Counter,
7878
/// Number of connections with a successful handshake that became direct.
7979
pub connection_became_direct: Counter,
80+
/// Histogram of connection latency in milliseconds across all endpoint connections.
81+
#[default(Histogram::new(vec![1.0, 5.0, 10.0, 25.0, 50.0, 100.0, 250.0, 500.0, 1000.0, f64::INFINITY]))]
82+
pub connection_latency_ms: Histogram,
8083

8184
/*
8285
* Path Congestion Metrics

iroh/src/magicsock/transports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Transports {
8080
msock: &MagicSock,
8181
) -> Poll<io::Result<usize>> {
8282
debug_assert_eq!(bufs.len(), metas.len(), "non matching bufs & metas");
83-
if msock.is_closed() {
83+
if msock.is_closing() {
8484
return Poll::Pending;
8585
}
8686

0 commit comments

Comments
 (0)