firewall

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package firewall implements the reconcile.Controller that converges internal/store's firewall_rules table onto the local host's ufw via internal/firewall. v1 only manages rules whose NodeID is the local node ("" sentinel); a remote-node rule is skipped and logged, not silently dropped, pending a future per-node agent RPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller converges the local host's ufw rules to match every firewall_rules row assigned to the control plane's own local node.

func New

func New(ruleStore RuleStore, syncer Syncer, opts ...Option) *Controller

New builds a Controller.

func (*Controller) Name

func (c *Controller) Name() string

Name implements reconcile.Controller.

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error)

Reconcile implements reconcile.Controller. It lists every desired firewall rule, builds the set this controller's local node should enforce, re-validates each against the required-ports allowlist as a defense-in-depth check (the API layer already refuses an unsafe rule at write time, so this should never trigger in practice), and syncs the remainder against ufw via Syncer.Sync.

type Option

type Option func(*Controller)

Option configures optional Controller behavior.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger overrides the logger used for per-rule skip decisions. Defaults to slog.Default().

func WithRequiredPorts

func WithRequiredPorts(ports []int) Option

WithRequiredPorts overrides the ports internal/firewall.Validate refuses to close, defaulting to firewall.DefaultRequiredPorts. Pass the control plane's actually configured ports (management API, agent gRPC listener, ingress) rather than relying on the defaults whenever any of them were moved off their default address.

type RuleStore

type RuleStore interface {
	ListFirewallRules(ctx context.Context) ([]store.FirewallRule, error)
}

RuleStore is the narrow surface this controller needs from internal/store, so tests can fake it without a real database. *store.DB satisfies this.

type Syncer

type Syncer interface {
	Sync(ctx context.Context, want []firewall.Rule) (firewall.Result, error)
}

Syncer is the narrow surface this controller needs from internal/firewall.Manager, so tests can fake it without shelling out to a real ufw binary. *firewall.Manager satisfies this.

Jump to

Keyboard shortcuts

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