Skip to content

Commit 57ddad7

Browse files
committed
style: format code
1 parent 07818d1 commit 57ddad7

File tree

10 files changed

+43
-41
lines changed

10 files changed

+43
-41
lines changed

asport-client/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ mod default {
262262
vec![b"asport".to_vec()]
263263
}
264264
}
265-
266265
}
267266

268267
pub fn network() -> Network {

asport-client/src/connection/mod.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ use crate::{
3838
};
3939

4040
use self::{authenticated::Authenticated, udp_session::UdpSession};
41-
use asport_common::buffer_pool::BufferPool;
4241
use crate::utils::SecurityType;
42+
use asport_common::buffer_pool::BufferPool;
4343
use quinn_hyphae::helper::hyphae_endpoint_config;
4444
use quinn_hyphae::{HandshakeBuilder, RustCryptoBackend, HYPHAE_H_V1_QUIC_V1_VERSION};
4545

@@ -169,7 +169,8 @@ impl Connection {
169169
_ => EndpointConfig::default(),
170170
};
171171

172-
let mut quinn_endpoint = QuinnEndpoint::new(ep_config, None, socket, Arc::new(TokioRuntime))?;
172+
let mut quinn_endpoint =
173+
QuinnEndpoint::new(ep_config, None, socket, Arc::new(TokioRuntime))?;
173174

174175
quinn_endpoint.set_default_client_config(config);
175176

@@ -214,14 +215,7 @@ impl Connection {
214215
}
215216

216217
pub async fn check() -> Result<(), Error> {
217-
let try_init_conn = async {
218-
ENDPOINT
219-
.get()
220-
.unwrap()
221-
.connect()
222-
.await
223-
.map(AsyncMutex::new)
224-
};
218+
let try_init_conn = async { ENDPOINT.get().unwrap().connect().await.map(AsyncMutex::new) };
225219

226220
let check_and_reconnect_conn = async {
227221
let mut conn = CONNECTION
@@ -468,9 +462,11 @@ impl Endpoint {
468462
SocketAddr::from((Ipv6Addr::UNSPECIFIED, 0))
469463
};
470464

471-
ep.rebind(UdpSocket::bind(bind_addr).map_err(|err| {
472-
Error::Socket("failed to create endpoint UDP socket", err)
473-
})?)
465+
ep.rebind(
466+
UdpSocket::bind(bind_addr).map_err(|err| {
467+
Error::Socket("failed to create endpoint UDP socket", err)
468+
})?,
469+
)
474470
.map_err(|err| Error::Socket("failed to rebind endpoint UDP socket", err))?;
475471
}
476472

asport-client/src/connection/udp_session.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl UdpSession {
108108
Ok(res) => {
109109
consecutive_errors = 0; // Reset error count on success
110110
res
111-
},
111+
}
112112
Err(err) => {
113113
consecutive_errors += 1;
114114
log::warn!(
@@ -123,7 +123,8 @@ impl UdpSession {
123123
}
124124

125125
// Exponential backoff for errors
126-
let backoff_ms = std::cmp::min(100 * (1 << consecutive_errors.min(6)), 5000);
126+
let backoff_ms =
127+
std::cmp::min(100 * (1 << consecutive_errors.min(6)), 5000);
127128
time::sleep(Duration::from_millis(backoff_ms as u64)).await;
128129
continue;
129130
}

asport-common/src/buffer_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::sync::Arc;
21
use parking_lot::Mutex;
2+
use std::sync::Arc;
33

44
/// A thread-safe buffer pool to avoid frequent allocations
55
pub struct BufferPool {

asport-common/src/config/serde.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use std::{
2-
fmt::Display,
3-
str::FromStr,
4-
sync::Arc,
5-
time::Duration,
6-
};
1+
use std::{fmt::Display, str::FromStr, sync::Arc, time::Duration};
72

83
use base64::{engine::general_purpose::STANDARD, Engine};
94
use humantime::Duration as HumanDuration;
@@ -28,9 +23,7 @@ where
2823
Ok(Arc::from(bytes.into_boxed_slice()))
2924
}
3025

31-
pub fn deserialize_from_base64_opt<'de, D>(
32-
deserializer: D,
33-
) -> Result<Option<Arc<[u8]>>, D::Error>
26+
pub fn deserialize_from_base64_opt<'de, D>(deserializer: D) -> Result<Option<Arc<[u8]>>, D::Error>
3427
where
3528
D: Deserializer<'de>,
3629
{

asport-quinn/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ struct KeyingMaterialExporter(QuinnConnection);
628628
impl KeyingMaterialExporterImpl for KeyingMaterialExporter {
629629
fn export_keying_material(&self, label: &[u8], context: &[u8]) -> [u8; 32] {
630630
let mut buf = [0; 32];
631-
self.0.export_keying_material(&mut buf, label, context).unwrap();
631+
self.0
632+
.export_keying_material(&mut buf, label, context)
633+
.unwrap();
632634
buf
633635
}
634636
}

asport-server/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ mod default {
252252
vec![b"asport".to_vec()]
253253
}
254254
}
255-
256255
}
257256
}
258257

