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 43/week @ 2024-11-15 133/week @ 2024-11-22 50/week @ 2024-11-29 90/week @ 2024-12-06 99/week @ 2024-12-13 44/week @ 2024-12-20 6/week @ 2024-12-27 28/week @ 2025-01-03 38/week @ 2025-01-10 38/week @ 2025-01-17 29/week @ 2025-01-24 36/week @ 2025-01-31 86/week @ 2025-02-07 133/week @ 2025-02-14 105/week @ 2025-02-21 147/week @ 2025-02-28

483 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