util

package
v0.0.0-...-606a1df Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MinCheckVersion = "1.4.11"

Versions of iptables less than this do not support the -C / --check flag (test whether a rule exists).

View Source
const MinWait2Version = "1.4.22"
View Source
const MinWaitVersion = "1.4.20"

Minimum iptables versions supporting the -w and -w2 flags

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the error indicates "not found". It parses the error string looking for known values, which is imperfect but works in practice.

func ListenForHealth

func ListenForHealth(primaryInterface string, port int, logger logrus.FieldLogger)

listens on a port and returns a set of information about the health of the system

Types

type Chain

type Chain string
const (
	ChainPostrouting Chain = "POSTROUTING"
	ChainPrerouting  Chain = "PREROUTING"
	ChainOutput      Chain = "OUTPUT"
	ChainInput       Chain = "INPUT"
)

func (Chain) String

func (c Chain) String() string

type FlushFlag

type FlushFlag bool

Option flag for Flush

const FlushTables FlushFlag = true
const NoFlushTables FlushFlag = false

type Protocol

type Protocol byte
const (
	ProtocolIpv4 Protocol = iota + 1
	ProtocolIpv6
)

type RestoreCountersFlag

type RestoreCountersFlag bool

Option flag for Restore

const NoRestoreCounters RestoreCountersFlag = false
const RestoreCounters RestoreCountersFlag = true

type RulePosition

type RulePosition string
const (
	Prepend RulePosition = "-I"
	Append  RulePosition = "-A"
)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner implements Interface in terms of exec("iptables").

func New

func New(exec utilexec.Interface, dbus utildbus.Interface, protocol Protocol) *Runner

New returns a new Interface which will exec iptables.

func NewDefault

func NewDefault() *Runner

NewDefault returns an interface which will exec iptables, instantiating exec and dbus interfaces that are unique to this instance

func (*Runner) AddReloadFunc

func (runner *Runner) AddReloadFunc(reloadFunc func())

AddReloadFunc is part of Interface

func (*Runner) CheckRule

func (runner *Runner) CheckRule(table Table, chain Chain, args ...string) (bool, error)

func (*Runner) ConnectToFirewallD

func (runner *Runner) ConnectToFirewallD()

Connects to D-Bus and listens for FirewallD start/restart. (On non-FirewallD-using systems, this is effectively a no-op; we listen for the signals, but they will never be emitted, so reload() will never be called.)

func (*Runner) DeleteChain

func (runner *Runner) DeleteChain(table Table, chain Chain) error

func (*Runner) DeleteRule

func (runner *Runner) DeleteRule(table Table, chain Chain, args ...string) error

func (*Runner) Destroy

func (runner *Runner) Destroy()

Destroy is part of Interface.

func (*Runner) EnsureChain

func (runner *Runner) EnsureChain(table Table, chain Chain) (bool, error)

func (*Runner) EnsureRule

func (runner *Runner) EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error)

func (*Runner) FlushChain

func (runner *Runner) FlushChain(table Table, chain Chain) error

func (*Runner) GetVersion

func (runner *Runner) GetVersion() (string, error)

GetVersion returns the version string.

func (*Runner) IsIpv6

func (runner *Runner) IsIpv6() bool

func (*Runner) Restore

func (runner *Runner) Restore(table Table, data []byte, flush FlushFlag, counters RestoreCountersFlag) error

func (*Runner) RestoreAll

func (runner *Runner) RestoreAll(data []byte, flush FlushFlag, counters RestoreCountersFlag) error

func (*Runner) Save

func (runner *Runner) Save(table Table) ([]byte, error)

Save is part of Interface.

func (*Runner) SaveAll

func (runner *Runner) SaveAll() ([]byte, error)

type Table

type Table string
const (
	TableNAT    Table = "nat"
	TableFilter Table = "filter"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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