diff options
Diffstat (limited to 'src/network/sniffer.rs')
-rw-r--r-- | src/network/sniffer.rs | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/network/sniffer.rs b/src/network/sniffer.rs index de587be..5409185 100644 --- a/src/network/sniffer.rs +++ b/src/network/sniffer.rs @@ -1,24 +1,31 @@ -use ::std::boxed::Box; - -use ::pnet::datalink::{DataLinkReceiver, NetworkInterface}; -use ::pnet::packet::ethernet::{EtherTypes, EthernetPacket}; -use ::pnet::packet::ip::{IpNextHeaderProtocol, IpNextHeaderProtocols}; -use ::pnet::packet::ipv4::Ipv4Packet; -use ::pnet::packet::ipv6::Ipv6Packet; -use ::pnet::packet::tcp::TcpPacket; -use ::pnet::packet::udp::UdpPacket; -use ::pnet::packet::Packet; - -use ::ipnetwork::IpNetwork; -use ::std::io::{self, Result}; -use ::std::net::{IpAddr, SocketAddr}; -use ::std::thread::park_timeout; - -use crate::network::{Connection, Protocol}; -use crate::os::shared::get_datalink_channel; - -const PACKET_WAIT_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(10); -const CHANNEL_RESET_DELAY: std::time::Duration = std::time::Duration::from_millis(1000); +use std::{ + io::{self, Result}, + net::{IpAddr, SocketAddr}, + thread::park_timeout, + time::Duration, +}; + +use ipnetwork::IpNetwork; +use pnet::{ + datalink::{DataLinkReceiver, NetworkInterface}, + packet::{ + ethernet::{EtherTypes, EthernetPacket}, + ip::{IpNextHeaderProtocol, IpNextHeaderProtocols}, + ipv4::Ipv4Packet, + ipv6::Ipv6Packet, + tcp::TcpPacket, + udp::UdpPacket, + Packet, + }, +}; + +use crate::{ + network::{Connection, Protocol}, + os::shared::get_datalink_channel, +}; + +const PACKET_WAIT_TIMEOUT: Duration = Duration::from_millis(10); +const CHANNEL_RESET_DELAY: Duration = Duration::from_millis(1000); #[derive(Debug)] pub struct Segment { |