pcap-async
Rust async wrapper around pcap-sys. Utilizes Futures 0.3 and Tokio.
Usage
First, add this to your Cargo.toml
:
[]
= "0.1"
Next, add this to your crate:
use StreamExt;
use ;
async
Rust async wrapper around pcap-sys. Utilizes Futures 0.3 and Tokio.
First, add this to your Cargo.toml
:
[dependencies]
pcap-async = "0.1"
Next, add this to your crate:
use futures::StreamExt;
use pcap_async::{Config, Handle, PacketStream};
#[tokio::main]
async fn main() {
let handle = Handle::lookup().expect("No handle created");
let mut provider = PacketStream::new(Config::default(), handle)
.expect("Could not create provider")
.fuse();
while let Some(packets) = provider.next().await {
}
handle.interrupt();
}