https://github.com/protectwise/pcap-async
Pure rust wrapper around pcap-sys
https://github.com/protectwise/pcap-async
Last synced: about 1 year ago
JSON representation
Pure rust wrapper around pcap-sys
- Host: GitHub
- URL: https://github.com/protectwise/pcap-async
- Owner: protectwise
- License: mit
- Created: 2018-11-30T20:40:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-31T13:11:24.000Z (over 5 years ago)
- Last Synced: 2025-03-22T16:02:10.043Z (over 1 year ago)
- Language: Rust
- Size: 3.76 MB
- Stars: 9
- Watchers: 6
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pcap-async
[![build status][travis-badge]][travis-url]
[![crates.io version][crates-badge]][crates-url]
[![docs.rs docs][docs-badge]][docs-url]
[![MIT licensed][mit-badge]][mit-url]
Rust async wrapper around [pcap-sys](https://github.com/protectwise/pcap-sys). Utilizes [Futures 0.3](https://github.com/rust-lang-nursery/futures-rs) and [Smol](https://github.com/stjepang/smol).
[Documentation](https://docs.rs/pcap-async/latest/)
[travis-badge]: https://travis-ci.com/protectwise/pcap-async.svg?branch=master
[travis-url]: https://travis-ci.com/protectwise/pcap-async
[crates-badge]: https://img.shields.io/crates/v/pcap-async.svg?style=flat-square
[crates-url]: https://crates.io/crates/pcap-async
[docs-badge]: https://img.shields.io/badge/docs.rs-latest-blue.svg?style=flat-square
[docs-url]: https://docs.rs/pcap-async
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
[mit-url]: LICENSE-MIT
## Usage
First, add this to your `Cargo.toml`:
```toml
[dependencies]
pcap-async = "0.3"
```
Next, add this to your crate:
```rust
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();
})
}
```