Skip to content

Commit dfefed5

Browse files
committed
styling
1 parent 99354c6 commit dfefed5

8 files changed

Lines changed: 104 additions & 135 deletions

File tree

src/client/http/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pub mod models;
21
pub mod cache;
32
mod handlers;
3+
pub mod models;
44
pub mod server;
55

66
// Re-export commonly used types
7-
pub use models::*;
7+
pub use models::*;

src/client/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use clap::Parser;
22

3-
mod relay;
3+
pub mod http;
44
pub mod main;
5-
mod prettylog;
65
pub mod p2p;
7-
pub mod http;
6+
mod prettylog;
7+
mod relay;
88

99
/// Default P2P UDP port for client-to-client direct connections
1010
///
@@ -51,4 +51,4 @@ pub struct Args {
5151
#[cfg(target_os = "linux")]
5252
#[arg(long)]
5353
pub masq: bool,
54-
}
54+
}

src/client/p2p/peer.rs

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -376,18 +376,16 @@ impl PeerHandler {
376376
match frame {
377377
Frame::ProbeIPv6(probe) => {
378378
tracing::info!(
379-
"Received probe ipv6 from peer {} at {}",
380-
probe.identity,
381-
remote
379+
"Received probe ipv6 from peer {} at {remote}",
380+
probe.identity
382381
);
383382
self.peers
384383
.update_peer_active(&probe.identity, remote, Protocol::Ipv6);
385384
}
386385
Frame::ProbeHolePunch(probe) => {
387386
tracing::info!(
388-
"Received probe hole punch from peer {} at {}",
389-
probe.identity,
390-
remote
387+
"Received probe hole punch from peer {} at {remote}",
388+
probe.identity
391389
);
392390
self.peers
393391
.update_peer_active(&probe.identity, remote, Protocol::Stun);
@@ -439,13 +437,11 @@ impl PeerHandler {
439437
SendResult::Success => return Ok(()),
440438
SendResult::Expired(elapsed) => {
441439
tracing::debug!(
442-
"IPv6 connection to {} expired ({:?} ago), trying STUN",
443-
peer_identity,
444-
elapsed
440+
"IPv6 connection to {peer_identity} expired ({elapsed:?} ago), trying STUN"
445441
);
446442
}
447443
SendResult::NeverResponded => {
448-
tracing::debug!("Peer {} IPv6 never responded, trying STUN", peer_identity);
444+
tracing::debug!("Peer {peer_identity} IPv6 never responded, trying STUN");
449445
}
450446
SendResult::NoAddress => {
451447
// No IPv6 address, try STUN
@@ -466,17 +462,13 @@ impl PeerHandler {
466462
{
467463
SendResult::Success => Ok(()),
468464
SendResult::Expired(elapsed) => Err(anyhow::anyhow!(
469-
"Peer {} STUN connection also expired ({:?} ago)",
470-
peer_identity,
471-
elapsed
465+
"Peer {peer_identity} STUN connection also expired ({elapsed:?} ago)"
472466
)),
473467
SendResult::NeverResponded => Err(anyhow::anyhow!(
474-
"Peer {} STUN address never responded",
475-
peer_identity
468+
"Peer {peer_identity} STUN address never responded"
476469
)),
477470
SendResult::NoAddress => Err(anyhow::anyhow!(
478-
"Failed to send to peer {}: IPv6 unavailable/expired, STUN unavailable/expired",
479-
peer_identity
471+
"Failed to send to peer {peer_identity}: IPv6 unavailable/expired, STUN unavailable/expired"
480472
)),
481473
}
482474
}
@@ -510,16 +502,11 @@ impl PeerHandler {
510502
// Connection is valid, send the packet
511503
match outbound_tx.send((data.to_vec(), vec![addr])).await {
512504
Ok(_) => {
513-
tracing::debug!(
514-
"Sent frame to peer {} via {}: {}",
515-
peer_identity,
516-
protocol,
517-
addr
518-
);
505+
tracing::debug!("Sent frame to peer {peer_identity} via {protocol}: {addr}");
519506
SendResult::Success
520507
}
521508
Err(e) => {
522-
tracing::error!("Failed to send via {}: {}", protocol, e);
509+
tracing::error!("Failed to send via {protocol}: {e}");
523510
SendResult::NeverResponded // Treat send error as connection problem
524511
}
525512
}
@@ -571,22 +558,17 @@ async fn send_probes(
571558
let probe_data = match Parser::marshal(probe_frame, block.as_ref().as_ref()) {
572559
Ok(data) => data,
573560
Err(e) => {
574-
tracing::error!("Failed to marshal {} probe: {}", protocol, e);
561+
tracing::error!("Failed to marshal {protocol} probe: {e}");
575562
return;
576563
}
577564
};
578565

579566
// Send to all peers
580567
let peer_addrs_display = format!("{peer_addrs:?}");
581568
if let Err(e) = outbound_tx.send((probe_data.clone(), peer_addrs)).await {
582-
tracing::warn!(
583-
"Failed to send {} probe to {}: {:?}",
584-
protocol,
585-
peer_addrs_display,
586-
e
587-
);
569+
tracing::warn!("Failed to send {protocol} probe to {peer_addrs_display}: {e:?}");
588570
} else {
589-
tracing::info!("Sent {} probe to {:?}", protocol, peer_addrs_display);
571+
tracing::info!("Sent {protocol} probe to {peer_addrs_display:?}");
590572
}
591573
}
592574

@@ -597,7 +579,7 @@ fn parse_address(identity: &str, ip: &str, port: u16) -> Option<SocketAddr> {
597579
let ip = match ip.parse::<IpAddr>() {
598580
Ok(ip) => ip,
599581
Err(e) => {
600-
tracing::warn!("Invalid address for peer {}: {}", identity, e);
582+
tracing::warn!("Invalid address for peer {identity}: {e}");
601583
return None;
602584
}
603585
};
@@ -614,13 +596,11 @@ fn update_address(peer: &mut PeerMeta, new_addr: SocketAddr, protocol: Protocol)
614596

615597
if old_addr != Some(new_addr) {
616598
tracing::info!(
617-
"Update {} address for peer {}: {} -> {}",
618-
protocol,
599+
"Update {protocol} address for peer {}: {} -> {new_addr}",
619600
peer.identity,
620601
old_addr
621602
.map(|a| a.to_string())
622603
.unwrap_or_else(|| "None".to_string()),
623-
new_addr
624604
);
625605

626606
let new_addr = LastActive::dormant(Some(new_addr));

0 commit comments

Comments
 (0)