mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Testing timeout
This commit is contained in:
+14
-13
@@ -7,7 +7,7 @@ use pnet::{
|
||||
ipnetwork::IpNetwork,
|
||||
};
|
||||
use tokio::task;
|
||||
use tokio::time::{Duration, timeout};
|
||||
use tokio::time::{Duration, sleep, timeout};
|
||||
|
||||
mod packet_send_receive;
|
||||
|
||||
@@ -59,6 +59,7 @@ pub async fn find(interface: &str) -> Vec<Device> {
|
||||
let send_result = timeout(
|
||||
Duration::from_secs(2),
|
||||
send_packet(sender, send_interface, ipv4_net, mac),
|
||||
// test_timeout(),
|
||||
)
|
||||
.await;
|
||||
match send_result {
|
||||
@@ -66,15 +67,15 @@ pub async fn find(interface: &str) -> Vec<Device> {
|
||||
Err(_) => println!("Sender timed out"),
|
||||
};
|
||||
|
||||
let receive_result = timeout(
|
||||
Duration::from_secs(5),
|
||||
listen_for_packets(receiver, ipv4_net),
|
||||
)
|
||||
.await;
|
||||
match receive_result {
|
||||
Ok(_) => println!("Receiver done"),
|
||||
Err(_) => println!("Receiver timed out"),
|
||||
};
|
||||
// let receive_result = timeout(
|
||||
// Duration::from_secs(5),
|
||||
// listen_for_packets(receiver, ipv4_net),
|
||||
// )
|
||||
// .await;
|
||||
// match receive_result {
|
||||
// Ok(_) => println!("Receiver done"),
|
||||
// Err(_) => println!("Receiver timed out"),
|
||||
// };
|
||||
|
||||
// println!("Spawning receiver threads");
|
||||
// let reciever_thread = thread::spawn(move || {
|
||||
@@ -103,6 +104,6 @@ pub async fn find(interface: &str) -> Vec<Device> {
|
||||
devices
|
||||
}
|
||||
|
||||
// async fn test_timeout() {
|
||||
// sleep(Duration::from_secs(10)).await;
|
||||
// }
|
||||
async fn test_timeout() {
|
||||
sleep(Duration::from_secs(10)).await;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use pnet::packet::arp::{ArpHardwareTypes, ArpOperations, ArpPacket, MutableArpPa
|
||||
use pnet::packet::ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket};
|
||||
use pnet::packet::{MutablePacket, Packet};
|
||||
use pnet::util::MacAddr;
|
||||
use tokio::time::{Duration, sleep, timeout};
|
||||
|
||||
pub async fn send_packet(
|
||||
mut tx: Box<dyn DataLinkSender>,
|
||||
@@ -46,6 +47,7 @@ pub async fn send_packet(
|
||||
);
|
||||
// thread::sleep(Duration::from_millis(2));
|
||||
}
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
// thread::sleep(Duration::from_millis(2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user