Skip to content

Commit 1d9dcdf

Browse files
feat!: update to rust edition 2024
1 parent 0776687 commit 1d9dcdf

File tree

13 files changed

+608
-594
lines changed

13 files changed

+608
-594
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)", "cfg(iroh_l
4040

4141
[workspace.lints.clippy]
4242
unused-async = "warn"
43+
44+
45+
[patch.crates-io]
46+
portmapper = { git = "https://github.com/n0-computer/net-tools", branch = "deps-update" }
47+
netwatch = { git = "https://github.com/n0-computer/net-tools", branch = "deps-update" }

iroh-dns-server/src/store/signed_packets.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Actor {
151151
Message::Upsert { packet, res } => {
152152
let key = PublicKeyBytes::from_signed_packet(&packet);
153153
trace!("upsert {}", key);
154-
let replaced = if let Some(existing) = get_packet(&tables.signed_packets, &key)? {
154+
let replaced = match get_packet(&tables.signed_packets, &key)? { Some(existing) => {
155155
if existing.more_recent_than(&packet) {
156156
res.send(false).ok();
157157
continue;
@@ -160,9 +160,9 @@ impl Actor {
160160
tables.update_time.remove(&existing.timestamp().to_bytes(), key.as_bytes()).e()?;
161161
true
162162
}
163-
} else {
163+
} _ => {
164164
false
165-
};
165+
}};
166166
let value = packet.serialize();
167167
tables.signed_packets
168168
.insert(key.as_bytes(), &value[..]).e()?;
@@ -177,14 +177,14 @@ impl Actor {
177177
}
178178
Message::Remove { key, res } => {
179179
trace!("remove {}", key);
180-
let updated = if let Some(row) = tables.signed_packets.remove(key.as_bytes()).e()? {
180+
let updated = match tables.signed_packets.remove(key.as_bytes()).e()? { Some(row) => {
181181
let packet = SignedPacket::deserialize(row.value()).e()?;
182182
tables.update_time.remove(&packet.timestamp().to_bytes(), key.as_bytes()).e()?;
183183
self.metrics.store_packets_removed.inc();
184184
true
185-
} else {
185+
} _ => {
186186
false
187-
};
187+
}};
188188
res.send(updated).ok();
189189
}
190190
Message::Snapshot { res } => {
@@ -193,7 +193,7 @@ impl Actor {
193193
}
194194
Message::CheckExpired { key, time } => {
195195
trace!("check expired {} at {}", key, fmt_time(time));
196-
if let Some(packet) = get_packet(&tables.signed_packets, &key)? {
196+
match get_packet(&tables.signed_packets, &key)? { Some(packet) => {
197197
let expired = Timestamp::now() - expiry_us;
198198
if packet.timestamp() < expired {
199199
tables.update_time.remove(&time.to_bytes(), key.as_bytes()).e()?;
@@ -204,10 +204,10 @@ impl Actor {
204204
debug!("packet {key} is no longer expired, removing obsolete expiry entry");
205205
tables.update_time.remove(&time.to_bytes(), key.as_bytes()).e()?;
206206
}
207-
} else {
207+
} _ => {
208208
debug!("expired packet {key} not found, remove from expiry table");
209209
tables.update_time.remove(&time.to_bytes(), key.as_bytes()).e()?;
210-
}
210+
}}
211211
}
212212
}
213213
}

iroh-relay/src/server/http_server.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ impl RelayService {
518518
async move {
519519
match hyper::upgrade::on(&mut req).await {
520520
Ok(upgraded) => {
521-
if let Err(err) = this.0.relay_connection_handler(upgraded).await {
522-
warn!("error accepting upgraded connection: {err:#}",);
523-
} else {
524-
debug!("upgraded connection completed");
521+
match this.0.relay_connection_handler(upgraded).await {
522+
Err(err) => {
523+
warn!("error accepting upgraded connection: {err:#}",);
524+
}
525+
_ => {
526+
debug!("upgraded connection completed");
527+
}
525528
};
526529
}
527530
Err(err) => warn!("upgrade error: {err:#}"),

iroh-relay/src/server/streams.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ impl AsyncRead for MaybeTlsStream {
173173
buf: &mut tokio::io::ReadBuf<'_>,
174174
) -> Poll<std::io::Result<()>> {
175175
match &mut *self {
176-
MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_read(cx, buf),
177-
MaybeTlsStream::Tls(ref mut s) => Pin::new(s).poll_read(cx, buf),
176+
MaybeTlsStream::Plain(s) => Pin::new(s).poll_read(cx, buf),
177+
MaybeTlsStream::Tls(s) => Pin::new(s).poll_read(cx, buf),
178178
#[cfg(test)]
179-
MaybeTlsStream::Test(ref mut s) => Pin::new(s).poll_read(cx, buf),
179+
MaybeTlsStream::Test(s) => Pin::new(s).poll_read(cx, buf),
180180
}
181181
}
182182
}
@@ -187,10 +187,10 @@ impl AsyncWrite for MaybeTlsStream {
187187
cx: &mut Context<'_>,
188188
) -> Poll<std::result::Result<(), std::io::Error>> {
189189
match &mut *self {
190-
MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_flush(cx),
191-
MaybeTlsStream::Tls(ref mut s) => Pin::new(s).poll_flush(cx),
190+
MaybeTlsStream::Plain(s) => Pin::new(s).poll_flush(cx),
191+
MaybeTlsStream::Tls(s) => Pin::new(s).poll_flush(cx),
192192
#[cfg(test)]
193-
MaybeTlsStream::Test(ref mut s) => Pin::new(s).poll_flush(cx),
193+
MaybeTlsStream::Test(s) => Pin::new(s).poll_flush(cx),
194194
}
195195
}
196196

@@ -199,10 +199,10 @@ impl AsyncWrite for MaybeTlsStream {
199199
cx: &mut Context<'_>,
200200
) -> Poll<std::result::Result<(), std::io::Error>> {
201201
match &mut *self {
202-
MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_shutdown(cx),
203-
MaybeTlsStream::Tls(ref mut s) => Pin::new(s).poll_shutdown(cx),
202+
MaybeTlsStream::Plain(s) => Pin::new(s).poll_shutdown(cx),
203+
MaybeTlsStream::Tls(s) => Pin::new(s).poll_shutdown(cx),
204204
#[cfg(test)]
205-
MaybeTlsStream::Test(ref mut s) => Pin::new(s).poll_shutdown(cx),
205+
MaybeTlsStream::Test(s) => Pin::new(s).poll_shutdown(cx),
206206
}
207207
}
208208

@@ -212,10 +212,10 @@ impl AsyncWrite for MaybeTlsStream {
212212
buf: &[u8],
213213
) -> Poll<std::result::Result<usize, std::io::Error>> {
214214
match &mut *self {
215-
MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_write(cx, buf),
216-
MaybeTlsStream::Tls(ref mut s) => Pin::new(s).poll_write(cx, buf),
215+
MaybeTlsStream::Plain(s) => Pin::new(s).poll_write(cx, buf),
216+
MaybeTlsStream::Tls(s) => Pin::new(s).poll_write(cx, buf),
217217
#[cfg(test)]
218-
MaybeTlsStream::Test(ref mut s) => Pin::new(s).poll_write(cx, buf),
218+
MaybeTlsStream::Test(s) => Pin::new(s).poll_write(cx, buf),
219219
}
220220
}
221221

@@ -225,10 +225,10 @@ impl AsyncWrite for MaybeTlsStream {
225225
bufs: &[std::io::IoSlice<'_>],
226226
) -> Poll<std::result::Result<usize, std::io::Error>> {
227227
match &mut *self {
228-
MaybeTlsStream::Plain(ref mut s) => Pin::new(s).poll_write_vectored(cx, bufs),
229-
MaybeTlsStream::Tls(ref mut s) => Pin::new(s).poll_write_vectored(cx, bufs),
228+
MaybeTlsStream::Plain(s) => Pin::new(s).poll_write_vectored(cx, bufs),
229+
MaybeTlsStream::Tls(s) => Pin::new(s).poll_write_vectored(cx, bufs),
230230
#[cfg(test)]
231-
MaybeTlsStream::Test(ref mut s) => Pin::new(s).poll_write_vectored(cx, bufs),
231+
MaybeTlsStream::Test(s) => Pin::new(s).poll_write_vectored(cx, bufs),
232232
}
233233
}
234234
}

iroh/src/discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ impl DiscoverySubscribers {
699699
}
700700
}
701701

702-
pub(crate) fn subscribe(&self) -> impl Stream<Item = Result<DiscoveryItem, Lagged>> {
702+
pub(crate) fn subscribe(&self) -> impl Stream<Item = Result<DiscoveryItem, Lagged>> + use<> {
703703
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
704704
let recv = self.inner.subscribe();
705705
BroadcastStream::new(recv).map_err(|BroadcastStreamRecvError::Lagged(n)| Lagged { val: n })

iroh/src/discovery/pkarr.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,24 +353,27 @@ impl PublisherService {
353353
break; // disconnected
354354
};
355355
if let Some(info) = info {
356-
if let Err(err) = self.publish_current(info).await {
357-
failed_attempts += 1;
358-
// Retry after increasing timeout
359-
let retry_after = Duration::from_secs(failed_attempts);
360-
republish.as_mut().reset(Instant::now() + retry_after);
361-
warn!(
362-
err = %format!("{err:#}"),
363-
url = %self.pkarr_client.pkarr_relay_url ,
364-
?retry_after,
365-
%failed_attempts,
366-
"Failed to publish to pkarr",
367-
);
368-
} else {
369-
failed_attempts = 0;
370-
// Republish after fixed interval
371-
republish
372-
.as_mut()
373-
.reset(Instant::now() + self.republish_interval);
356+
match self.publish_current(info).await {
357+
Err(err) => {
358+
failed_attempts += 1;
359+
// Retry after increasing timeout
360+
let retry_after = Duration::from_secs(failed_attempts);
361+
republish.as_mut().reset(Instant::now() + retry_after);
362+
warn!(
363+
err = %format!("{err:#}"),
364+
url = %self.pkarr_client.pkarr_relay_url ,
365+
?retry_after,
366+
%failed_attempts,
367+
"Failed to publish to pkarr",
368+
);
369+
}
370+
_ => {
371+
failed_attempts = 0;
372+
// Republish after fixed interval
373+
republish
374+
.as_mut()
375+
.reset(Instant::now() + self.republish_interval);
376+
}
374377
}
375378
}
376379
// Wait until either the retry/republish timeout is reached, or the node info changed.

iroh/src/endpoint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ impl Endpoint {
908908
/// # }
909909
/// ```
910910
#[cfg(not(wasm_browser))]
911-
pub fn node_addr(&self) -> impl n0_watcher::Watcher<Value = Option<NodeAddr>> {
911+
pub fn node_addr(&self) -> impl n0_watcher::Watcher<Value = Option<NodeAddr>> + use<> {
912912
let watch_addrs = self.direct_addresses();
913913
let watch_relay = self.home_relay();
914914
let node_id = self.node_id();
@@ -973,7 +973,7 @@ impl Endpoint {
973973
/// let _relay_url = mep.home_relay().initialized().await.unwrap();
974974
/// # });
975975
/// ```
976-
pub fn home_relay(&self) -> impl n0_watcher::Watcher<Value = Vec<RelayUrl>> {
976+
pub fn home_relay(&self) -> impl n0_watcher::Watcher<Value = Vec<RelayUrl>> + use<> {
977977
self.msock.home_relay()
978978
}
979979

@@ -1043,7 +1043,7 @@ impl Endpoint {
10431043
/// # });
10441044
/// ```
10451045
#[doc(hidden)]
1046-
pub fn net_report(&self) -> impl Watcher<Value = Option<Report>> {
1046+
pub fn net_report(&self) -> impl Watcher<Value = Option<Report>> + use<> {
10471047
self.msock.net_report()
10481048
}
10491049

@@ -1086,7 +1086,7 @@ impl Endpoint {
10861086
/// connection was ever made or is even possible.
10871087
///
10881088
/// See also [`Endpoint::remote_info`] to only retrieve information about a single node.
1089-
pub fn remote_info_iter(&self) -> impl Iterator<Item = RemoteInfo> {
1089+
pub fn remote_info_iter(&self) -> impl Iterator<Item = RemoteInfo> + use<> {
10901090
self.msock.list_remote_infos().into_iter()
10911091
}
10921092

@@ -1114,7 +1114,7 @@ impl Endpoint {
11141114
///
11151115
/// [`MdnsDiscovery`]: crate::discovery::mdns::MdnsDiscovery
11161116
/// [`StaticProvider`]: crate::discovery::static_provider::StaticProvider
1117-
pub fn discovery_stream(&self) -> impl Stream<Item = Result<DiscoveryItem, Lagged>> {
1117+
pub fn discovery_stream(&self) -> impl Stream<Item = Result<DiscoveryItem, Lagged>> + use<> {
11181118
self.msock.discovery_subscribers().subscribe()
11191119
}
11201120

iroh/src/magicsock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl MagicSock {
280280
&self.ip_bind_addrs
281281
}
282282

283-
fn ip_local_addrs(&self) -> impl Iterator<Item = SocketAddr> {
283+
fn ip_local_addrs(&self) -> impl Iterator<Item = SocketAddr> + use<> {
284284
self.local_addr()
285285
.into_iter()
286286
.filter_map(|addr| addr.into_socket_addr())
@@ -336,7 +336,7 @@ impl MagicSock {
336336
///
337337
/// [`Watcher`]: n0_watcher::Watcher
338338
/// [`Watcher::initialized`]: n0_watcher::Watcher::initialized
339-
pub(crate) fn net_report(&self) -> impl Watcher<Value = Option<Report>> {
339+
pub(crate) fn net_report(&self) -> impl Watcher<Value = Option<Report>> + use<> {
340340
self.net_report
341341
.watch()
342342
.map(|(r, _)| r)
@@ -347,7 +347,7 @@ impl MagicSock {
347347
///
348348
/// Note that this can be used to wait for the initial home relay to be known using
349349
/// [`Watcher::initialized`].
350-
pub(crate) fn home_relay(&self) -> impl Watcher<Value = Vec<RelayUrl>> {
350+
pub(crate) fn home_relay(&self) -> impl Watcher<Value = Vec<RelayUrl>> + use<> {
351351
let res = self.local_addrs_watch.clone().map(|addrs| {
352352
addrs
353353
.into_iter()

iroh/src/magicsock/transports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
io::{self, IoSliceMut},
33
net::{IpAddr, Ipv6Addr, SocketAddr, SocketAddrV6},
44
pin::Pin,
5-
sync::{atomic::AtomicUsize, Arc},
5+
sync::{Arc, atomic::AtomicUsize},
66
task::{Context, Poll},
77
};
88

@@ -420,7 +420,7 @@ impl UdpSender {
420420
match destination {
421421
#[cfg(wasm_browser)]
422422
Addr::Ip(..) => {
423-
return Poll::Ready(Err(io::Error::other("IP is unsupported in browser")))
423+
return Poll::Ready(Err(io::Error::other("IP is unsupported in browser")));
424424
}
425425
#[cfg(not(wasm_browser))]
426426
Addr::Ip(addr) => {

0 commit comments

Comments
 (0)