flod

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter is a loaded XDP program and its maps. Close detaches it.

func Attach

func Attach(ifaceName string, block []netip.Prefix, quic bool, syn SYNRate) (*Filter, error)

Attach loads the XDP filter onto ifaceName. Driver mode first, generic (SKB) as fallback.

func (*Filter) Ban

func (f *Filter) Ban(addr netip.Addr, ttl time.Duration) error

Ban pins addr until ttl elapses (monotonic clock, same as BPF): the address itself for IPv4, its /64 for IPv6, which is what one user usually holds. ttl <= 0 is forever. XDP then drops that source before its next handshake.

func (*Filter) Close

func (f *Filter) Close()

func (*Filter) EtherTypes added in v0.3.0

func (f *Filter) EtherTypes() map[string]uint64

EtherTypes counts the frames dropped for their EtherType (drop_ethertype), by EtherType as 0x88cc, or llc for an IEEE 802.3 frame, whose type field is a length. The program tracks up to 64 types.

func (*Filter) Mode

func (f *Filter) Mode() string

Mode is how the filter attached: driver (in the NIC driver, before the kernel allocates for a packet) or generic (after, slower).

func (*Filter) SetBlock

func (f *Filter) SetBlock(block []netip.Prefix) error

SetBlock replaces the permanent drop list (expire_ns == 0). Runtime bans (expire_ns != 0) stay. The XDP program keeps running.

func (*Filter) SetSYNRate

func (f *Filter) SetSYNRate(syn SYNRate) error

SetSYNRate changes the SYN limit while XDP runs. Sources keep the tokens they have; they refill at the new rate.

func (*Filter) Stats

func (f *Filter) Stats() map[string]uint64

type SYNRate

type SYNRate struct{ PerSecond, Burst int }

SYNRate is how many new TCP connections one source may open: perSecond sustained, burst at once. PerSecond 0 means no limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL