Documentation
¶
Overview ¶
Package firewalld is a comprehensive Go client for the firewalld D-Bus API.
It exposes both runtime (transient) and permanent configuration operations, mirroring firewall-cmd's default and --permanent modes, and adapts to the connected server's version so a single binary serves both old (EL7 0.6.x) and new (EL9 1.x) firewalld. Compound values are encoded as concrete Go structs so godbus emits the D-Bus tuples firewalld requires (see CLAUDE.md).
Index ¶
- Variables
- type ActiveZone
- type Capability
- type Conn
- func (c *Conn) Call(ctx context.Context, path dbus.ObjectPath, iface, method string, rets []any, ...) error
- func (c *Conn) CheckPermanentConfig(ctx context.Context) error
- func (c *Conn) Close() error
- func (c *Conn) CompleteReload(ctx context.Context) error
- func (c *Conn) Config() *Permanent
- func (c *Conn) DefaultZone(ctx context.Context) (string, error)
- func (c *Conn) Direct() *Direct
- func (c *Conn) DisablePanicMode(ctx context.Context) error
- func (c *Conn) EnablePanicMode(ctx context.Context) error
- func (c *Conn) HelperSettings(ctx context.Context, helper string) (HelperSettings, error)
- func (c *Conn) Helpers(ctx context.Context) ([]string, error)
- func (c *Conn) ICMPTypeSettings(ctx context.Context, icmptype string) (ICMPTypeSettings, error)
- func (c *Conn) ICMPTypes(ctx context.Context) ([]string, error)
- func (c *Conn) Lockdown() *Lockdown
- func (c *Conn) LogDenied(ctx context.Context) (string, error)
- func (c *Conn) MainProperty(ctx context.Context, name string) (dbus.Variant, error)
- func (c *Conn) Permanent() *Permanent
- func (c *Conn) QueryPanicMode(ctx context.Context) (bool, error)
- func (c *Conn) Reload(ctx context.Context) error
- func (c *Conn) ResetToDefaults(ctx context.Context) error
- func (c *Conn) Runtime() *Runtime
- func (c *Conn) RuntimeInfo(ctx context.Context) (RuntimeInfo, error)
- func (c *Conn) RuntimeToPermanent(ctx context.Context) error
- func (c *Conn) ServiceSettings(ctx context.Context, service string) (ServiceSettings, error)
- func (c *Conn) Services(ctx context.Context) ([]string, error)
- func (c *Conn) SetDefaultZone(ctx context.Context, zone string) error
- func (c *Conn) SetLogDenied(ctx context.Context, value string) error
- func (c *Conn) State(ctx context.Context) (string, error)
- func (c *Conn) Supports(cap Capability) bool
- func (c *Conn) Version() Version
- func (c *Conn) WatchReloaded(ctx context.Context) (<-chan struct{}, error)
- func (c *Conn) WatchSignals(ctx context.Context) (<-chan Signal, error)
- type DaemonConfig
- type Direct
- func (d *Direct) AddChain(ctx context.Context, ch DirectChain) error
- func (d *Direct) AddPassthrough(ctx context.Context, ipv string, args []string) error
- func (d *Direct) AddRule(ctx context.Context, r DirectRule) error
- func (d *Direct) AllChains(ctx context.Context) ([]DirectChain, error)
- func (d *Direct) AllPassthroughs(ctx context.Context) ([]DirectPassthrough, error)
- func (d *Direct) AllRules(ctx context.Context) ([]DirectRule, error)
- func (d *Direct) Chains(ctx context.Context, ipv, table string) ([]string, error)
- func (d *Direct) Passthrough(ctx context.Context, ipv string, args []string) (string, error)
- func (d *Direct) Passthroughs(ctx context.Context, ipv string) ([][]string, error)
- func (d *Direct) QueryChain(ctx context.Context, ch DirectChain) (bool, error)
- func (d *Direct) QueryPassthrough(ctx context.Context, ipv string, args []string) (bool, error)
- func (d *Direct) QueryRule(ctx context.Context, r DirectRule) (bool, error)
- func (d *Direct) RemoveAllPassthroughs(ctx context.Context) error
- func (d *Direct) RemoveChain(ctx context.Context, ch DirectChain) error
- func (d *Direct) RemovePassthrough(ctx context.Context, ipv string, args []string) error
- func (d *Direct) RemoveRule(ctx context.Context, r DirectRule) error
- func (d *Direct) RemoveRules(ctx context.Context, ipv, table, chain string) error
- func (d *Direct) Rules(ctx context.Context, ipv, table, chain string) ([]DirectRule, error)
- type DirectChain
- type DirectConfig
- type DirectPassthrough
- type DirectRule
- type Error
- type Family
- type ForwardPort
- type HelperSettings
- type ICMPTypeSettings
- type IPSetSettings
- type Lockdown
- func (l *Lockdown) AddCommand(ctx context.Context, command string) error
- func (l *Lockdown) AddContext(ctx context.Context, selinuxContext string) error
- func (l *Lockdown) AddUID(ctx context.Context, uid int32) error
- func (l *Lockdown) AddUser(ctx context.Context, user string) error
- func (l *Lockdown) Commands(ctx context.Context) ([]string, error)
- func (l *Lockdown) Contexts(ctx context.Context) ([]string, error)
- func (l *Lockdown) Disable(ctx context.Context) error
- func (l *Lockdown) Enable(ctx context.Context) error
- func (l *Lockdown) Query(ctx context.Context) (bool, error)
- func (l *Lockdown) QueryCommand(ctx context.Context, command string) (bool, error)
- func (l *Lockdown) QueryContext(ctx context.Context, selinuxContext string) (bool, error)
- func (l *Lockdown) QueryUID(ctx context.Context, uid int32) (bool, error)
- func (l *Lockdown) QueryUser(ctx context.Context, user string) (bool, error)
- func (l *Lockdown) RemoveCommand(ctx context.Context, command string) error
- func (l *Lockdown) RemoveContext(ctx context.Context, selinuxContext string) error
- func (l *Lockdown) RemoveUID(ctx context.Context, uid int32) error
- func (l *Lockdown) RemoveUser(ctx context.Context, user string) error
- func (l *Lockdown) UIDs(ctx context.Context) ([]int32, error)
- func (l *Lockdown) Users(ctx context.Context) ([]string, error)
- type PermDirect
- type PermHelper
- func (s *PermHelper) AddPort(ctx context.Context, p Port) error
- func (s *PermHelper) Remove(ctx context.Context) error
- func (s *PermHelper) RemovePort(ctx context.Context, p Port) error
- func (s *PermHelper) SetDescription(ctx context.Context, description string) error
- func (s *PermHelper) SetFamily(ctx context.Context, family string) error
- func (s *PermHelper) SetModule(ctx context.Context, module string) error
- func (s *PermHelper) Settings(ctx context.Context) (HelperSettings, error)
- func (s *PermHelper) Update(ctx context.Context, settings HelperSettings) error
- type PermICMPType
- func (s *PermICMPType) AddDestination(ctx context.Context, family string) error
- func (s *PermICMPType) QueryDestination(ctx context.Context, family string) (bool, error)
- func (s *PermICMPType) Remove(ctx context.Context) error
- func (s *PermICMPType) RemoveDestination(ctx context.Context, family string) error
- func (s *PermICMPType) SetDescription(ctx context.Context, description string) error
- func (s *PermICMPType) Settings(ctx context.Context) (ICMPTypeSettings, error)
- func (s *PermICMPType) Update(ctx context.Context, settings ICMPTypeSettings) error
- type PermIPSet
- func (s *PermIPSet) AddEntry(ctx context.Context, entry string) error
- func (s *PermIPSet) AddOption(ctx context.Context, key, value string) error
- func (s *PermIPSet) Entries(ctx context.Context) ([]string, error)
- func (s *PermIPSet) QueryEntry(ctx context.Context, entry string) (bool, error)
- func (s *PermIPSet) Remove(ctx context.Context) error
- func (s *PermIPSet) RemoveEntry(ctx context.Context, entry string) error
- func (s *PermIPSet) RemoveOption(ctx context.Context, key string) error
- func (s *PermIPSet) SetDescription(ctx context.Context, description string) error
- func (s *PermIPSet) SetEntries(ctx context.Context, entries []string) error
- func (s *PermIPSet) Settings(ctx context.Context) (IPSetSettings, error)
- func (s *PermIPSet) Update(ctx context.Context, settings IPSetSettings) error
- type PermPolicy
- type PermService
- func (s *PermService) AddInclude(ctx context.Context, service string) error
- func (s *PermService) AddModule(ctx context.Context, module string) error
- func (s *PermService) AddPort(ctx context.Context, p Port) error
- func (s *PermService) AddProtocol(ctx context.Context, proto string) error
- func (s *PermService) Includes(ctx context.Context) ([]string, error)
- func (s *PermService) QueryInclude(ctx context.Context, service string) (bool, error)
- func (s *PermService) Remove(ctx context.Context) error
- func (s *PermService) RemoveDestination(ctx context.Context, family string) error
- func (s *PermService) RemoveInclude(ctx context.Context, service string) error
- func (s *PermService) RemoveModule(ctx context.Context, module string) error
- func (s *PermService) RemovePort(ctx context.Context, p Port) error
- func (s *PermService) RemoveProtocol(ctx context.Context, proto string) error
- func (s *PermService) SetDescription(ctx context.Context, description string) error
- func (s *PermService) SetDestination(ctx context.Context, family, address string) error
- func (s *PermService) Settings(ctx context.Context) (ServiceSettings, error)
- func (s *PermService) Update(ctx context.Context, settings ServiceSettings) error
- type PermZone
- func (z *PermZone) AddForwardPort(ctx context.Context, fp ForwardPort) error
- func (z *PermZone) AddIcmpBlock(ctx context.Context, icmptype string) error
- func (z *PermZone) AddIcmpBlockInversion(ctx context.Context) error
- func (z *PermZone) AddInterface(ctx context.Context, iface string) error
- func (z *PermZone) AddMasquerade(ctx context.Context) error
- func (z *PermZone) AddPort(ctx context.Context, p Port) error
- func (z *PermZone) AddProtocol(ctx context.Context, proto string) error
- func (z *PermZone) AddRichRule(ctx context.Context, rule string) error
- func (z *PermZone) AddService(ctx context.Context, service string) error
- func (z *PermZone) AddSource(ctx context.Context, source string) error
- func (z *PermZone) AddSourcePort(ctx context.Context, p Port) error
- func (z *PermZone) Interfaces(ctx context.Context) ([]string, error)
- func (z *PermZone) LoadDefaults(ctx context.Context) error
- func (z *PermZone) Name() string
- func (z *PermZone) Protocols(ctx context.Context) ([]string, error)
- func (z *PermZone) QueryForwardPort(ctx context.Context, fp ForwardPort) (bool, error)
- func (z *PermZone) QueryIcmpBlock(ctx context.Context, icmptype string) (bool, error)
- func (z *PermZone) QueryIcmpBlockInversion(ctx context.Context) (bool, error)
- func (z *PermZone) QueryInterface(ctx context.Context, iface string) (bool, error)
- func (z *PermZone) QueryMasquerade(ctx context.Context) (bool, error)
- func (z *PermZone) QueryPort(ctx context.Context, p Port) (bool, error)
- func (z *PermZone) QueryProtocol(ctx context.Context, proto string) (bool, error)
- func (z *PermZone) QueryRichRule(ctx context.Context, rule string) (bool, error)
- func (z *PermZone) QueryService(ctx context.Context, service string) (bool, error)
- func (z *PermZone) QuerySource(ctx context.Context, source string) (bool, error)
- func (z *PermZone) QuerySourcePort(ctx context.Context, p Port) (bool, error)
- func (z *PermZone) Remove(ctx context.Context) error
- func (z *PermZone) RemoveForwardPort(ctx context.Context, fp ForwardPort) error
- func (z *PermZone) RemoveIcmpBlock(ctx context.Context, icmptype string) error
- func (z *PermZone) RemoveIcmpBlockInversion(ctx context.Context) error
- func (z *PermZone) RemoveInterface(ctx context.Context, iface string) error
- func (z *PermZone) RemoveMasquerade(ctx context.Context) error
- func (z *PermZone) RemovePort(ctx context.Context, p Port) error
- func (z *PermZone) RemoveProtocol(ctx context.Context, proto string) error
- func (z *PermZone) RemoveRichRule(ctx context.Context, rule string) error
- func (z *PermZone) RemoveService(ctx context.Context, service string) error
- func (z *PermZone) RemoveSource(ctx context.Context, source string) error
- func (z *PermZone) RemoveSourcePort(ctx context.Context, p Port) error
- func (z *PermZone) Rename(ctx context.Context, newName string) error
- func (z *PermZone) RichRules(ctx context.Context) ([]string, error)
- func (z *PermZone) Services(ctx context.Context) ([]string, error)
- func (z *PermZone) SetDescription(ctx context.Context, description string) error
- func (z *PermZone) SetShort(ctx context.Context, short string) error
- func (z *PermZone) SetTarget(ctx context.Context, target Target) error
- func (z *PermZone) SetVersion(ctx context.Context, version string) error
- func (z *PermZone) Settings(ctx context.Context) (ZoneSettings, error)
- func (z *PermZone) Sources(ctx context.Context) ([]string, error)
- func (z *PermZone) Target(ctx context.Context) (Target, error)
- func (z *PermZone) Update(ctx context.Context, settings ZoneSettings) error
- type Permanent
- func (p *Permanent) AddHelper(ctx context.Context, name string, settings HelperSettings) (dbus.ObjectPath, error)
- func (p *Permanent) AddICMPType(ctx context.Context, name string, settings ICMPTypeSettings) (dbus.ObjectPath, error)
- func (p *Permanent) AddIPSet(ctx context.Context, name string, settings IPSetSettings) (dbus.ObjectPath, error)
- func (p *Permanent) AddPolicy(ctx context.Context, name string, settings PolicySettings) (dbus.ObjectPath, error)
- func (p *Permanent) AddService(ctx context.Context, name string, settings ServiceSettings) (dbus.ObjectPath, error)
- func (p *Permanent) AddZone(ctx context.Context, name string, settings ZoneSettings) (dbus.ObjectPath, error)
- func (p *Permanent) ConfigProperty(ctx context.Context, name string) (dbus.Variant, error)
- func (p *Permanent) DaemonConfig(ctx context.Context) (DaemonConfig, error)
- func (p *Permanent) Direct() *PermDirect
- func (p *Permanent) Helper(name string) *PermHelper
- func (p *Permanent) HelperNames(ctx context.Context) ([]string, error)
- func (p *Permanent) HelperPaths(ctx context.Context) ([]dbus.ObjectPath, error)
- func (p *Permanent) ICMPType(name string) *PermICMPType
- func (p *Permanent) ICMPTypeNames(ctx context.Context) ([]string, error)
- func (p *Permanent) IPSet(name string) *PermIPSet
- func (p *Permanent) IPSetNames(ctx context.Context) ([]string, error)
- func (p *Permanent) IPSetPaths(ctx context.Context) ([]dbus.ObjectPath, error)
- func (p *Permanent) Policy(name string) *PermPolicy
- func (p *Permanent) PolicyNames(ctx context.Context) ([]string, error)
- func (p *Permanent) PolicyPaths(ctx context.Context) ([]dbus.ObjectPath, error)
- func (p *Permanent) Service(name string) *PermService
- func (p *Permanent) ServiceNames(ctx context.Context) ([]string, error)
- func (p *Permanent) SetConfigProperty(ctx context.Context, name string, value any) error
- func (p *Permanent) SetFirewallBackend(ctx context.Context, backend string) error
- func (p *Permanent) Zone(name string) *PermZone
- func (p *Permanent) ZoneNames(ctx context.Context) ([]string, error)
- func (p *Permanent) ZoneOfInterface(ctx context.Context, iface string) (string, error)
- func (p *Permanent) ZoneOfSource(ctx context.Context, source string) (string, error)
- func (p *Permanent) ZonePaths(ctx context.Context) ([]dbus.ObjectPath, error)
- type PolicySettings
- type Port
- type Runtime
- func (r *Runtime) ActivePolicies(ctx context.Context) ([]string, error)
- func (r *Runtime) ActiveZones(ctx context.Context) ([]ActiveZone, error)
- func (r *Runtime) IPSet(name string) *RuntimeIPSet
- func (r *Runtime) IPSetExists(ctx context.Context, name string) (bool, error)
- func (r *Runtime) IPSets(ctx context.Context) ([]string, error)
- func (r *Runtime) Policies(ctx context.Context) ([]string, error)
- func (r *Runtime) PolicySettings(ctx context.Context, policy string) (PolicySettings, error)
- func (r *Runtime) SetPolicySettings(ctx context.Context, policy string, settings PolicySettings) error
- func (r *Runtime) SetSettings(ctx context.Context, zone string, settings ZoneSettings) error
- func (r *Runtime) Settings(ctx context.Context, zone string) (ZoneSettings, error)
- func (r *Runtime) Zone(name string) *RuntimeZone
- func (r *Runtime) ZoneOfInterface(ctx context.Context, iface string) (string, error)
- func (r *Runtime) ZoneOfSource(ctx context.Context, source string) (string, error)
- func (r *Runtime) Zones(ctx context.Context) ([]string, error)
- type RuntimeIPSet
- func (s *RuntimeIPSet) AddEntry(ctx context.Context, entry string) error
- func (s *RuntimeIPSet) Entries(ctx context.Context) ([]string, error)
- func (s *RuntimeIPSet) QueryEntry(ctx context.Context, entry string) (bool, error)
- func (s *RuntimeIPSet) RemoveEntry(ctx context.Context, entry string) error
- func (s *RuntimeIPSet) SetEntries(ctx context.Context, entries []string) error
- func (s *RuntimeIPSet) Settings(ctx context.Context) (IPSetSettings, error)
- type RuntimeInfo
- type RuntimeZone
- func (z *RuntimeZone) AddForwardPort(ctx context.Context, fp ForwardPort, timeout time.Duration) error
- func (z *RuntimeZone) AddIcmpBlock(ctx context.Context, icmptype string, timeout time.Duration) error
- func (z *RuntimeZone) AddIcmpBlockInversion(ctx context.Context, timeout time.Duration) error
- func (z *RuntimeZone) AddInterface(ctx context.Context, iface string) error
- func (z *RuntimeZone) AddMasquerade(ctx context.Context, timeout time.Duration) error
- func (z *RuntimeZone) AddPort(ctx context.Context, p Port, timeout time.Duration) error
- func (z *RuntimeZone) AddProtocol(ctx context.Context, proto string, timeout time.Duration) error
- func (z *RuntimeZone) AddRichRule(ctx context.Context, rule string, timeout time.Duration) error
- func (z *RuntimeZone) AddService(ctx context.Context, service string, timeout time.Duration) error
- func (z *RuntimeZone) AddSource(ctx context.Context, source string) error
- func (z *RuntimeZone) AddSourcePort(ctx context.Context, p Port, timeout time.Duration) error
- func (z *RuntimeZone) ChangeInterface(ctx context.Context, iface string) error
- func (z *RuntimeZone) ChangeSource(ctx context.Context, source string) error
- func (z *RuntimeZone) ForwardPorts(ctx context.Context) ([]ForwardPort, error)
- func (z *RuntimeZone) ICMPBlocks(ctx context.Context) ([]string, error)
- func (z *RuntimeZone) Interfaces(ctx context.Context) ([]string, error)
- func (z *RuntimeZone) Name() string
- func (z *RuntimeZone) Ports(ctx context.Context) ([]Port, error)
- func (z *RuntimeZone) Protocols(ctx context.Context) ([]string, error)
- func (z *RuntimeZone) QueryForwardPort(ctx context.Context, fp ForwardPort) (bool, error)
- func (z *RuntimeZone) QueryIcmpBlock(ctx context.Context, icmptype string) (bool, error)
- func (z *RuntimeZone) QueryIcmpBlockInversion(ctx context.Context) (bool, error)
- func (z *RuntimeZone) QueryInterface(ctx context.Context, iface string) (bool, error)
- func (z *RuntimeZone) QueryMasquerade(ctx context.Context) (bool, error)
- func (z *RuntimeZone) QueryPort(ctx context.Context, p Port) (bool, error)
- func (z *RuntimeZone) QueryProtocol(ctx context.Context, proto string) (bool, error)
- func (z *RuntimeZone) QueryRichRule(ctx context.Context, rule string) (bool, error)
- func (z *RuntimeZone) QueryService(ctx context.Context, service string) (bool, error)
- func (z *RuntimeZone) QuerySource(ctx context.Context, source string) (bool, error)
- func (z *RuntimeZone) QuerySourcePort(ctx context.Context, p Port) (bool, error)
- func (z *RuntimeZone) RemoveForwardPort(ctx context.Context, fp ForwardPort) error
- func (z *RuntimeZone) RemoveIcmpBlock(ctx context.Context, icmptype string) error
- func (z *RuntimeZone) RemoveIcmpBlockInversion(ctx context.Context) error
- func (z *RuntimeZone) RemoveInterface(ctx context.Context, iface string) error
- func (z *RuntimeZone) RemoveMasquerade(ctx context.Context) error
- func (z *RuntimeZone) RemovePort(ctx context.Context, p Port) error
- func (z *RuntimeZone) RemoveProtocol(ctx context.Context, proto string) error
- func (z *RuntimeZone) RemoveRichRule(ctx context.Context, rule string) error
- func (z *RuntimeZone) RemoveService(ctx context.Context, service string) error
- func (z *RuntimeZone) RemoveSource(ctx context.Context, source string) error
- func (z *RuntimeZone) RemoveSourcePort(ctx context.Context, p Port) error
- func (z *RuntimeZone) RichRules(ctx context.Context) ([]string, error)
- func (z *RuntimeZone) Services(ctx context.Context) ([]string, error)
- func (z *RuntimeZone) SourcePorts(ctx context.Context) ([]Port, error)
- func (z *RuntimeZone) Sources(ctx context.Context) ([]string, error)
- type ServiceSettings
- type Signal
- type Target
- type Version
- type ZoneSettings
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyEnabled = errors.New("firewalld: already enabled") ErrNotEnabled = errors.New("firewalld: not enabled") ErrInvalidZone = errors.New("firewalld: invalid zone") ErrInvalidPort = errors.New("firewalld: invalid port") ErrInvalidProtocol = errors.New("firewalld: invalid protocol") ErrInvalidService = errors.New("firewalld: invalid service") ErrInvalidICMPType = errors.New("firewalld: invalid icmptype") ErrInvalidIPSet = errors.New("firewalld: invalid ipset") ErrInvalidInterface = errors.New("firewalld: invalid interface") ErrInvalidSource = errors.New("firewalld: invalid source") ErrInvalidPolicy = errors.New("firewalld: invalid policy") ErrInvalidHelper = errors.New("firewalld: invalid helper") ErrInvalidCommand = errors.New("firewalld: invalid command") ErrNameConflict = errors.New("firewalld: name conflict") ErrZoneConflict = errors.New("firewalld: zone conflict") ErrBuiltinZone = errors.New("firewalld: builtin zone") ErrAlreadySet = errors.New("firewalld: already set") ErrMissingName = errors.New("firewalld: missing name") ErrNotRunning = errors.New("firewalld: not running") ErrNotApplicable = errors.New("firewalld: not applicable") // ErrUnsupported is returned by this library (not firewalld) when a caller // asks for a feature the connected server's version does not provide. ErrUnsupported = errors.New("firewalld: operation not supported by this server version") )
Sentinel errors mapped from firewalld exception messages. Callers match with errors.Is. ErrAlreadyEnabled/ErrNotEnabled are the idempotency signals: an add of something already present, or a remove of something absent.
Functions ¶
This section is empty.
Types ¶
type ActiveZone ¶
ActiveZone pairs a zone name with the interfaces and sources currently bound to it, as reported by getActiveZones.
type Capability ¶
type Capability int
Capability names a version-gated feature of the firewalld D-Bus surface. Callers test support with Conn.Supports; internal code version-gates transports (tuple vs dict) on these flags.
const ( // DictZoneSettings gates the a{sv} zone-settings path (getSettings2/update2 on // config.zone, getZoneSettings2/setZoneSettings2 on the runtime .zone). Added // in firewalld 0.9. Absent on EL7 0.6.3, which uses the v1 tuple only. DictZoneSettings Capability = iota // Policies gates zone-to-zone policy objects (config listPolicies/addPolicy, // runtime getPolicySettings/getActivePolicies). Added in 0.9. Absent on EL7. Policies // ServiceSettings2 gates getServiceSettings2/addService2 (a{sv} services). // Present on 1.3.4, absent on 0.6.3. ServiceSettings2 // AddZone2 gates config.addZone2/addService2 (dict-based creation). Added 0.9. AddZone2 // ResetToDefaults gates the main resetToDefaults method. Present on 1.x. ResetToDefaults )
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a connection to the firewalld service on the system bus. It caches the server version and derived capabilities so callers can branch on Supports and internal code can pick the tuple or dict transport. A Conn is safe for concurrent use to the extent godbus's connection is.
func Connect ¶
Connect dials the system bus, reads the firewalld version property, and derives the capability set. The context bounds the connection and initial version read.
func Open ¶
Open builds a Conn on a caller-supplied bus connection. The caller retains ownership: Close will not tear the bus down. Useful for sharing a bus or for tests against a private connection.
func (*Conn) Call ¶
func (c *Conn) Call(ctx context.Context, path dbus.ObjectPath, iface, method string, rets []any, args ...any) error
Call is the low-level escape hatch for any method not yet wrapped by a typed helper. It targets the given object path and interface, passes args verbatim, and stores results into rets (pointers). Errors are mapped to sentinels.
func (*Conn) CheckPermanentConfig ¶
CheckPermanentConfig validates the on-disk permanent configuration, returning a firewalld error if it is inconsistent.
func (*Conn) Close ¶
Close releases the connection. If the bus was dialed by Connect it is closed; a bus adopted via Open is left open for its owner.
func (*Conn) CompleteReload ¶
CompleteReload reloads and also re-reads interface-to-zone bindings, dropping active runtime state. Heavier than Reload; use when the permanent set changed structurally.
func (*Conn) Config ¶
Config is an alias for Permanent, matching the firewalld config object naming used by callers that think in terms of "the config interface".
func (*Conn) DefaultZone ¶
DefaultZone returns the name of the default zone.
func (*Conn) DisablePanicMode ¶
DisablePanicMode restores normal packet processing.
func (*Conn) EnablePanicMode ¶
EnablePanicMode drops all inbound and outbound packets.
func (*Conn) HelperSettings ¶
HelperSettings reads a conntrack helper definition from the running firewall.
func (*Conn) ICMPTypeSettings ¶
ICMPTypeSettings reads an ICMP type definition from the running firewall.
func (*Conn) LogDenied ¶
LogDenied returns the current LogDenied setting ("off", "all", "unicast", ...).
func (*Conn) MainProperty ¶
MainProperty reads a single read-only property from the main object (e.g. "IPv4", "IPSetTypes", "nf_conntrack_helpers") for values not covered by a typed accessor.
func (*Conn) QueryPanicMode ¶
QueryPanicMode reports whether panic mode is active.
func (*Conn) Reload ¶
Reload reloads firewalld's permanent configuration into the runtime, keeping active bindings where possible.
func (*Conn) ResetToDefaults ¶
ResetToDefaults resets the permanent configuration to firewalld's defaults. Requires firewalld >= 1.0; returns ErrUnsupported on older servers.
func (*Conn) RuntimeInfo ¶
func (c *Conn) RuntimeInfo(ctx context.Context) (RuntimeInfo, error)
RuntimeInfo reads the main object's runtime properties in one round-trip.
func (*Conn) RuntimeToPermanent ¶
RuntimeToPermanent persists the current runtime configuration as permanent.
func (*Conn) ServiceSettings ¶
ServiceSettings reads a service definition from the running firewall, choosing the dict transport (getServiceSettings2) when available so includes/helpers are populated, and falling back to the v1 tuple otherwise.
func (*Conn) SetDefaultZone ¶
SetDefaultZone sets the default zone by name.
func (*Conn) SetLogDenied ¶
SetLogDenied sets the LogDenied value.
func (*Conn) Supports ¶
func (c *Conn) Supports(cap Capability) bool
Supports reports whether the connected server provides a capability.
func (*Conn) WatchReloaded ¶
WatchReloaded returns a channel that receives an empty struct each time firewalld emits its Reloaded signal, a convenience for callers that only need to re-read state after a reload.
func (*Conn) WatchSignals ¶
WatchSignals subscribes to firewalld's signals and returns a channel of typed events. The subscription and channel are torn down when ctx is cancelled. The channel is buffered; a slow consumer that lets it fill will drop no earlier events but may block delivery of later ones until drained.
type DaemonConfig ¶
type DaemonConfig struct {
DefaultZone string
MinimalMark int32
CleanupOnExit string
CleanupModulesOnExit string
Lockdown string
IPv6RPFilter string
IPv6RPFilter2 string // finer-grained rp_filter (newer firewalld)
IndividualCalls string
LogDenied string
AutomaticHelpers string
FirewallBackend string
FlushAllOnReload string
RFC3964IPv4 string
AllowZoneDrifting string
NftablesTableOwner string
NftablesCounters string // nftables rule counters (firewalld >= 2.0)
NftablesFlowtable string // nftables flowtable offload (firewalld >= 2.0)
StrictForwardPorts string // strict forward-port handling (firewalld >= 2.0)
}
DaemonConfig holds firewalld's permanent daemon settings (the firewalld.conf knobs). Fields absent on the connected version read as empty. Most values are firewalld's "yes"/"no" strings or an enum ("iptables"/"nftables"); they are exposed verbatim rather than coerced, since firewalld's own semantics vary.
type Direct ¶
type Direct struct {
// contains filtered or unexported fields
}
Direct is the entry point for firewalld's direct interface, which passes rules straight to the underlying iptables/nftables backend. It is a low-level escape hatch: firewalld does not manage or reconcile direct rules the way it does zones. All operations here are runtime (the direct interface has no per-element permanent methods; the permanent form is a single config.direct blob).
func (*Direct) AddChain ¶
func (d *Direct) AddChain(ctx context.Context, ch DirectChain) error
AddChain adds a custom chain (ipv, table, chain).
func (*Direct) AddPassthrough ¶
AddPassthrough persists a passthrough rule for an IP family.
func (*Direct) AddRule ¶
func (d *Direct) AddRule(ctx context.Context, r DirectRule) error
AddRule adds a direct rule at the given priority.
func (*Direct) AllChains ¶
func (d *Direct) AllChains(ctx context.Context) ([]DirectChain, error)
AllChains lists every custom chain across all families and tables.
func (*Direct) AllPassthroughs ¶
func (d *Direct) AllPassthroughs(ctx context.Context) ([]DirectPassthrough, error)
AllPassthroughs lists every passthrough rule across all IP families.
func (*Direct) AllRules ¶
func (d *Direct) AllRules(ctx context.Context) ([]DirectRule, error)
AllRules lists every direct rule across all families, tables, and chains.
func (*Direct) Passthrough ¶
Passthrough sends a raw command straight to the backend for an IP family and returns the backend's output.
func (*Direct) Passthroughs ¶
Passthroughs lists the passthrough rules for an IP family, each as an argv.
func (*Direct) QueryChain ¶
QueryChain reports whether a custom chain exists.
func (*Direct) QueryPassthrough ¶
QueryPassthrough reports whether a passthrough rule is present.
func (*Direct) RemoveAllPassthroughs ¶
RemoveAllPassthroughs clears all passthrough rules.
func (*Direct) RemoveChain ¶
func (d *Direct) RemoveChain(ctx context.Context, ch DirectChain) error
RemoveChain removes a custom chain.
func (*Direct) RemovePassthrough ¶
RemovePassthrough removes a passthrough rule.
func (*Direct) RemoveRule ¶
func (d *Direct) RemoveRule(ctx context.Context, r DirectRule) error
RemoveRule removes a direct rule matching the given fields exactly.
func (*Direct) RemoveRules ¶
RemoveRules removes all direct rules in a chain.
type DirectChain ¶
type DirectChain struct {
IPV string // "ipv4", "ipv6", or "eb" (ebtables)
Table string // e.g. "filter", "nat"
Chain string
}
DirectChain is a custom chain added through the direct interface.
type DirectConfig ¶
type DirectConfig struct {
Chains []DirectChain
Rules []DirectRule
Passthroughs []DirectPassthrough
}
DirectConfig is the complete permanent direct configuration: all custom chains, rules, and passthroughs. It maps to the config.direct tuple "(a(sss)a(sssias)a(sas))".
type DirectPassthrough ¶
DirectPassthrough is a passthrough rule tagged with its IP family, as returned by AllPassthroughs.
type DirectRule ¶
DirectRule is a rule added through the direct interface, including the chain it belongs to, its priority, and the raw backend arguments.
type Error ¶
type Error struct {
Code string // firewalld token, e.g. "INVALID_ZONE"; empty if none parsed
Message string // full exception message from firewalld
// contains filtered or unexported fields
}
Error wraps a firewalld D-Bus exception, preserving the raw code and message while chaining to a sentinel (via Unwrap) so errors.Is works. Errors that are not firewalld exceptions are returned unchanged by mapError.
type ForwardPort ¶
type ForwardPort struct {
Port string // incoming port or range
Protocol string // "tcp" | "udp"
ToPort string // destination port; empty keeps the same port
ToAddr string // destination address; empty forwards locally
}
ForwardPort describes a port-forward rule. Encodes to the tuple "(ssss)" in the field order firewalld expects: port, protocol, toport, toaddr.
type HelperSettings ¶
type HelperSettings struct {
Version string
Short string
Description string
Family string // "", "ipv4", or "ipv6"
Module string // e.g. "nf_conntrack_ftp"
Ports []Port
}
HelperSettings is the transport-neutral representation of a conntrack helper. It maps to the tuple "(sssssa(ss))": version, short, description, family, module, ports.
type ICMPTypeSettings ¶
type ICMPTypeSettings struct {
Version string
Short string
Description string
Destinations []string
}
ICMPTypeSettings is the transport-neutral representation of an ICMP type. It maps to the tuple "(sssas)": version, short, description, destinations. The destinations list holds the IP families the type applies to ("ipv4", "ipv6").
type IPSetSettings ¶
type IPSetSettings struct {
Version string
Name string
Description string
Type string // e.g. "hash:ip", "hash:net"
Options map[string]string // e.g. {"family": "inet"}
Entries []string
}
IPSetSettings is the transport-neutral representation of an ipset. It maps to the D-Bus tuple "(ssssa{ss}as)": version, name, description, type, options, entries. ipsets have no dict form; the tuple is used on every server.
type Lockdown ¶
type Lockdown struct {
// contains filtered or unexported fields
}
Lockdown controls firewalld's lockdown feature and its whitelist. Lockdown, when enabled, restricts which applications may change the firewall; the whitelist names the commands, contexts, users, and uids that remain allowed. These live on the main object's .policies interface (distinct from zone-to-zone policies).
func (*Lockdown) AddCommand ¶
Whitelist command operations. A command entry may end in "*" to match a prefix.
func (*Lockdown) AddContext ¶
Whitelist context (SELinux) operations.
func (*Lockdown) QueryCommand ¶
func (*Lockdown) QueryContext ¶
func (*Lockdown) RemoveCommand ¶
func (*Lockdown) RemoveContext ¶
type PermDirect ¶
type PermDirect struct {
// contains filtered or unexported fields
}
PermDirect reads and writes firewalld's permanent direct configuration as a single blob (the config.direct object), the permanent counterpart to the runtime Direct interface.
func (*PermDirect) Settings ¶
func (p *PermDirect) Settings(ctx context.Context) (DirectConfig, error)
Settings reads the whole permanent direct configuration.
func (*PermDirect) Update ¶
func (p *PermDirect) Update(ctx context.Context, cfg DirectConfig) error
Update replaces the whole permanent direct configuration.
type PermHelper ¶
type PermHelper struct {
// contains filtered or unexported fields
}
PermHelper is a handle for permanent edits to a single conntrack helper, operating on the helper's config child object (/config/helper/N).
func (*PermHelper) AddPort ¶
func (s *PermHelper) AddPort(ctx context.Context, p Port) error
AddPort adds a port to the permanent helper.
func (*PermHelper) Remove ¶
func (s *PermHelper) Remove(ctx context.Context) error
Remove deletes the helper from the permanent configuration.
func (*PermHelper) RemovePort ¶
func (s *PermHelper) RemovePort(ctx context.Context, p Port) error
RemovePort removes a port from the permanent helper.
func (*PermHelper) SetDescription ¶
func (s *PermHelper) SetDescription(ctx context.Context, description string) error
SetDescription sets the permanent helper description.
func (*PermHelper) SetFamily ¶
func (s *PermHelper) SetFamily(ctx context.Context, family string) error
SetFamily sets the helper's IP family ("", "ipv4", "ipv6").
func (*PermHelper) SetModule ¶
func (s *PermHelper) SetModule(ctx context.Context, module string) error
SetModule sets the helper's netfilter module name.
func (*PermHelper) Settings ¶
func (s *PermHelper) Settings(ctx context.Context) (HelperSettings, error)
Settings reads the helper's permanent settings.
func (*PermHelper) Update ¶
func (s *PermHelper) Update(ctx context.Context, settings HelperSettings) error
Update replaces the helper's permanent settings.
type PermICMPType ¶
type PermICMPType struct {
// contains filtered or unexported fields
}
PermICMPType is a handle for permanent edits to a single ICMP type, operating on the icmptype's config child object (/config/icmptype/N).
func (*PermICMPType) AddDestination ¶
func (s *PermICMPType) AddDestination(ctx context.Context, family string) error
AddDestination adds an IP family ("ipv4"/"ipv6") the type applies to.
func (*PermICMPType) QueryDestination ¶
QueryDestination reports whether the type applies to an IP family.
func (*PermICMPType) Remove ¶
func (s *PermICMPType) Remove(ctx context.Context) error
Remove deletes the ICMP type from the permanent configuration.
func (*PermICMPType) RemoveDestination ¶
func (s *PermICMPType) RemoveDestination(ctx context.Context, family string) error
RemoveDestination removes an IP family from the type.
func (*PermICMPType) SetDescription ¶
func (s *PermICMPType) SetDescription(ctx context.Context, description string) error
SetDescription sets the permanent ICMP type description.
func (*PermICMPType) Settings ¶
func (s *PermICMPType) Settings(ctx context.Context) (ICMPTypeSettings, error)
Settings reads the ICMP type's permanent settings.
func (*PermICMPType) Update ¶
func (s *PermICMPType) Update(ctx context.Context, settings ICMPTypeSettings) error
Update replaces the ICMP type's permanent settings.
type PermIPSet ¶
type PermIPSet struct {
// contains filtered or unexported fields
}
PermIPSet is a handle for permanent edits to a single ipset, operating on the ipset's config child object (/config/ipset/N).
func (*PermIPSet) QueryEntry ¶
QueryEntry reports whether an entry is present in the permanent ipset.
func (*PermIPSet) RemoveEntry ¶
RemoveEntry removes an entry from the permanent ipset.
func (*PermIPSet) RemoveOption ¶
RemoveOption removes an option from the permanent ipset.
func (*PermIPSet) SetDescription ¶
SetDescription sets the permanent ipset description.
func (*PermIPSet) SetEntries ¶
SetEntries replaces all entries of the permanent ipset.
type PermPolicy ¶
type PermPolicy struct {
// contains filtered or unexported fields
}
PermPolicy is a handle for permanent edits to a single policy, operating on the policy's config child object (/config/policy/N).
func (*PermPolicy) Remove ¶
func (s *PermPolicy) Remove(ctx context.Context) error
Remove deletes the policy from the permanent configuration.
func (*PermPolicy) Rename ¶
func (s *PermPolicy) Rename(ctx context.Context, newName string) error
Rename changes the policy's name and invalidates the cached path.
func (*PermPolicy) Settings ¶
func (s *PermPolicy) Settings(ctx context.Context) (PolicySettings, error)
Settings reads the policy's permanent settings.
func (*PermPolicy) Update ¶
func (s *PermPolicy) Update(ctx context.Context, settings PolicySettings) error
Update replaces the policy's permanent settings wholesale.
type PermService ¶
type PermService struct {
// contains filtered or unexported fields
}
PermService is a handle for permanent edits to a single service definition, operating on the service's config child object (/config/service/N).
func (*PermService) AddInclude ¶
func (s *PermService) AddInclude(ctx context.Context, service string) error
Include operations compose other services into this one (firewalld >= 1.0).
func (*PermService) AddModule ¶
func (s *PermService) AddModule(ctx context.Context, module string) error
Module (netfilter helper) operations.
func (*PermService) AddPort ¶
func (s *PermService) AddPort(ctx context.Context, p Port) error
Port operations.
func (*PermService) AddProtocol ¶
func (s *PermService) AddProtocol(ctx context.Context, proto string) error
Protocol operations.
func (*PermService) Includes ¶
func (s *PermService) Includes(ctx context.Context) ([]string, error)
func (*PermService) QueryInclude ¶
func (*PermService) Remove ¶
func (s *PermService) Remove(ctx context.Context) error
Remove deletes the service from the permanent configuration.
func (*PermService) RemoveDestination ¶
func (s *PermService) RemoveDestination(ctx context.Context, family string) error
RemoveDestination clears the destination for an IP family.
func (*PermService) RemoveInclude ¶
func (s *PermService) RemoveInclude(ctx context.Context, service string) error
func (*PermService) RemoveModule ¶
func (s *PermService) RemoveModule(ctx context.Context, module string) error
func (*PermService) RemovePort ¶
func (s *PermService) RemovePort(ctx context.Context, p Port) error
func (*PermService) RemoveProtocol ¶
func (s *PermService) RemoveProtocol(ctx context.Context, proto string) error
func (*PermService) SetDescription ¶
func (s *PermService) SetDescription(ctx context.Context, description string) error
SetDescription sets the permanent service description.
func (*PermService) SetDestination ¶
func (s *PermService) SetDestination(ctx context.Context, family, address string) error
SetDestination sets the destination address for an IP family ("ipv4"/"ipv6").
func (*PermService) Settings ¶
func (s *PermService) Settings(ctx context.Context) (ServiceSettings, error)
Settings reads the service's permanent settings via the v1 tuple.
func (*PermService) Update ¶
func (s *PermService) Update(ctx context.Context, settings ServiceSettings) error
Update replaces the service's permanent settings via the v1 tuple.
type PermZone ¶
type PermZone struct {
// contains filtered or unexported fields
}
PermZone is a handle for permanent edits to a single zone, operating on the zone's config child object (/config/zone/N). The object path is resolved once from the zone name and cached. Permanent element methods take no timeout and return nothing; changes apply after a Reload.
func (*PermZone) AddForwardPort ¶
func (z *PermZone) AddForwardPort(ctx context.Context, fp ForwardPort) error
ForwardPort operations.
func (*PermZone) AddIcmpBlock ¶
IcmpBlock operations.
func (*PermZone) AddIcmpBlockInversion ¶
IcmpBlockInversion operations.
func (*PermZone) AddInterface ¶
Interface operations.
func (*PermZone) AddMasquerade ¶
Masquerade operations.
func (*PermZone) AddProtocol ¶
Protocol operations.
func (*PermZone) AddRichRule ¶
RichRule operations.
func (*PermZone) AddService ¶
Service operations.
func (*PermZone) AddSourcePort ¶
SourcePort operations.
func (*PermZone) LoadDefaults ¶
LoadDefaults resets the zone to its built-in defaults.
func (*PermZone) QueryForwardPort ¶
func (*PermZone) QueryIcmpBlock ¶
func (*PermZone) QueryIcmpBlockInversion ¶
func (*PermZone) QueryInterface ¶
func (*PermZone) QueryMasquerade ¶
func (*PermZone) QueryProtocol ¶
func (*PermZone) QueryRichRule ¶
func (*PermZone) QueryService ¶
func (*PermZone) QuerySource ¶
func (*PermZone) QuerySourcePort ¶
func (*PermZone) RemoveForwardPort ¶
func (z *PermZone) RemoveForwardPort(ctx context.Context, fp ForwardPort) error
func (*PermZone) RemoveIcmpBlock ¶
func (*PermZone) RemoveIcmpBlockInversion ¶
func (*PermZone) RemoveInterface ¶
func (*PermZone) RemoveProtocol ¶
func (*PermZone) RemoveRichRule ¶
func (*PermZone) RemoveService ¶
func (*PermZone) RemoveSource ¶
func (*PermZone) RemoveSourcePort ¶
func (*PermZone) Rename ¶
Rename changes the zone's name. The cached path is invalidated so subsequent calls re-resolve under the new name.
func (*PermZone) SetDescription ¶
func (*PermZone) SetVersion ¶
type Permanent ¶
type Permanent struct {
// contains filtered or unexported fields
}
Permanent is the entry point for operations on firewalld's on-disk permanent configuration, mirroring firewall-cmd --permanent. Changes take effect after a Reload. It also exposes the config-object management methods (listing and creating zones, ipsets, services, and so on).
func (*Permanent) AddHelper ¶
func (p *Permanent) AddHelper(ctx context.Context, name string, settings HelperSettings) (dbus.ObjectPath, error)
AddHelper creates a new permanent conntrack helper and returns its config path.
func (*Permanent) AddICMPType ¶
func (p *Permanent) AddICMPType(ctx context.Context, name string, settings ICMPTypeSettings) (dbus.ObjectPath, error)
AddICMPType creates a new permanent ICMP type and returns its config path.
func (*Permanent) AddIPSet ¶
func (p *Permanent) AddIPSet(ctx context.Context, name string, settings IPSetSettings) (dbus.ObjectPath, error)
AddIPSet creates a new permanent ipset from the given settings and returns its config object path.
func (*Permanent) AddPolicy ¶
func (p *Permanent) AddPolicy(ctx context.Context, name string, settings PolicySettings) (dbus.ObjectPath, error)
AddPolicy creates a new permanent policy and returns its config object path.
func (*Permanent) AddService ¶
func (p *Permanent) AddService(ctx context.Context, name string, settings ServiceSettings) (dbus.ObjectPath, error)
AddService creates a new permanent service and returns its config object path.
func (*Permanent) AddZone ¶
func (p *Permanent) AddZone(ctx context.Context, name string, settings ZoneSettings) (dbus.ObjectPath, error)
AddZone creates a new permanent zone from the given settings and returns its object path. On dict-capable servers it uses addZone2; otherwise addZone with the v1 tuple.
func (*Permanent) ConfigProperty ¶
ConfigProperty reads a single daemon-config property by its firewalld name (e.g. "FirewallBackend", "IPv6_rpfilter").
func (*Permanent) DaemonConfig ¶
func (p *Permanent) DaemonConfig(ctx context.Context) (DaemonConfig, error)
DaemonConfig reads the config object's daemon-settings properties.
func (*Permanent) Direct ¶
func (p *Permanent) Direct() *PermDirect
Direct returns a handle for the permanent direct configuration.
func (*Permanent) Helper ¶
func (p *Permanent) Helper(name string) *PermHelper
Helper returns a handle for permanent operations on the named helper.
func (*Permanent) HelperNames ¶
HelperNames lists the names of all permanent conntrack helpers.
func (*Permanent) HelperPaths ¶
HelperPaths lists the config object paths of all permanent helpers.
func (*Permanent) ICMPType ¶
func (p *Permanent) ICMPType(name string) *PermICMPType
ICMPType returns a handle for permanent operations on the named ICMP type.
func (*Permanent) ICMPTypeNames ¶
ICMPTypeNames lists the names of all permanent ICMP types.
func (*Permanent) IPSetNames ¶
IPSetNames lists the names of all permanent ipsets.
func (*Permanent) IPSetPaths ¶
IPSetPaths lists the config object paths of all permanent ipsets (listIPSets).
func (*Permanent) Policy ¶
func (p *Permanent) Policy(name string) *PermPolicy
Policy returns a handle for permanent operations on the named policy.
func (*Permanent) PolicyNames ¶
PolicyNames lists the names of all permanent policies.
func (*Permanent) PolicyPaths ¶
PolicyPaths lists the config object paths of all permanent policies.
func (*Permanent) Service ¶
func (p *Permanent) Service(name string) *PermService
Service returns a handle for permanent operations on the named service.
func (*Permanent) ServiceNames ¶
ServiceNames lists the names of all permanent services.
func (*Permanent) SetConfigProperty ¶
SetConfigProperty writes a daemon-config property. Changes are permanent and take effect after a reload; most require privilege.
func (*Permanent) SetFirewallBackend ¶
SetFirewallBackend selects the packet backend ("nftables" or "iptables").
func (*Permanent) Zone ¶
Zone returns a handle for permanent operations on the named zone. The object path is resolved lazily on first use via getZoneByName.
func (*Permanent) ZoneOfInterface ¶
ZoneOfInterface returns the permanent zone bound to an interface, or "" if none.
func (*Permanent) ZoneOfSource ¶
ZoneOfSource returns the permanent zone bound to a source, or "" if none.
type PolicySettings ¶
type PolicySettings struct {
Version string
Short string
Description string
Target string // CONTINUE, ACCEPT, DROP, REJECT
Priority int32
IngressZones []string
EgressZones []string
Services []string
Ports []Port
SourcePorts []Port
ICMPBlocks []string
Masquerade bool
ForwardPorts []ForwardPort
RichRules []string
Protocols []string
}
PolicySettings is the transport-neutral representation of a zone-to-zone policy (firewalld >= 0.9). Policies have no v1 tuple form; they are exchanged only as an a{sv} dict. Ingress and egress zones define the traffic the policy governs; the remaining fields mirror a zone's filtering elements.
type Port ¶
type Port struct {
Port string // single port "80" or range "1000-2000"
Protocol string // "tcp" | "udp" | "sctp" | "dccp"
}
Port is a port-or-range with its protocol. Encodes to the D-Bus tuple "(ss)".
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the entry point for transient operations on the running firewall. Edits made here last until the next reload unless given a timeout, mirroring firewall-cmd without --permanent.
func (*Runtime) ActivePolicies ¶
ActivePolicies returns the policies that currently have zones bound.
func (*Runtime) ActiveZones ¶
func (r *Runtime) ActiveZones(ctx context.Context) ([]ActiveZone, error)
ActiveZones returns the zones that currently have interfaces or sources bound. getActiveZones returns a{sa{sas}}: zone -> {"interfaces": [...], "sources": [...]}.
func (*Runtime) IPSet ¶
func (r *Runtime) IPSet(name string) *RuntimeIPSet
IPSet returns a handle for runtime operations on the named ipset.
func (*Runtime) IPSetExists ¶
IPSetExists reports whether an ipset of the given name exists at runtime.
func (*Runtime) Policies ¶
Policies lists the names of all policies known to the runtime. Returns ErrUnsupported on servers that predate policy support (firewalld < 0.9).
func (*Runtime) PolicySettings ¶
PolicySettings reads a policy definition from the running firewall.
func (*Runtime) SetPolicySettings ¶
func (r *Runtime) SetPolicySettings(ctx context.Context, policy string, settings PolicySettings) error
SetPolicySettings replaces a policy's runtime settings wholesale.
func (*Runtime) SetSettings ¶
SetSettings replaces a zone's runtime settings wholesale via setZoneSettings2. This is a dict-only path (firewalld >= 0.9); older servers expose no runtime settings writer, so it returns ErrUnsupported there.
func (*Runtime) Settings ¶
Settings reads the runtime settings of a zone. On dict-capable servers it uses getZoneSettings2; otherwise it falls back to the main getZoneSettings tuple.
func (*Runtime) Zone ¶
func (r *Runtime) Zone(name string) *RuntimeZone
Zone returns a handle for runtime operations on the named zone.
func (*Runtime) ZoneOfInterface ¶
ZoneOfInterface returns the zone an interface is bound to at runtime, or "" if none.
func (*Runtime) ZoneOfSource ¶
ZoneOfSource returns the zone a source is bound to at runtime, or "" if none.
type RuntimeIPSet ¶
type RuntimeIPSet struct {
// contains filtered or unexported fields
}
RuntimeIPSet is a handle for transient ipset entry operations on the running firewall. ipset runtime methods live on the main object's .ipset interface.
func (*RuntimeIPSet) AddEntry ¶
func (s *RuntimeIPSet) AddEntry(ctx context.Context, entry string) error
AddEntry adds a single entry to the ipset at runtime.
func (*RuntimeIPSet) Entries ¶
func (s *RuntimeIPSet) Entries(ctx context.Context) ([]string, error)
Entries returns all entries of the ipset at runtime.
func (*RuntimeIPSet) QueryEntry ¶
QueryEntry reports whether an entry is present at runtime.
func (*RuntimeIPSet) RemoveEntry ¶
func (s *RuntimeIPSet) RemoveEntry(ctx context.Context, entry string) error
RemoveEntry removes a single entry from the ipset at runtime.
func (*RuntimeIPSet) SetEntries ¶
func (s *RuntimeIPSet) SetEntries(ctx context.Context, entries []string) error
SetEntries replaces all entries of the ipset at runtime.
func (*RuntimeIPSet) Settings ¶
func (s *RuntimeIPSet) Settings(ctx context.Context) (IPSetSettings, error)
Settings reads the runtime settings of the ipset.
type RuntimeInfo ¶
type RuntimeInfo struct {
State string
InterfaceVer string
IPv4 bool
IPv6 bool
IPv6RPFilter bool
Bridge bool
IPSet bool
IPSetTypes []string
IPv4ICMPTypes []string
IPv6ICMPTypes []string
}
RuntimeInfo captures the main object's read-only capability and state properties, describing what the running firewalld supports.
type RuntimeZone ¶
type RuntimeZone struct {
// contains filtered or unexported fields
}
RuntimeZone is a handle for transient edits to a single zone. Add methods take a timeout (zero for none) and return the affected zone name from firewalld.
func (*RuntimeZone) AddForwardPort ¶
func (z *RuntimeZone) AddForwardPort(ctx context.Context, fp ForwardPort, timeout time.Duration) error
ForwardPort operations.
func (*RuntimeZone) AddIcmpBlock ¶
func (z *RuntimeZone) AddIcmpBlock(ctx context.Context, icmptype string, timeout time.Duration) error
IcmpBlock operations.
func (*RuntimeZone) AddIcmpBlockInversion ¶
IcmpBlockInversion operations. Add takes a timeout; the others do not.
func (*RuntimeZone) AddInterface ¶
func (z *RuntimeZone) AddInterface(ctx context.Context, iface string) error
Interface operations bind and unbind network interfaces to the zone at runtime.
func (*RuntimeZone) AddMasquerade ¶
Masquerade operations. Add takes a timeout; the others do not.
func (*RuntimeZone) AddProtocol ¶
Protocol operations.
func (*RuntimeZone) AddRichRule ¶
RichRule operations.
func (*RuntimeZone) AddService ¶
Service operations.
func (*RuntimeZone) AddSource ¶
func (z *RuntimeZone) AddSource(ctx context.Context, source string) error
Source operations. Unlike ports/services, a source binding is not timed, so AddSource takes no timeout (firewalld's addSource has no timeout argument).
func (*RuntimeZone) AddSourcePort ¶
SourcePort operations.
func (*RuntimeZone) ChangeInterface ¶
func (z *RuntimeZone) ChangeInterface(ctx context.Context, iface string) error
ChangeInterface moves an interface into this zone, detaching it from whatever zone currently owns it. Unlike AddInterface, it does not fail if the interface is already bound elsewhere (firewall-cmd --change-interface).
func (*RuntimeZone) ChangeSource ¶
func (z *RuntimeZone) ChangeSource(ctx context.Context, source string) error
ChangeSource moves a source into this zone, detaching it from its current zone.
func (*RuntimeZone) ForwardPorts ¶
func (z *RuntimeZone) ForwardPorts(ctx context.Context) ([]ForwardPort, error)
ForwardPorts returns the runtime forward ports as typed values.
func (*RuntimeZone) ICMPBlocks ¶
func (z *RuntimeZone) ICMPBlocks(ctx context.Context) ([]string, error)
func (*RuntimeZone) Interfaces ¶
func (z *RuntimeZone) Interfaces(ctx context.Context) ([]string, error)
func (*RuntimeZone) Name ¶
func (z *RuntimeZone) Name() string
Name returns the zone name this handle targets.
func (*RuntimeZone) Ports ¶
func (z *RuntimeZone) Ports(ctx context.Context) ([]Port, error)
Ports returns the runtime ports as typed pairs.
func (*RuntimeZone) Protocols ¶
func (z *RuntimeZone) Protocols(ctx context.Context) ([]string, error)
func (*RuntimeZone) QueryForwardPort ¶
func (z *RuntimeZone) QueryForwardPort(ctx context.Context, fp ForwardPort) (bool, error)
func (*RuntimeZone) QueryIcmpBlock ¶
func (*RuntimeZone) QueryIcmpBlockInversion ¶
func (z *RuntimeZone) QueryIcmpBlockInversion(ctx context.Context) (bool, error)
func (*RuntimeZone) QueryInterface ¶
func (*RuntimeZone) QueryMasquerade ¶
func (z *RuntimeZone) QueryMasquerade(ctx context.Context) (bool, error)
func (*RuntimeZone) QueryProtocol ¶
func (*RuntimeZone) QueryRichRule ¶
func (*RuntimeZone) QueryService ¶
func (*RuntimeZone) QuerySource ¶
func (*RuntimeZone) QuerySourcePort ¶
func (*RuntimeZone) RemoveForwardPort ¶
func (z *RuntimeZone) RemoveForwardPort(ctx context.Context, fp ForwardPort) error
func (*RuntimeZone) RemoveIcmpBlock ¶
func (z *RuntimeZone) RemoveIcmpBlock(ctx context.Context, icmptype string) error
func (*RuntimeZone) RemoveIcmpBlockInversion ¶
func (z *RuntimeZone) RemoveIcmpBlockInversion(ctx context.Context) error
func (*RuntimeZone) RemoveInterface ¶
func (z *RuntimeZone) RemoveInterface(ctx context.Context, iface string) error
func (*RuntimeZone) RemoveMasquerade ¶
func (z *RuntimeZone) RemoveMasquerade(ctx context.Context) error
func (*RuntimeZone) RemovePort ¶
func (z *RuntimeZone) RemovePort(ctx context.Context, p Port) error
func (*RuntimeZone) RemoveProtocol ¶
func (z *RuntimeZone) RemoveProtocol(ctx context.Context, proto string) error
func (*RuntimeZone) RemoveRichRule ¶
func (z *RuntimeZone) RemoveRichRule(ctx context.Context, rule string) error
func (*RuntimeZone) RemoveService ¶
func (z *RuntimeZone) RemoveService(ctx context.Context, service string) error
func (*RuntimeZone) RemoveSource ¶
func (z *RuntimeZone) RemoveSource(ctx context.Context, source string) error
func (*RuntimeZone) RemoveSourcePort ¶
func (z *RuntimeZone) RemoveSourcePort(ctx context.Context, p Port) error
func (*RuntimeZone) RichRules ¶
func (z *RuntimeZone) RichRules(ctx context.Context) ([]string, error)
func (*RuntimeZone) Services ¶
func (z *RuntimeZone) Services(ctx context.Context) ([]string, error)
Getters for the current runtime element lists.
func (*RuntimeZone) SourcePorts ¶
func (z *RuntimeZone) SourcePorts(ctx context.Context) ([]Port, error)
SourcePorts returns the runtime source ports as typed pairs.
type ServiceSettings ¶
type ServiceSettings struct {
Version string
Short string
Description string
Ports []Port
Modules []string // netfilter helper modules
Destinations map[string]string // family -> address, e.g. {"ipv4": "224.0.0.0/8"}
Protocols []string
SourcePorts []Port
Includes []string // dict-only (firewalld >= 1.0)
Helpers []string // dict-only (firewalld >= 1.0)
}
ServiceSettings is the transport-neutral representation of a firewalld service. It maps to the v1 tuple "(sssa(ss)asa{ss}asa(ss))": version, short, description, ports, modules, destinations, protocols, source_ports. Newer firewalld also exposes includes/helpers via the dict form (getSettings2), which are modelled here and populated when the dict transport is available.
type Signal ¶
type Signal struct {
Member string
Interface string
Path dbus.ObjectPath
Body []any
}
Signal is a firewalld D-Bus signal delivered to a watcher. Member is the short signal name (e.g. "Reloaded", "PortAdded"); Interface is the emitting interface; Body carries the signal's arguments in firewalld's declared order.
type Version ¶
Version is a parsed firewalld version. Missing components read as zero, so a server reporting "1" compares equal to "1.0.0".
type ZoneSettings ¶
type ZoneSettings struct {
Version string
Short string
Description string
Target Target
Services []string
Ports []Port
ICMPBlocks []string
Masquerade bool
ForwardPorts []ForwardPort
Interfaces []string
Sources []string
RichRules []string
Protocols []string
SourcePorts []Port
ICMPBlockInversion bool
// v2-only (dict) fields.
Forward bool // intra-zone forwarding (firewalld >= 0.9)
EgressPriority int32 // zone egress priority (newer firewalld)
IngressPriority int32 // zone ingress priority (newer firewalld)
}
ZoneSettings is the complete, transport-neutral representation of a zone's configuration. It is populated from either the v1 tuple (EL7 and up) or the v2 dict (firewalld >= 0.9) and encodes back through whichever transport the server supports. The final three fields exist only in the v2 dict; on the tuple path they are ignored on write and left zero on read.