Skip to content

Commit 0898e86

Browse files
fix: satisfy gateway lint checks
1 parent db68372 commit 0898e86

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎crates/wsrx/src/cli/capture.rs‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ fn build_udp_packet(
242242
packet
243243
}
244244

245+
#[allow(clippy::chunks_exact_to_as_chunks)]
245246
fn ipv4_checksum(header: &[u8]) -> u16 {
246247
let mut sum = 0_u32;
247248
for word in header.chunks_exact(2) {
@@ -333,14 +334,14 @@ fn collect_pcaps(
333334
let path = entry.path();
334335
if path.is_dir() {
335336
collect_pcaps(&path, files)?;
336-
} else if path.extension().and_then(|value| value.to_str()) == Some("pcap") {
337-
if let Ok(metadata) = entry.metadata() {
338-
files.push((
339-
path,
340-
metadata.modified().unwrap_or(UNIX_EPOCH),
341-
metadata.len(),
342-
));
343-
}
337+
} else if path.extension().and_then(|value| value.to_str()) == Some("pcap")
338+
&& let Ok(metadata) = entry.metadata()
339+
{
340+
files.push((
341+
path,
342+
metadata.modified().unwrap_or(UNIX_EPOCH),
343+
metadata.len(),
344+
));
344345
}
345346
}
346347
Ok(())

‎crates/wsrx/src/cli/serve.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const CONNECT_TIMEOUT: Duration = Duration::from_secs(5);
4242
const CLEANUP_INTERVAL: Duration = Duration::from_secs(30);
4343

4444
/// Launch the platform tunnel gateway.
45+
#[allow(clippy::too_many_arguments)]
4546
pub async fn launch(
4647
host: Option<String>, port: Option<u16>, secret: Option<String>, state_file: Option<String>,
4748
allowed_target_hosts: Vec<String>, max_connections: usize, capture_root: Option<String>,
@@ -463,12 +464,12 @@ impl TunnelConnectionPermit {
463464

464465
impl Drop for TunnelConnectionPermit {
465466
fn drop(&mut self) {
466-
if let Ok(mut counts) = self.counts.lock() {
467-
if let Some(count) = counts.get_mut(&self.key) {
468-
*count = count.saturating_sub(1);
469-
if *count == 0 {
470-
counts.remove(&self.key);
471-
}
467+
if let Ok(mut counts) = self.counts.lock()
468+
&& let Some(count) = counts.get_mut(&self.key)
469+
{
470+
*count = count.saturating_sub(1);
471+
if *count == 0 {
472+
counts.remove(&self.key);
472473
}
473474
}
474475
}

0 commit comments

Comments
 (0)