firewall

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 9 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 firewall validates host firewall rules and renders the agent's nftables table (§8.3). The controller uses the same rendering to show the effective rules of any node.

Index

Constants

View Source
const (
	Interface = "wg-syncloud"
	Bridge    = "syncloud0"
	// SourceCluster matches the addresses of all cluster nodes.
	SourceCluster = "cluster"
)

Names the rendered table refers to (kept in sync with the agent).

View Source
const (
	SetHostDrops = "host_drops"
	SetInDrops   = "sg_in_drops"
	SetOutDrops  = "sg_out_drops"

	// Counter names of the built-in security group rules.
	RulePlatform = "builtin:platform"
	RuleInDeny   = "builtin:sg-in-deny"
	RuleOutDeny  = "builtin:sg-out-deny"
	RuleHostDeny = "default deny"
	RuleSpoofed  = "builtin:sg-spoofed"
)

Names of the dynamic sets that record dropped flows (the drop log). Their contents change with traffic, so drift detection ignores them.

Variables

This section is empty.

Functions

func Matches

func Matches(sel string, labels map[string]string) bool

Matches reports whether a container with these labels belongs to a set selector (see SecuritySet.match).

func ParseCounters

func ParseCounters(data []byte) (map[string]Counts, map[DropKey]uint64, error)

ParseCounters reads `nft -j list table inet syncloud`: rule counters by comment (summed over rules with the same comment) and the drop sets' per-flow packet counts.

func Render

Render returns the complete "inet syncloud" table for cfg. It replaces the table atomically when fed to `nft -f`. fw may differ from cfg.Firewall (after a rollback the agent renders the last confirmed firewall). svcs are the service VIPs to load-balance (§8.6).

func RenderWith

func RenderWith(cfg *agentv1.NetworkConfig, fw *agentv1.Firewall, svcs []*agentv1.VirtualService, sec *Security) (string, error)

RenderWith also enforces security groups when sec is set (§8.3).

func StripDynamic

func StripDynamic(listing string) string

StripDynamic removes what changes with traffic from an `nft -s list table` listing (the drop sets' elements and counts), so drift detection only sees configuration changes.

func ValidateRule

func ValidateRule(protocol, ports string, sources []string) error

ValidateRule checks one rule. Everything in a rule ends up in nftables syntax, so only strictly parsed values are accepted.

func ValidateSecurityRule

func ValidateSecurityRule(protocol, ports string) error

ValidateSecurityRule checks protocol and ports like host rules do.

Types

type Counts

type Counts struct{ Packets, Bytes uint64 }

Counts are a rule's packets and bytes.

type DropKey

type DropKey struct {
	Direction, Src, Dst, Protocol string
	Port                          uint32
}

DropKey identifies a dropped flow.

type LocalContainer

type LocalContainer struct {
	IP     string
	Labels map[string]string
}

LocalContainer is a container on this node, classified into security sets by its labels.

type Security

type Security struct {
	Policy *agentv1.SecurityPolicy
	Local  []LocalContainer
}

Security is what an agent needs to render security groups: the compiled policy and the node's own containers.

Jump to

Keyboard shortcuts

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