firewallstatus

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package firewallstatus publishes this micro-VM's live nftables state on the per-VM NATS subject the control plane (and the UI) listen on.

Reverse direction of pkg/firewall : where the firewall subscriber pulls a desired ruleset on weft.firewall.<vm-uuid> and reconciles the kernel table, this emitter polls the kernel table and pushes a [pod.FirewallStatus] on weft.firewall.<vm-uuid>.status. Same shape weft-router's statusemitter uses for its BGP RouterStatus.

Cadence : a ticker (default 10 s) calls the ReadFunc, stamps the status with the current wall-clock time, and publishes. The first tick fires immediately at Run() entry so a dashboard sees a value inside a second of boot. Best-effort : publish or read failures log + skip ; the next tick reconciles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Subject

func Subject(vmID string) string

Subject returns the per-VM NATS subject status messages publish to. Sibling of pkg/firewall.Subject : same VM id, ".status" suffix.

Types

type Emitter

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

Emitter periodically reads + publishes FirewallStatus for one VM.

func New

func New(nc *nats.Conn, vmID string, read ReadFunc, interval time.Duration, logger *log.Logger) (*Emitter, error)

New constructs an Emitter. interval <= 0 defaults to 10 s. logger nil defaults to log.Default.

func (*Emitter) Run

func (e *Emitter) Run(ctx context.Context) error

Run ticks every interval until ctx is cancelled. Publishes one status message immediately on entry so a fresh boot is visible without waiting for the first tick.

type ReadFunc

type ReadFunc func() pod.FirewallStatus

ReadFunc returns the current FirewallStatus, typically by inspecting the kernel nftables table. Production implementation is network.ReadFirewallStatus ; tests inject a stub.

Jump to

Keyboard shortcuts

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