config

package
v0.0.0-...-d22ae78 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DHCPv6Required

func DHCPv6Required(cmd Command) bool

DHCPv6Required reports whether a dhcpv6 command was marked `required`, making a failed lease fatal to the whole configuration. Without it, DHCPv6 is best-effort: the interface may still come up on another address family.

func EnsureCIDR

func EnsureCIDR(s string) string

EnsureCIDR adds a default prefix length if missing (/32 for v4, /128 for v6).

func ExpandCommand

func ExpandCommand(cmd Command) []string

ExpandCommand returns the ip command args that should be executed for this command. Returns nil for commands that are not ip commands (alias, pin, ns, wifi, dhcp, firewall, include).

func ExpandCommandString

func ExpandCommandString(cmd Command) string

ExpandCommandString returns a human-readable form of the command.

func FirewallRules

func FirewallRules(cmd Command) (string, error)

FirewallRules returns the exact rules captured when a configuration file was loaded. The file fallback keeps manually constructed commands and snapshots from pre-capture builds usable.

func IsIPAddress

func IsIPAddress(s string) bool

IsIPAddress reports whether s looks like an IP address (with optional CIDR prefix).

func SaveSnapshot

func SaveSnapshot(path string, cfg *Config) error

SaveSnapshot saves the fully expanded configuration (including included files) for later teardown or rollback.

Types

type CmdType

type CmdType int
const (
	CmdIPRoute2      CmdType = iota // ip ... (full or abbreviated iproute2 command)
	CmdAlias                        // alias <name> <iface>
	CmdPin                          // pin <name> <mac>
	CmdInclude                      // include <glob>
	CmdNameserver                   // nameserver <ip> / ns <ip>
	CmdWifi                         // wifi <ssid> <password> [iface]
	CmdDHCP                         // dhcp|dhcp4|dhcpv4 <iface> [client]
	CmdDHCPv6                       // dhcpv6|dhcp6 <iface> [required]
	CmdIfShortcut                   // if <iface> up/down  OR  up/down <iface>
	CmdIPShortcut                   // ip <addr>[/prefix] <iface>
	CmdRouteShortcut                // route <dest> [via <gw>] <iface>
	CmdIPTables                     // iptables <rules-file>
	CmdIP6Tables                    // ip6tables <rules-file>
)

type Command

type Command struct {
	Type    CmdType
	Raw     string
	Tokens  []string
	File    string
	LineNum int
	// Input is the exact rules-file content reviewed when the configuration was
	// loaded. Keeping it in runtime snapshots prevents a daemon reload or
	// rollback from silently reading a file that changed in the meantime.
	Input *string `json:",omitempty"`
}

type Config

type Config struct {
	Commands []Command
	// contains filtered or unexported fields
}

func Load

func Load(path string) (*Config, error)

Load parses the config file at path, following include directives.

func LoadSnapshot

func LoadSnapshot(path string) (*Config, error)

LoadSnapshot loads a configuration previously written by SaveSnapshot.

Jump to

Keyboard shortcuts

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