9 releases

new 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

#237 in Network programming

Download history 2/week @ 2021-10-07 15/week @ 2021-10-14 15/week @ 2021-10-21 16/week @ 2021-10-28 65/week @ 2021-11-04 25/week @ 2021-11-11 16/week @ 2021-11-18 10/week @ 2021-11-25 48/week @ 2021-12-02 11/week @ 2021-12-09 7/week @ 2021-12-16 3/week @ 2021-12-23 15/week @ 2021-12-30 15/week @ 2022-01-06 28/week @ 2022-01-13 18/week @ 2022-01-20

76 downloads per month

MIT/Apache

63KB
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