Skip to content

protectwise/pcap-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pcap-async

build status crates.io version docs.rs docs MIT licensed

Rust async wrapper around pcap-sys. Utilizes Futures 0.3 and Smol.

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
pcap-async = "0.3"

Next, add this to your crate:

use futures::StreamExt;
use pcap_async::{Config, Handle, PacketStream};

fn main() {
    smol::run(async move {
        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();
    })
}

About

Pure rust wrapper around pcap-sys

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages