Skip to content

Commit

Permalink
massive fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed Nov 8, 2024
1 parent 5c58e93 commit 3457409
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 70 deletions.
3 changes: 1 addition & 2 deletions iroh-net/bench/src/iroh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use iroh_net::{
endpoint::{Connection, ConnectionError, RecvStream, SendStream, TransportConfig},
Endpoint, NodeAddr,
};
use tracing::{trace, warn};

use iroh_relay::{RelayMap, RelayMode, RelayUrl};
use tracing::{trace, warn};

use crate::{
client_handler, stats::TransferResult, ClientStats, ConnectionSelector, EndpointSelector, Opt,
Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/defaults.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Default values used in [`iroh-net`][`crate`]

use url::Url;

use iroh_relay::{RelayMap, RelayNode};
use url::Url;

/// The default STUN port used by the Relay server.
///
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use std::{
};

use anyhow::{anyhow, bail, ensure, Context, Result};
use iroh_relay::RelayUrl;
use serde::{Deserialize, Serialize};
use url::Url;

use super::key::PublicKey;
use crate::key;
use iroh_relay::RelayUrl;

// TODO: custom magicn
/// The 6 byte header of all discovery messages.
Expand Down
4 changes: 2 additions & 2 deletions iroh-net/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ mod tests {
time::SystemTime,
};

use iroh_relay::RelayMode;
use parking_lot::Mutex;
use rand::Rng;
use tokio_util::task::AbortOnDropHandle;

use super::*;
use crate::key::SecretKey;
use iroh_relay::RelayMode;

#[derive(Debug, Clone, Default)]
struct TestDiscoveryShared {
Expand Down Expand Up @@ -732,6 +732,7 @@ mod test_dns_pkarr {

use anyhow::Result;
use iroh_base::key::SecretKey;
use iroh_relay::{RelayMap, RelayMode};
use tokio_util::task::AbortOnDropHandle;

use crate::{
Expand All @@ -744,7 +745,6 @@ mod test_dns_pkarr {
},
AddrInfo, Endpoint, NodeAddr,
};
use iroh_relay::{RelayMap, RelayMode};

const PUBLISH_TIMEOUT: Duration = Duration::from_secs(10);

Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/discovery/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

use anyhow::Result;
use futures_lite::stream::Boxed as BoxStream;
use iroh_relay::force_staging_infra;

use crate::{
discovery::{Discovery, DiscoveryItem},
dns::ResolverExt,
Endpoint, NodeId,
};

use iroh_relay::force_staging_infra;

/// The n0 testing DNS node origin, for production.
pub const N0_DNS_NODE_ORIGIN_PROD: &str = "dns.iroh.link";
/// The n0 testing DNS node origin, for testing.
Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/discovery/pkarr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use std::sync::Arc;

use anyhow::{anyhow, bail, Result};
use futures_util::stream::BoxStream;
use iroh_relay::force_staging_infra;
use pkarr::SignedPacket;
use tokio::{
task::JoinHandle,
Expand All @@ -64,8 +65,6 @@ use crate::{
AddrInfo, Endpoint, NodeId,
};

use iroh_relay::force_staging_infra;

#[cfg(feature = "discovery-pkarr-dht")]
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "discovery-pkarr-dht")))]
pub mod dht;
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{
use anyhow::{anyhow, bail, Context, Result};
use derive_more::Debug;
use futures_lite::{Stream, StreamExt};
use iroh_relay::{force_staging_infra, RelayMode, RelayUrl};
use pin_project::pin_project;
use tokio_util::sync::{CancellationToken, WaitForCancellationFuture};
use tracing::{debug, instrument, trace, warn};
Expand All @@ -38,7 +39,6 @@ use crate::{
magicsock::{self, Handle, QuicMappedAddr},
tls, NodeId,
};
use iroh_relay::{force_staging_infra, RelayMode, RelayUrl};

mod rtt_actor;

Expand Down
4 changes: 2 additions & 2 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use futures_lite::{FutureExt, Stream, StreamExt};
use futures_util::stream::BoxStream;
use iroh_base::key::NodeId;
use iroh_metrics::{inc, inc_by};
use iroh_relay::{protos::stun, RelayMap, RelayUrl};
use netwatch::{interfaces, ip::LocalAddresses, netmon};
use quinn::AsyncUdpSocket;
use rand::{seq::SliceRandom, Rng, SeedableRng};
Expand Down Expand Up @@ -67,7 +68,6 @@ use crate::{
key::{PublicKey, SecretKey, SharedSecret},
netcheck, AddrInfo,
};
use iroh_relay::{protos::stun, RelayMap, RelayUrl};

mod metrics;
mod node_map;
Expand Down Expand Up @@ -2778,13 +2778,13 @@ impl NetInfo {
#[cfg(test)]
mod tests {
use anyhow::Context;
use iroh_relay::RelayMode;
use iroh_test::CallOnDrop;
use rand::RngCore;
use tokio_util::task::AbortOnDropHandle;

use super::*;
use crate::{defaults::staging::EU_RELAY_HOSTNAME, tls, Endpoint};
use iroh_relay::RelayMode;

const ALPN: &[u8] = b"n0/test/1";

Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/magicsock/node_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
use futures_lite::stream::Stream;
use iroh_base::key::NodeId;
use iroh_metrics::inc;
use iroh_relay::RelayUrl;
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use stun_rs::TransactionId;
Expand All @@ -27,7 +28,6 @@ use crate::{
key::PublicKey,
NodeAddr,
};
use iroh_relay::RelayUrl;

mod best_addr;
mod node_state;
Expand Down
4 changes: 1 addition & 3 deletions iroh-net/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
};

use iroh_metrics::inc;
use iroh_relay::{protos::stun, RelayUrl};
use netwatch::ip::is_unicast_link_local;
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc;
Expand All @@ -27,9 +28,6 @@ use crate::{
NodeAddr, NodeId,
};

use iroh_relay::protos::stun;
use iroh_relay::RelayUrl;

/// Number of addresses that are not active that we keep around per node.
///
/// See [`NodeState::prune_direct_addresses`].
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/magicsock/node_map/path_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use std::{
};

use iroh_base::key::NodeId;
use iroh_relay::protos::stun;
use tracing::{debug, event, Level};

use super::{
node_state::{ControlMsg, PongReply, SESSION_ACTIVE_TIMEOUT},
IpPort, PingRole, Source,
};
use crate::{disco::SendAddr, magicsock::HEARTBEAT_INTERVAL};
use iroh_relay::protos::stun;

/// The minimum time between pings to an endpoint.
///
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use anyhow::Context;
use backoff::backoff::Backoff;
use bytes::{Bytes, BytesMut};
use iroh_metrics::{inc, inc_by};
use iroh_relay::{self as relay, client::ClientError, ReceivedMessage, RelayUrl, MAX_PACKET_SIZE};
use tokio::{
sync::{mpsc, oneshot},
task::{JoinHandle, JoinSet},
Expand All @@ -20,7 +21,6 @@ use tracing::{debug, info, info_span, trace, warn, Instrument};

use super::{ActorMessage, MagicSock, Metrics as MagicsockMetrics, RelayContents};
use crate::key::{NodeId, PUBLIC_KEY_LENGTH};
use iroh_relay::{self as relay, client::ClientError, ReceivedMessage, RelayUrl, MAX_PACKET_SIZE};

/// How long a non-home relay connection needs to be idle (last written to) before we close it.
const RELAY_INACTIVE_CLEANUP_TIME: Duration = Duration::from_secs(60);
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Co-locating all of the iroh-net metrics structs
pub use portmapper::Metrics as PortmapMetrics;

pub use crate::{magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics};
#[cfg(feature = "iroh-relay")]
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "iroh-relay")))]
pub use iroh_relay::server::Metrics as RelayMetrics;
pub use portmapper::Metrics as PortmapMetrics;

