Skip to content

Commit b5b6b88

Browse files
author
pseusys
committed
reformat
1 parent c0ffcc1 commit b5b6b88

4 files changed

Lines changed: 10 additions & 34 deletions

File tree

typhoon/src/flow/client.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static> ClientFlowM
7070
}
7171

7272
impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static> ProbeFlowSender for ClientFlowManager<T, AE> {
73-
fn send_raw<'a>(
74-
&'a self,
75-
packet: DynamicByteBuffer,
76-
_target: SocketAddr,
77-
) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>> {
73+
fn send_raw<'a>(&'a self, packet: DynamicByteBuffer, _target: SocketAddr) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>> {
7874
Box::pin(async move { self.sock.send(packet).await.map(|_| ()) })
7975
}
8076
}
@@ -110,7 +106,7 @@ impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static> FlowManager
110106

111107
{
112108
let mut lock = self.receive_internal.lock().await;
113-
match lock.process_incoming(notified_packet.unwrap(), self.settings.pool())? {
109+
match lock.process_incoming(notified_packet, self.settings.pool())? {
114110
ProcessIncomingResult::Valid(result) => return Ok(result),
115111
ProcessIncomingResult::Decoy => continue,
116112
ProcessIncomingResult::Unexpected(pkt) => {

typhoon/src/flow/common.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,14 @@ impl<CP: FlowCryptoProvider> FlowReceiveInternal<CP> {
140140
Ok(()) => {}
141141
Err(err) => {
142142
warn!("client flow: tailor verification failed: {err}");
143-
return Ok(ProcessIncomingResult::Unexpected(
144-
encrypted_packet.expand_end(encrypted_tailor_len),
145-
));
143+
return Ok(ProcessIncomingResult::Unexpected(encrypted_packet.expand_end(encrypted_tailor_len)));
146144
}
147145
}
148146
tailor
149147
}
150148
Err(err) => {
151149
warn!("client flow: tailor decryption failed: {err}");
152-
return Ok(ProcessIncomingResult::Unexpected(
153-
encrypted_packet.expand_end(encrypted_tailor_len),
154-
));
150+
return Ok(ProcessIncomingResult::Unexpected(encrypted_packet.expand_end(encrypted_tailor_len)));
155151
}
156152
},
157153
Err(err) => return Err(FlowControllerError::MissingCache(err)),
@@ -163,8 +159,6 @@ impl<CP: FlowCryptoProvider> FlowReceiveInternal<CP> {
163159
}
164160

165161
let payload_len = tailor.payload_length() as usize;
166-
Ok(ProcessIncomingResult::Valid(
167-
encrypted_packet.rebuffer_start(encrypted_packet.len() - payload_len).expand_end(full_tailor_len),
168-
))
162+
Ok(ProcessIncomingResult::Valid(encrypted_packet.rebuffer_start(encrypted_packet.len() - payload_len).expand_end(full_tailor_len)))
169163
}
170164
}

typhoon/src/flow/probe.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ use crate::utils::sync::AsyncExecutor;
2323
/// `ClientFlowManager` (forwards to `send` on the connected socket, ignoring `target`).
2424
pub trait ProbeFlowSender: Send + Sync {
2525
/// Send `packet` as raw bytes to `target`, bypassing all TYPHOON framing.
26-
fn send_raw<'a>(
27-
&'a self,
28-
packet: DynamicByteBuffer,
29-
target: SocketAddr,
30-
) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>>;
26+
fn send_raw<'a>(&'a self, packet: DynamicByteBuffer, target: SocketAddr) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>>;
3127
}
3228

3329
/// Handler for packets the flow manager could not identify (active probing protection).

typhoon/src/flow/server.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ impl<T: IdentityType + Clone + Eq + Hash + Send + ToString + 'static, AE: AsyncE
151151
Ok(result) => result,
152152
Err(err) => {
153153
warn!("server flow: tailor decryption failed from {source_addr}: {err}");
154-
self.probe_handler.lock().await.process(
155-
encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr),
156-
).await;
154+
self.probe_handler.lock().await.process(encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr)).await;
157155
continue;
158156
}
159157
};
@@ -162,9 +160,7 @@ impl<T: IdentityType + Clone + Eq + Hash + Send + ToString + 'static, AE: AsyncE
162160
let identity = tailor.identity();
163161
if let Err(err) = crypto.verify_tailor(&identity, transcript).await {
164162
debug!("error verifying packet tailor: {err}");
165-
self.probe_handler.lock().await.process(
166-
encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr),
167-
).await;
163+
self.probe_handler.lock().await.process(encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr)).await;
168164
continue;
169165
}
170166
}
@@ -194,9 +190,7 @@ impl<T: IdentityType + Clone + Eq + Hash + Send + ToString + 'static, AE: AsyncE
194190
}
195191
} else {
196192
// Non-handshake, non-decoy packet from an unregistered user.
197-
self.probe_handler.lock().await.process(
198-
encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr),
199-
).await;
193+
self.probe_handler.lock().await.process(encrypted_packet.expand_end(identity_len + tailor_overhead), Some(source_addr)).await;
200194
continue;
201195
}
202196
}
@@ -226,11 +220,7 @@ impl<T: IdentityType + Clone + Eq + Hash + Send + ToString + 'static, AE: AsyncE
226220
}
227221

228222
impl<T: IdentityType + Clone + Eq + Hash + Send + ToString + 'static, AE: AsyncExecutor + 'static> ProbeFlowSender for ServerFlowManager<T, AE> {
229-
fn send_raw<'a>(
230-
&'a self,
231-
packet: DynamicByteBuffer,
232-
target: SocketAddr,
233-
) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>> {
223+
fn send_raw<'a>(&'a self, packet: DynamicByteBuffer, target: SocketAddr) -> Pin<Box<dyn Future<Output = Result<(), SocketError>> + Send + 'a>> {
234224
Box::pin(async move { self.socks[0].send_to(packet, target).await.map(|_| ()) })
235225
}
236226
}

0 commit comments

Comments
 (0)