Skip to content

Commit e7be54d

Browse files
authored
chore: upgrade to the latest version of iroh-quinn-udp (#89)
- Upgrade to `iroh-quinn-udp` @ 0.8 - adjust rust-version/MSRV to 1.89
1 parent 8628222 commit e7be54d

10 files changed

Lines changed: 86 additions & 90 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
RUST_BACKTRACE: 1
1717
RUSTFLAGS: -Dwarnings
1818
RUSTDOCFLAGS: -Dwarnings
19-
MSRV: "1.85"
19+
MSRV: "1.89"
2020
SCCACHE_CACHE_SIZE: "10G"
2121
IROH_FORCE_STAGING_RELAYS: "1"
2222

Cargo.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netwatch/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["networking", "interfaces"]
1010
edition = "2024"
1111

1212
# Sadly this also needs to be updated in .github/workflows/ci.yml
13-
rust-version = "1.85"
13+
rust-version = "1.89"
1414

1515
[lints]
1616
workspace = true
@@ -34,7 +34,7 @@ tracing = "0.1"
3434

3535
# non-browser dependencies
3636
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
37-
quinn-udp = { package = "iroh-quinn-udp", version = "0.7" }
37+
quinn-udp = { package = "iroh-quinn-udp", version = "0.8" }
3838
libc = "0.2.139"
3939
netdev = "0.40.0"
4040
socket2 = { version = "0.6", features = ["all"] }

netwatch/src/interfaces.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ impl fmt::Display for State {
196196
ifaces.sort_by_key(|iface| iface.iface.index);
197197
for iface in ifaces {
198198
write!(f, "{iface}")?;
199-
if let Some(ref default_if) = self.default_route_interface {
200-
if iface.name() == default_if {
201-
write!(f, " (default)")?;
202-
}
199+
if let Some(ref default_if) = self.default_route_interface
200+
&& iface.name() == default_if
201+
{
202+
write!(f, " (default)")?;
203203
}
204204
if f.alternate() {
205205
writeln!(f)?;

netwatch/src/netmon/bsd.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,21 @@ pub(super) fn is_interesting_message(msg: &WireMessage) -> bool {
9292
WireMessage::InterfaceMulticastAddr(_) => true,
9393
WireMessage::Interface(_) => false,
9494
WireMessage::InterfaceAddr(msg) => {
95-
if let Some(addr) = msg.addrs.get(RTAX_IFP as usize) {
96-
if let Some(name) = addr.name() {
97-
if !is_interesting_interface(name) {
98-
return false;
99-
}
100-
}
95+
if let Some(addr) = msg.addrs.get(RTAX_IFP as usize)
96+
&& let Some(name) = addr.name()
97+
&& !is_interesting_interface(name)
98+
{
99+
return false;
101100
}
102101
true
103102
}
104103
WireMessage::Route(msg) => {
105104
// Ignore local unicast
106-
if let Some(addr) = msg.addrs.get(RTAX_DST as usize) {
107-
if let Some(ip) = addr.ip() {
108-
if is_link_local(ip) {
109-
return false;
110-
}
111-
}
105+
if let Some(addr) = msg.addrs.get(RTAX_DST as usize)
106+
&& let Some(ip) = addr.ip()
107+
&& is_link_local(ip)
108+
{
109+
return false;
112110
}
113111

114112
true

netwatch/src/udp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -841,16 +841,16 @@ impl SocketState {
841841

842842
impl Drop for UdpSocket {
843843
fn drop(&mut self) {
844-
if let Some((socket, _)) = self.socket.write().unwrap().close() {
845-
if let Ok(handle) = tokio::runtime::Handle::try_current() {
846-
// No wakeup after dropping write lock here, since we're getting dropped.
847-
// this will be empty if `close` was called before
848-
let std_sock = socket.into_std();
849-
handle.spawn_blocking(move || {
850-
// Calls libc::close, which can block
851-
drop(std_sock);
852-
});
853-
}
844+
if let Some((socket, _)) = self.socket.write().unwrap().close()
845+
&& let Ok(handle) = tokio::runtime::Handle::try_current()
846+
{
847+
// No wakeup after dropping write lock here, since we're getting dropped.
848+
// this will be empty if `close` was called before
849+
let std_sock = socket.into_std();
850+
handle.spawn_blocking(move || {
851+
// Calls libc::close, which can block
852+
drop(std_sock);
853+
});
854854
}
855855
}
856856
}

portmapper/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/n0-computer/net-tools"
1010
keywords = ["portmapping", "pmp", "pcp", "upnp"]
1111

1212
# Sadly this also needs to be updated in .github/workflows/ci.yml
13-
rust-version = "1.85"
13+
rust-version = "1.89"
1414

1515
[lints]
1616
workspace = true

portmapper/src/current_mapping.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,27 @@ impl<M: Mapping> CurrentMapping<M> {
135135
deadline,
136136
expire_after,
137137
}) = &mut self.mapping
138+
&& deadline.as_mut().poll(cx).is_ready()
138139
{
139-
if deadline.as_mut().poll(cx).is_ready() {
140-
let (external_ip, external_port) = mapping.external();
141-
// check if the deadline means the mapping is expired or due for renewal
142-
return if *expire_after {
143-
trace!("mapping expired {mapping:?}");
144-
self.update(None);
145-
Poll::Ready(Event::Expired {
146-
external_ip,
147-
external_port,
148-
})
149-
} else {
150-
// mapping is due for renewal
151-
*deadline = Box::pin(time::sleep(mapping.half_lifetime()));
152-
*expire_after = true;
153-
trace!("due for renewal {mapping:?}");
154-
Poll::Ready(Event::Renew {
155-
external_ip,
156-
external_port,
157-
})
158-
};
159-
}
140+
let (external_ip, external_port) = mapping.external();
141+
// check if the deadline means the mapping is expired or due for renewal
142+
return if *expire_after {
143+
trace!("mapping expired {mapping:?}");
144+
self.update(None);
145+
Poll::Ready(Event::Expired {
146+
external_ip,
147+
external_port,
148+
})
149+
} else {
150+
// mapping is due for renewal
151+
*deadline = Box::pin(time::sleep(mapping.half_lifetime()));
152+
*expire_after = true;
153+
trace!("due for renewal {mapping:?}");
154+
Poll::Ready(Event::Renew {
155+
external_ip,
156+
external_port,
157+
})
158+
};
160159
}
161160
Poll::Pending
162161
}

portmapper/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ impl Service {
488488

489489
/// Clears the current mapping and releases it.
490490
async fn invalidate_mapping(&mut self) {
491-
if let Some(old_mapping) = self.current_mapping.update(None) {
492-
if let Err(e) = old_mapping.release().await {
493-
debug!("failed to release mapping {e}");
494-
}
491+
if let Some(old_mapping) = self.current_mapping.update(None)
492+
&& let Err(e) = old_mapping.release().await
493+
{
494+
debug!("failed to release mapping {e}");
495495
}
496496
}
497497

portmapper/src/upnp.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ impl Mapping {
9797

9898
// if we are trying to get a specific external port, try this first. If this fails, default
9999
// to try to get any port
100-
if let Some(external_port) = preferred_port {
101-
if gateway
100+
if let Some(external_port) = preferred_port
101+
&& gateway
102102
.add_port(
103103
protocol,
104104
external_port.into(),
@@ -108,14 +108,13 @@ impl Mapping {
108108
)
109109
.await
110110
.is_ok()
111-
{
112-
return Ok(Mapping {
113-
protocol,
114-
gateway,
115-
external_ip,
116-
external_port,
117-
});
118-
}
111+
{
112+
return Ok(Mapping {
113+
protocol,
114+
gateway,
115+
external_ip,
116+
external_port,
117+
});
119118
}
120119

121120
let external_port = gateway

0 commit comments

Comments
 (0)