pub use crate::{magicsock::Metrics as MagicsockMetrics, netcheck::Metrics as NetcheckMetrics};
5 changes: 2 additions & 3 deletions iroh-net/src/netcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use anyhow::{anyhow, Context as _, Result};
use bytes::Bytes;
use hickory_resolver::TokioAsyncResolver as DnsResolver;
use iroh_metrics::inc;
use iroh_relay::{protos::stun, RelayMap, RelayUrl};
use netwatch::{IpFamily, UdpSocket};
use tokio::{
sync::{self, mpsc, oneshot},
Expand All @@ -25,8 +26,6 @@ use tokio::{
use tokio_util::{sync::CancellationToken, task::AbortOnDropHandle};
use tracing::{debug, error, info_span, trace, warn, Instrument};

use iroh_relay::{protos::stun, RelayMap, RelayUrl};

mod metrics;
mod reportgen;

Expand Down Expand Up @@ -773,6 +772,7 @@ mod tests {
use std::net::Ipv4Addr;

use bytes::BytesMut;
use iroh_relay::RelayNode;
use tokio::time;
use tracing::info;

Expand All @@ -781,7 +781,6 @@ mod tests {
defaults::{staging::EU_RELAY_HOSTNAME, DEFAULT_STUN_PORT},
ping::Pinger,
};
use iroh_relay::RelayNode;

mod stun_utils {
//! Utils for testing that expose a simple stun server.
Expand Down
4 changes: 1 addition & 3 deletions iroh-net/src/netcheck/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::{

use anyhow::{anyhow, bail, Context, Result};
use iroh_metrics::inc;
use iroh_relay::{http::RELAY_PROBE_PATH, protos::stun, RelayMap, RelayNode, RelayUrl};
use netwatch::{interfaces, UdpSocket};
use rand::seq::IteratorRandom;
use tokio::{
Expand All @@ -46,9 +47,6 @@ use crate::{
util::MaybeFuture,
};

use iroh_relay::protos::stun;
use iroh_relay::{http::RELAY_PROBE_PATH, RelayMap, RelayNode, RelayUrl};

mod hairpin;
mod probes;

Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/netcheck/reportgen/hairpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};

use anyhow::{bail, Context, Result};
use iroh_relay::protos::stun;
use netwatch::UdpSocket;
use tokio::{sync::oneshot, time::Instant};
use tokio_util::task::AbortOnDropHandle;
Expand All @@ -25,8 +26,6 @@ use crate::{
netcheck::{self, reportgen, Inflight},
};

use iroh_relay::protos::stun;

/// Handle to the hairpin actor.
///
/// Dropping it will abort the actor.
Expand Down
3 changes: 1 addition & 2 deletions iroh-net/src/netcheck/reportgen/probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
use std::{collections::BTreeSet, fmt, sync::Arc};

use anyhow::{ensure, Result};
use iroh_relay::{RelayMap, RelayNode, RelayUrl};
use netwatch::interfaces;
use tokio::time::Duration;

use crate::netcheck::Report;

use iroh_relay::{RelayMap, RelayNode, RelayUrl};

/// The retransmit interval used when netcheck first runs.
///
/// We have no past context to work with, and we want answers relatively quickly, so it's
Expand Down
7 changes: 3 additions & 4 deletions iroh-net/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ use std::net::Ipv4Addr;
use anyhow::Result;
pub use dns_and_pkarr_servers::DnsPkarrServer;
pub use dns_server::create_dns_resolver;
use tokio::sync::oneshot;

use crate::defaults::DEFAULT_STUN_PORT;

use iroh_relay::{
server::{CertConfig, RelayConfig, Server, ServerConfig, StunConfig, TlsConfig},
RelayMap, RelayNode, RelayUrl,
};
use tokio::sync::oneshot;

use crate::defaults::DEFAULT_STUN_PORT;

/// A drop guard to clean up test infrastructure.
///
Expand Down
4 changes: 1 addition & 3 deletions iroh-relay/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ use crate::{
defaults::timeouts::*,
http::{Protocol, RELAY_PATH},
protos::relay::DerpCodec,
RelayUrl,
util, RelayUrl,
};

use crate::util;

pub(crate) mod conn;
pub(crate) mod streams;

Expand Down
6 changes: 2 additions & 4 deletions iroh-relay/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub const DEFAULT_METRICS_PORT: u16 = 9090;
pub mod prod {
use url::Url;

use crate::{RelayMap, RelayNode};

use super::*;
use crate::{RelayMap, RelayNode};

/// Hostname of the default NA relay.
pub const NA_RELAY_HOSTNAME: &str = "use1-1.relay.iroh.network.";
Expand Down Expand Up @@ -89,9 +88,8 @@ pub mod prod {
pub mod staging {
use url::Url;

use crate::{RelayMap, RelayNode};

use super::*;
use crate::{RelayMap, RelayNode};

/// Hostname of the default NA relay.
pub const NA_RELAY_HOSTNAME: &str = "staging-use1-1.relay.iroh.network.";
Expand Down
6 changes: 3 additions & 3 deletions iroh-relay/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use std::{

use anyhow::{anyhow, bail, Context as _, Result};
use clap::Parser;
use iroh_relay::defaults::{
DEFAULT_HTTPS_PORT, DEFAULT_HTTP_PORT, DEFAULT_METRICS_PORT, DEFAULT_STUN_PORT,
use iroh_relay::{
defaults::{DEFAULT_HTTPS_PORT, DEFAULT_HTTP_PORT, DEFAULT_METRICS_PORT, DEFAULT_STUN_PORT},
server as relay,
};
use iroh_relay::server as relay;
use serde::{Deserialize, Serialize};
use tokio_rustls_acme::{caches::DirCache, AcmeConfig};
use tracing::debug;
Expand Down
4 changes: 1 addition & 3 deletions iroh-relay/src/protos/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures_lite::{Stream, StreamExt};
use futures_sink::Sink;
use futures_util::SinkExt;
use iroh_base::key::{Signature, PUBLIC_KEY_LENGTH};
use iroh_base::key::{PublicKey, SecretKey, Signature, PUBLIC_KEY_LENGTH};
use postcard::experimental::max_size::MaxSize;
use serde::{Deserialize, Serialize};
use tokio_util::codec::{Decoder, Encoder};

use iroh_base::key::{PublicKey, SecretKey};

/// The maximum size of a packet sent over relay.
/// (This only includes the data bytes visible to magicsock, not
/// including its on-wire framing overhead)
Expand Down
Loading

0 comments on commit 3457409

Please sign in to comment.