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,
|
ipnetwork::IpNetwork,
|
||||||
};
|
};
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
use tokio::time::{Duration, sleep, timeout};
|
use tokio::time::{Duration, Instant, sleep, timeout};
|
||||||
|
|
||||||
mod packet_send_receive;
|
mod packet_send_receive;
|
||||||
|
|
||||||
@@ -55,17 +55,21 @@ pub async fn find(interface: &str) -> Vec<Device> {
|
|||||||
let send_interface = network_interface.clone();
|
let send_interface = network_interface.clone();
|
||||||
|
|
||||||
println!("Starting sender");
|
println!("Starting sender");
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
let send_result = timeout(
|
let send_result = timeout(
|
||||||
Duration::from_secs(2),
|
Duration::from_millis(10),
|
||||||
send_packet(sender, send_interface, ipv4_net, mac),
|
send_packet(sender, send_interface, ipv4_net, mac),
|
||||||
// test_timeout(),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
match send_result {
|
match send_result {
|
||||||
Ok(_) => println!("Sender done"),
|
Ok(_) => println!("Sender done"),
|
||||||
Err(_) => println!("Sender timed out"),
|
Err(_) => println!("Sender timed out"),
|
||||||
};
|
};
|
||||||
|
println!(
|
||||||
|
"Sender took {} millisecs",
|
||||||
|
(Instant::now() - start).as_millis()
|
||||||
|
);
|
||||||
|
|
||||||
// let receive_result = timeout(
|
// let receive_result = timeout(
|
||||||
// Duration::from_secs(5),
|
// Duration::from_secs(5),
|
||||||
|
|||||||
@@ -45,10 +45,8 @@ pub async fn send_packet(
|
|||||||
ðernet_packet.to_immutable().packet(),
|
ðernet_packet.to_immutable().packet(),
|
||||||
Some(interface.clone()),
|
Some(interface.clone()),
|
||||||
);
|
);
|
||||||
// thread::sleep(Duration::from_millis(2));
|
|
||||||
}
|
}
|
||||||
sleep(Duration::from_secs(5)).await;
|
// sleep(Duration::from_millis(1)).await;
|
||||||
// thread::sleep(Duration::from_millis(2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ mod device_finders;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn 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() {
|
for device in devices.iter() {
|
||||||
println!("{}", device);
|
println!("{}", device);
|
||||||
|
|||||||
Reference in New Issue
Block a user