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
231 downloads per month
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(())
}