asport-server/src/connection/handle_bind.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use crate::{
1717

1818
use super::{udp_sessions::UdpSessions, Connection};
1919

20-
static EPHEMERAL_PORTS: LazyLock<BTreeSet<u16>> = LazyLock::new(|| ephemeral_port_range().collect());
20+
static EPHEMERAL_PORTS: LazyLock<BTreeSet<u16>> =
21+
LazyLock::new(|| ephemeral_port_range().collect());
2122

2223
impl Connection {
2324
async fn bind_tcp(

asport-server/src/connection/udp_sessions.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::{
2+
collections::HashMap,
23
io::Error as IoError,
34
net::{IpAddr, SocketAddr},
45
sync::{
56
atomic::{AtomicU16, Ordering},
67
Arc,
78
},
8-
collections::HashMap,
99
time::{Duration, Instant},
1010
};
1111

@@ -42,7 +42,13 @@ struct UdpSessionsInner {
4242
}
4343

4444
impl UdpSessions {
45-
pub fn with_timeout(conn: Connection, socket: UdpSocket, max_pkt_size: usize, buffer_pool_size: usize, session_timeout: Duration) -> Self {
45+
pub fn with_timeout(
46+
conn: Connection,
47+
socket: UdpSocket,
48+
max_pkt_size: usize,
49+
buffer_pool_size: usize,
50+
session_timeout: Duration,
51+
) -> Self {
4652
let (tx, rx) = oneshot::channel();
4753
let assoc_id_addr_map = Arc::new(Mutex::new(bimap::BiMap::new()));
4854
let session_last_activity = Arc::new(Mutex::new(HashMap::new()));
@@ -93,9 +99,11 @@ impl UdpSessions {
9399
Some(assoc_id) => {
94100
let assoc_id = *assoc_id;
95101
// Update last activity time for existing session
96-
session_last_activity_listening.lock().insert(assoc_id, Instant::now());
102+
session_last_activity_listening
103+
.lock()
104+
.insert(assoc_id, Instant::now());
97105
assoc_id
98-
},
106+
}
99107
None => {
100108
// Find a free association ID with collision detection
101109
let mut attempts = 0;
@@ -118,7 +126,8 @@ impl UdpSessions {
118126
}
119127

120128
if attempts == u16::MAX {
121-
log::error!("[{id:#010x}] [{addr}] [{auth}] No available association IDs",
129+
log::error!(
130+
"[{id:#010x}] [{addr}] [{auth}] No available association IDs",
122131
id = session_listening.0.conn.id(),
123132
addr = session_listening.0.conn.inner.remote_address(),
124133
auth = session_listening.0.conn.auth,
@@ -132,7 +141,9 @@ impl UdpSessions {
132141
}
133142

134143
// Record activity time for new session
135-
session_last_activity_listening.lock().insert(assoc_id, Instant::now());
144+
session_last_activity_listening
145+
.lock()
146+
.insert(assoc_id, Instant::now());
136147

137148
assoc_id
138149
}
@@ -158,8 +169,10 @@ impl UdpSessions {
158169
gc_interval.tick().await;
159170
if let Err(err) = tokio::time::timeout(
160171
TokioDuration::from_secs(30),
161-
session_gc.cleanup_expired_sessions()
162-
).await {
172+
session_gc.cleanup_expired_sessions(),
173+
)
174+
.await
175+
{
163176
error_count += 1;
164177
log::warn!(
165178
"[{id:#010x}] [{addr}] [{auth}] GC task timeout or error (count: {error_count}): {err}",
@@ -294,4 +307,3 @@ impl UdpSessions {
294307
let _ = self.0.close.lock().take().unwrap().send(());
295308
}
296309
}
297-

asport-server/src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ pub fn load_priv_key<P: AsRef<Path>>(path: P) -> Result<PrivateKeyDer<'static>,
7575
Err(_) => {
7676
// If PEM parsing fails, try to read DER format
7777
if priv_key.is_none() {
78-
priv_key = Some(
79-
PrivateKeyDer::try_from(key_bytes).map_err(Error::InvalidPrivateKey)?,
80-
);
78+
priv_key =
79+
Some(PrivateKeyDer::try_from(key_bytes).map_err(Error::InvalidPrivateKey)?);
8180
}
8281
}
8382
}

0 commit comments

Comments
 (0)