From a86efc015ab0427e999bf65f89e1716c0de82f64 Mon Sep 17 00:00:00 2001 From: rzuasti Date: Wed, 28 Jan 2026 17:57:59 -0500 Subject: [PATCH] Changed send/receive logic to be sequential rather than parallel (its faster) --- examples/sample_oott.toml | 4 ++-- src/device_finders/arp.rs | 47 +++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/examples/sample_oott.toml b/examples/sample_oott.toml index c6bdf2b..b92998f 100644 --- a/examples/sample_oott.toml +++ b/examples/sample_oott.toml @@ -8,9 +8,9 @@ interface = "eno1" # Network interface to use for scans level = "info" # off, error, warn, info, debug, trace [timings] -wait_between_scans="15m" # Wait time between scans. This does not include the scan time +wait_between_scans="10m" # Wait time between scans. This does not include the scan time arp_sender_timeout="1m" # If the ARP sender process takes longer than this it will be stopped (for a class C network - 254 IPs - it should take less than a minute) -arp_scan_duration="30s" # How long to wait for response packets on each scan (5m to 10m is a good timeframe for a class B or C network) +arp_scan_duration="10m" # How long to wait for response packets on each scan (5m to 10m is a good timeframe for a class B or C network) [notifications] method="pushover" # For now just pushover, you can set this to "none" to avoid sending notifications (it will just log) diff --git a/src/device_finders/arp.rs b/src/device_finders/arp.rs index 7d74d08..336811a 100644 --- a/src/device_finders/arp.rs +++ b/src/device_finders/arp.rs @@ -95,34 +95,27 @@ pub async fn find(interface: String) -> Result, String> { String::from(DurationString::from(receiver_timeout)) ); - if sender_timeout >= scan_duration { - warn!( - "OOTT_ARP_SENDER_TIMEOUT ({}) needs to be smaller than OOTT_ARP_SCAN_DURATION ({}).", - CONFIG.timings.arp_sender_timeout, CONFIG.timings.arp_scan_duration - ); - return Err(format!( - "OOTT_ARP_SENDER_TIMEOUT ({}) needs to be smaller than OOTT_ARP_SCAN_DURATION ({}).", - CONFIG.timings.arp_sender_timeout, CONFIG.timings.arp_scan_duration - ) - .to_string()); - } + let result_send = timeout( + sender_timeout, + send_packet(sender, send_interface, ipv4_net, mac), + ) + .await; - let result = tokio::join!( - timeout( - sender_timeout, - send_packet(sender, send_interface, ipv4_net, mac), - ), - timeout( - receiver_timeout, - listen_for_packets(receiver, ipv4_net, scan_duration), - ) - ); - - match result { - (Ok(_), Ok(_)) => info!("ARP sender and receiver done"), - (Err(_), _) => warn!("ARP sender timed out. Consider increasing its duration."), - (_, Err(_)) => info!("ARP receiver timed out"), + match result_send { + Ok(_) => info!("ARP sender done."), + Err(_) => warn!("ARP sender timed out. Consider increasing its duration."), }; - Ok(result.1.unwrap_or(Vec::new())) + let result_receive = timeout( + receiver_timeout, + listen_for_packets(receiver, ipv4_net, scan_duration), + ) + .await; + + match result_receive { + Ok(_) => info!("ARP receiver done."), + Err(_) => info!("ARP receiver timed out."), + }; + + Ok(result_receive.unwrap_or(Vec::new())) }