Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 29c58bd

Browse files
authored
Update README.md
1 parent 2d1d8f9 commit 29c58bd

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
11
# nfq-go
2-
libnetfilter_queue wrapper for Go
2+
3+
nfq-go is a Go library that wraps libnetfilter_queue.
4+
5+
## Usage
6+
7+
### Import
8+
9+
```go
10+
import nfq "github.com/hownetworks/nfq-go"
11+
```
12+
13+
### New
14+
15+
```go
16+
queue, err := nfq.New(0, func(pkt nfq.Packet) {
17+
...
18+
})
19+
```
20+
21+
### Give a Verdict
22+
23+
`NF_ACCEPT`
24+
25+
```go
26+
err := pkt.Accept()
27+
```
28+
29+
`NF_DROP`
30+
31+
```go
32+
err := pkt.Drop()
33+
```
34+
35+
`NF_REPEAT`
36+
37+
```go
38+
err := pkt.Repeat()
39+
```
40+
41+
`NF_QUEUE` to queue 5
42+
43+
```go
44+
err := pkt.Queue(x)
45+
```
46+
47+
### Modifying Packets
48+
49+
Use `WithData(data []byte)` and `WithMark(mark uint32)` to modify the packet's data and mark. Instead of modifying the original these methods return a new `Packet` and can be chained.
50+
51+
As an example, here's how to (re)queue the packet to queue number 5, this time its data set to `newData` and mark set to `1234`:
52+
53+
```go
54+
err := pkt.WithData(newData).WithMark(1234).Queue(5)
55+
```
56+
57+
### Close
58+
59+
```go
60+
queue.Close()
61+
```

0 commit comments

Comments
 (0)