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
- func Matches(sel string, labels map[string]string) bool
- func ParseCounters(data []byte) (map[string]Counts, map[DropKey]uint64, error)
- func Render(cfg *agentv1.NetworkConfig, fw *agentv1.Firewall, ...) (string, error)
- func RenderWith(cfg *agentv1.NetworkConfig, fw *agentv1.Firewall, ...) (string, error)
- func StripDynamic(listing string) string
- func ValidateBlock(source string) (netip.Prefix, error)
- func ValidateGuard(g *agentv1.FirewallGuard) error
- func ValidatePorts(ports string) error
- func ValidateRule(protocol, ports string, sources []string) error
- func ValidateSecurityRule(protocol, ports string) error
- type Counts
- type DropKey
- type LocalContainer
- type Security
Constants ¶
const ( Interface = "wg-syncloud" Bridge = "syncloud0" // SourceCluster matches the addresses of all cluster nodes. SourceCluster = "cluster" // Counter names of the DHCP client rules. RuleDHCP = "builtin:dhcp" RuleDHCPv6 = "builtin:dhcpv6" )
Names the rendered table refers to (kept in sync with the agent).
const ( SetHostDrops = "host_drops" // Phase 24: IPv6 host drops, sources over a guard's limit, blocks. SetHostDrops6 = "host_drops6" SetLimitDrops = "limit_drops" SetLimitDrops6 = "limit_drops6" RuleForwardSeal = "builtin:forward-seal" RuleBlocked = "builtin:blocked" 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 ¶
Matches reports whether a container with these labels belongs to a set selector (see SecuritySet.match).
func ParseCounters ¶
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 ¶
func Render(cfg *agentv1.NetworkConfig, fw *agentv1.Firewall, svcs []*agentv1.VirtualService) (string, error)
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 ¶
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 ValidateBlock ¶ added in v0.3.0
ValidateBlock checks a blocked source: an IP or a CIDR, never everything.
func ValidateGuard ¶ added in v0.3.0
func ValidateGuard(g *agentv1.FirewallGuard) error
ValidateGuard checks a guard before it is rendered.
func ValidatePorts ¶ added in v0.3.0
ValidatePorts checks a port list: numbers and ranges separated by commas.
func ValidateRule ¶
ValidateRule checks one rule. Everything in a rule ends up in nftables syntax, so only strictly parsed values are accepted.
func ValidateSecurityRule ¶
ValidateSecurityRule checks protocol and ports like host rules do.
Types ¶
type LocalContainer ¶
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.