From edaa3d53b717f9bb58390d6c7e7c0128f40a5d82 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Thu, 15 Feb 2024 13:15:54 +0100 Subject: move interfaces to global const at the beginning of the main.rs --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1cb7b14..9ca4a5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,10 @@ use thiserror::Error; // * PPP Control Protocols (ID > 0x4000, see RFC 1661 section 2) const FILTER: &str = "arp or udp port 67 or udp port 68 or udp port 546 or udp port 547 or udp port 5060 or icmp or icmp6 or ether proto 0x8863 or (ether proto 0x8864 and ether[20:2] > 0x4000)"; +const DEVICES: &[&str] = &[ + "eth0", "eth0.10", "eth0.20", "eth0.30", "eth0.40", "eth1", "ppp0", +]; + const PPP_MAC_AC: &[u8] = &[0xcf, 0x72, 0x73, 0x00, 0x00, 0x01]; const PPP_MAC_HOST: &[u8] = &[0xcf, 0x72, 0x73, 0x00, 0x00, 0x02]; @@ -282,12 +286,8 @@ async fn main() -> Result<()> { packets: Arc::new(Mutex::new(HeapRb::new(PACKET_BUFFER_SIZE))), }; - let devices = [ - "eth0", "eth0.10", "eth0.20", "eth0.30", "eth0.40", "eth1", "ppp0", - ]; - - for device in devices { - if device == "any" { + for device in DEVICES { + if *device == "any" { continue; } @@ -305,7 +305,7 @@ async fn main() -> Result<()> { .expect("link waiting"); println!("[info] capture {}", device); - match capture(device.into(), server2.clone(), live_tx2.clone()).await { + match capture((*device).into(), server2.clone(), live_tx2.clone()).await { Ok(_) => {} Err(e) => println!("[fail] capture on {}: {}", device, e), } -- cgit v1.2.3