9 releases

0.2.5 Jan 26, 2022
0.2.4 Apr 29, 2020
0.2.3 Feb 4, 2020
0.2.2 Sep 21, 2019
0.1.2 Sep 2, 2019

#695 in Network programming

Download history 64/week @ 2023-12-18 292/week @ 2024-01-01 393/week @ 2024-01-08 168/week @ 2024-01-15 222/week @ 2024-01-22 110/week @ 2024-01-29 44/week @ 2024-02-12 56/week @ 2024-02-19 23/week @ 2024-02-26 20/week @ 2024-03-04 34/week @ 2024-03-11 34/week @ 2024-03-18 24/week @ 2024-03-25 102/week @ 2024-04-01

197 downloads per month

MIT/Apache

64KB
1.5K SLoC

nfq - NetFilter queue for Rust

nfq is Rust library for performing userspace handling of packets queued by the kernel packet packet filter chains.

License

In contrast to libnetfilter_queue which is licensed under GPL 2.0, which will require all binaries using that library to be bound by GPL, nfq is dual-licensed under MIT/Apache-2.0. nfq achieves this by communicates with kernel via NETLINK sockets directly.

Example

Here is an example which accepts all packets.

use nfq::{Queue, Verdict};

fn main() -> std::io::Result<()> {
   let mut queue = Queue::open()?; 
   queue.bind(0)?;
   loop {
       let mut msg = queue.recv()?;
       msg.set_verdict(Verdict::Accept);
       queue.verdict(msg)?;
   }
   Ok(())
}

lib.rs:

nfq - NetFilter queue for Rust

nfq is Rust library for performing userspace handling of packets queued by the kernel packet packet filter chains.

License

In contrast to libnetfilter_queue which is licensed under GPL 2.0, which will require all binaries using that library to be bound by GPL, nfq is dual-licensed under MIT/Apache-2.0. nfq achieves this by communicates with kernel via NETLINK sockets directly.

Example

Here is an example which accepts all packets.

use nfq::{Queue, Verdict};

fn main() -> std::io::Result<()> {
   let mut queue = Queue::open()?;
   queue.bind(0)?;
   loop {
       let mut msg = queue.recv()?;
       msg.set_verdict(Verdict::Accept);
       queue.verdict(msg)?;
   }
   Ok(())
}

Dependencies