Documentation
¶
Index ¶
- func DHCPv6Required(cmd Command) bool
- func EnsureCIDR(s string) string
- func ExpandCommand(cmd Command) []string
- func ExpandCommandString(cmd Command) string
- func FirewallRules(cmd Command) (string, error)
- func IsIPAddress(s string) bool
- func SaveSnapshot(path string, cfg *Config) error
- type CmdType
- type Command
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DHCPv6Required ¶
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 ¶
EnsureCIDR adds a default prefix length if missing (/32 for v4, /128 for v6).
func ExpandCommand ¶
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 ¶
ExpandCommandString returns a human-readable form of the command.
func FirewallRules ¶
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 ¶
IsIPAddress reports whether s looks like an IP address (with optional CIDR prefix).
func SaveSnapshot ¶
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"`
}