https://github.com/pgaskin/go-pcapfilter
Compile tcpdump-style filters in pure Go.
https://github.com/pgaskin/go-pcapfilter
bpf pcap tcpdump wasm wasm2go
Last synced: 20 days ago
JSON representation
Compile tcpdump-style filters in pure Go.
- Host: GitHub
- URL: https://github.com/pgaskin/go-pcapfilter
- Owner: pgaskin
- License: bsd-3-clause
- Created: 2026-05-23T03:17:43.000Z (21 days ago)
- Default Branch: master
- Last Pushed: 2026-05-23T05:22:40.000Z (20 days ago)
- Last Synced: 2026-05-23T07:23:24.731Z (20 days ago)
- Topics: bpf, pcap, tcpdump, wasm, wasm2go
- Language: Go
- Homepage:
- Size: 399 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-pcapfilter
[](https://pkg.go.dev/github.com/pgaskin/go-pcapfilter)
[](https://github.com/pgaskin/go-pcapfilter/actions/workflows/test.yml)
[](https://github.com/pgaskin/go-pcapfilter/actions/workflows/attest.yml)
Compile tcpdump-style filters in pure Go.
This library wraps a WebAssembly build of [pcap_compile](https://www.tcpdump.org/manpages/pcap_compile.3pcap.html) from [libpcap](https://github.com/the-tcpdump-group/libpcap) transpiled to Go using [wasm2go](https://github.com/ncruces/wasm2go).
It can be used with libraries like [github.com/gopacket/gopacket/afpacket](https://github.com/google/gopacket/tree/master/afpacket) to implement CGO-less packet capture.
A command-line interface is available.
The wasm2go blob is fully [reproducible](./src/Dockerfile) and [verified](https://github.com/pgaskin/go-pcapfilter/attestations).
To have working IDE integration while working on the bindings, use `bear -- make -C src distclean download all CC=/path/to/wasi-sdk/bin/wasm32-wasip1-clang WASM_OPT=/path/to/binaryen/bin/wasm-opt` to download the libpcap source and generate the `compile_commands.json`.