networkfirewall

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package networkfirewall implements a routed, verdict-producing packet firewall. It does not decrypt TLS or modify packet bytes.

Index

Constants

This section is empty.

Variables

View Source
var ErrFragment = errors.New("fragment requires explicit failure verdict; reassembly unsupported")

Functions

func PrepareOwned

func PrepareOwned(ctx context.Context, c Config) error

PrepareOwned installs persistent missing-listener-deny hooks before routing.

func ProvisionOwned

func ProvisionOwned(ctx context.Context, c Config, provision func() error) error

ProvisionOwned holds the packet-owner fences and persistent deny hooks while a supervisor reconciles topology. The callback must not reacquire these fences.

func RetireOwned

func RetireOwned(ctx context.Context, c Config, retire func() error) error

RetireOwned retains both fences and fail-closed hooks throughout retirement.

Types

type Config

type Config struct {
	Namespace, Interface string
	ProtectedCIDRs       []string
	// ManagementDestinations exempts these peer CIDRs in both flow directions.
	ManagementDestinations []string
	Hook                   string // input or forward
	Queue                  uint16
	MaxQueueLen            uint32
	Deadline               time.Duration
	FailureVerdict         Verdict
	// BypassWithoutListener and FailOpenOnOverflow are independent kernel policies.
	BypassWithoutListener, FailOpenOnOverflow bool
	// InspectTLS enables bounded visible ClientHello metadata; it never holds a
	// packet waiting for a later segment and cannot inspect encrypted application data.
	InspectTLS bool
	// Persistent appliance hooks require lifetime-lock fencing for recovery.
	OwnershipNonce string
	RecoverOwned   bool
}

type Counters

type Counters struct{ Packets, Accepted, Dropped, WouldDeny, ParseErrors, EvaluationErrors, Deadlines, Overloads, VerdictErrors, ReceiveErrors uint64 }

type Decision

type Decision struct{ Verdict Verdict }

type Evaluator

type Evaluator interface {
	EvaluatePacket(PacketEvent) (Decision, error)
}

Evaluator must be safe to retain until its outstanding call finishes. Only one call runs at a time; a hung evaluator consumes one worker, never one per packet.

type Firewall

type Firewall struct {
	Operations *runtimeobs.Monitor
	// contains filtered or unexported fields
}

func New

func New(c Config, e Evaluator) (*Firewall, error)

func (*Firewall) Ready

func (f *Firewall) Ready() <-chan struct{}

Ready closes after both the queue listener and scoped diversion rules exist.

func (*Firewall) Run

func (f *Firewall) Run(ctx context.Context) (result error)

Run is single-use. Netlink's NetNS option creates the socket in the pinned namespace; nsenter inherits that same descriptor for nft operations. Neither operation depends on the Go scheduler's current OS thread namespace.

func (*Firewall) Stats

func (f *Firewall) Stats() Counters

type PacketEvent

type PacketEvent struct {
	SrcIP, DstIP        string
	SrcPort, DstPort    int
	Transport           string
	IPVersion, TCPFlags int
	Direction           string
	TLS                 *TLSMetadata
}

func ParsePacket

func ParsePacket(b []byte) (e PacketEvent, err error)

ParsePacket accepts a complete L3 packet. Fragmented traffic, IPv6 jumbograms, ESP and unknown extension headers are deliberately not classified as TCP/UDP.

type TLSMetadata

type TLSMetadata struct {
	ServerName    string
	ALPN          []string
	LegacyVersion uint16
}

TLSMetadata describes only the visible ClientHello. ECH can hide the real SNI.

type Verdict

type Verdict string
const (
	Allow     Verdict = "allow"
	Deny      Verdict = "deny"
	WouldDeny Verdict = "would-deny"
)

Jump to

Keyboard shortcuts

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