mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Still working on timeouts
This commit is contained in:
@@ -7,7 +7,7 @@ use pnet::{
|
||||
ipnetwork::IpNetwork,
|
||||
};
|
||||
use tokio::task;
|
||||
use tokio::time::{Duration, sleep, timeout};
|
||||
use tokio::time::{Duration, Instant, sleep, timeout};
|
||||
|
||||
mod packet_send_receive;
|
||||
|
||||
@@ -55,17 +55,21 @@ pub async fn find(interface: &str) -> Vec<Device> {
|
||||
let send_interface = network_interface.clone();
|
||||
|
||||
println!("Starting sender");
|
||||
let start = Instant::now();
|
||||
|
||||
let send_result = timeout(
|
||||
Duration::from_secs(2),
|
||||
Duration::from_millis(10),
|
||||
send_packet(sender, send_interface, ipv4_net, mac),
|
||||
// test_timeout(),
|
||||
)
|
||||
.await;
|
||||
match send_result {
|
||||
Ok(_) => println!("Sender done"),
|
||||
Err(_) => println!("Sender timed out"),
|
||||
};
|
||||
println!(
|
||||
"Sender took {} millisecs",
|
||||
(Instant::now() - start).as_millis()
|
||||
);
|
||||
|
||||
// let receive_result = timeout(
|
||||
// Duration::from_secs(5),
|
||||
|
||||
@@ -45,10 +45,8 @@ pub async fn send_packet(
|
||||
ðernet_packet.to_immutable().packet(),
|
||||
Some(interface.clone()),
|
||||
);
|
||||
// thread::sleep(Duration::from_millis(2));
|
||||
}
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
// thread::sleep(Duration::from_millis(2));
|
||||
// sleep(Duration::from_millis(1)).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ mod device_finders;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let devices = device_finders::arp::find("eno1").await;
|
||||
let devices = device_finders::arp::find("wlp1s0").await;
|
||||
|
||||
for device in devices.iter() {
|
||||
println!("{}", device);
|
||||
|
||||
Reference in New Issue
Block a user