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

#5 in #iptables

Download history 71/week @ 2024-07-22 89/week @ 2024-07-29 11/week @ 2024-08-05 7/week @ 2024-08-12 24/week @ 2024-08-19 98/week @ 2024-08-26 43/week @ 2024-09-02 48/week @ 2024-09-09 76/week @ 2024-09-16 116/week @ 2024-09-23 61/week @ 2024-09-30 62/week @ 2024-10-07 136/week @ 2024-10-14 4/week @ 2024-10-21 26/week @ 2024-10-28 63/week @ 2024-11-04

231 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