Skip to content

Commit 71d77c2

Browse files
authored
Merge fa1fa7b into 36842d5
2 parents 36842d5 + fa1fa7b commit 71d77c2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

iroh/src/magicsock.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,8 +1879,13 @@ impl Actor {
18791879
continue;
18801880
};
18811881
let is_major = state.is_major_change(&current_netmon_state);
1882+
event!(
1883+
target: "iroh::_events::link_change",
1884+
Level::DEBUG,
1885+
?state,
1886+
is_major
1887+
);
18821888
current_netmon_state = state;
1883-
trace!("tick: link change {}", is_major);
18841889
self.msock.metrics.magicsock.actor_link_change.inc();
18851890
self.handle_network_change(is_major).await;
18861891
}
@@ -1912,11 +1917,11 @@ impl Actor {
19121917
}
19131918

19141919
async fn handle_network_change(&mut self, is_major: bool) {
1915-
debug!("link change detected: major? {}", is_major);
1920+
debug!(is_major, "link change detected");
19161921

19171922
if is_major {
19181923
if let Err(err) = self.network_change_sender.rebind() {
1919-
warn!("failed to rebind transports: {:?}", err);
1924+
warn!("failed to rebind transports: {err:?}");
19201925
}
19211926

19221927
#[cfg(not(wasm_browser))]

iroh/src/magicsock/node_map/node_state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,22 @@ impl NodeState {
294294
let (best_addr, relay_url) = match self.udp_paths.send_addr(have_ipv6) {
295295
UdpSendAddr::Valid(addr) => {
296296
// If we have a valid address we use it.
297-
trace!(%addr, "UdpSendAddr is valid, use it");
297+
trace!(%addr, ?have_ipv6, "UdpSendAddr is valid, use it");
298298
(Some(*addr), None)
299299
}
300300
UdpSendAddr::Outdated(addr) => {
301301
// If the address is outdated we use it, but send via relay at the same time.
302302
// We also send disco pings so that it will become valid again if it still
303303
// works (i.e. we don't need to holepunch again).
304-
trace!(%addr, "UdpSendAddr is outdated, use it together with relay");
304+
trace!(%addr, ?have_ipv6, "UdpSendAddr is outdated, use it together with relay");
305305
(Some(*addr), self.relay_url())
306306
}
307307
UdpSendAddr::Unconfirmed(addr) => {
308-
trace!(%addr, "UdpSendAddr is unconfirmed, use it together with relay");
308+
trace!(%addr, ?have_ipv6, "UdpSendAddr is unconfirmed, use it together with relay");
309309
(Some(*addr), self.relay_url())
310310
}
311311
UdpSendAddr::None => {
312-
trace!("No UdpSendAddr, use relay");
312+
trace!(?have_ipv6, "No UdpSendAddr, use relay");
313313
(None, self.relay_url())
314314
}
315315
};

iroh/src/magicsock/node_map/udp_paths.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ impl NodeUdpPaths {
132132
/// Returns the current UDP address to send on.
133133
pub(super) fn send_addr(&self, have_ipv6: bool) -> &UdpSendAddr {
134134
if !have_ipv6 {
135+
// If it's a valid address, it doesn't matter if our interface scan determined that we
136+
// "probably" don't have IPv6, because we clearly were able to send and receive a ping/pong over IPv6.
137+
if matches!(&self.best, UdpSendAddr::Valid(_)) {
138+
return &self.best;
139+
}
135140
return &self.best_ipv4;
136141
}
137142
&self.best

0 commit comments

Comments
 (0)