Documentation
¶
Overview ¶
Package iptables provides an interface and implementations for running iptables commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIptablesVersion ¶ added in v0.20.0
func GetIptablesVersion(exec utilexec.Interface) (int, int, int, error)
GetIptablesVersion returns the major minor and patch version of iptables which will all be zero in case of error, and any error encountered.
Types ¶
type Chain ¶
type Chain string
const (
ChainPostrouting Chain = "POSTROUTING"
ChainPrerouting Chain = "PREROUTING"
ChainOutput Chain = "OUTPUT"
)
type Interface ¶
type Interface interface {
// EnsureChain checks if the specified chain exists and, if not, creates it. If the chain existed, return true.
EnsureChain(table Table, chain Chain) (bool, error)
// FlushChain clears the specified chain. If the chain did not exist, return error.
FlushChain(table Table, chain Chain) error
// DeleteChain deletes the specified chain. If the chain did not exist, return error.
DeleteChain(table Table, chain Chain) error
// EnsureRule checks if the specified rule is present and, if not, creates it. If the rule existed, return true.
EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error)
// DeleteRule checks if the specified rule is present and, if so, deletes it.
DeleteRule(table Table, chain Chain, args ...string) error
// IsIpv6 returns true if this is managing ipv6 tables
IsIpv6() bool
}
An injectable interface for running iptables commands. Implementations must be goroutine-safe.
type Protocol ¶ added in v0.5.1
type Protocol byte
const (
ProtocolIpv4 Protocol = iota + 1
ProtocolIpv6
)
type RulePosition ¶ added in v0.18.0
type RulePosition string
const (
Prepend RulePosition = "-I"
Append RulePosition = "-A"
)
Click to show internal directories.
Click to hide internal directories.