# README
go-netutils
Network utilities in Golang
- TCP assembly stream for dns packets
- Generic IP defrag function
- Generate BPF filter: (ip4 || ip6) && (tcp || udp) && port == int
- Get EBPF program to inject in kernel (XDP DNS filter)
- Easy config for TLS
- String IPv4/v6 CIDR parser to net.IPMask
Build eBPF bytecode
Install prerequisites
sudo apt install llvm clang
sudo apt-get install gcc-multilib
Update libpbf
library and generate vmlinux.h
cd ebpf/headers
./update.sh
Compiles a C source file into eBPF bytecode
cd xdp/
go generate .
Running tests
$ go test -cover -v
Examples
String CIDR parser
v4Mask, err = netutils.ParseCIDRMask("10.0.0.0/8")
if err != nil {
fmt.Println(err)
}
// v4Mask == net.CIDRMask(8, 32)
# Functions
No description provided by the author
No description provided by the author
thanks to https://stackoverflow.com/questions/28967701/golang-tcp-socket-cant-close-after-get-file, call conn.CloseRead() before calling conn.Close().
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetPeerName returns the hostname associated with the given peer address.
Convert a uint16 to host byte order (big endian).
No description provided by the author
No description provided by the author
No description provided by the author
loadBpfObjects loads bpf and converts it into a struct.
No description provided by the author
No description provided by the author
No description provided by the author
Configure SO_RCVBUF, thanks to https://github.com/dmachard/go-dns-collector/issues/61#issuecomment-1201199895.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
Back out if we get more than this many fragments.
Maximum offset of a fragment.
Maximum size of a fragment (2^16).
Minimum size of a single fragment.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
bpfObjects contains all objects after they have been loaded into the kernel.
No description provided by the author
DefragPacket is a struct that holds DNS data.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author