Documentation ¶
Index ¶
- type IPTablesAPI
- type IPTablesAPIRead
- type IPTablesAPIWrite
- type IPTablesHandler
- func (h *IPTablesHandler) AppendRule(protocol L3Protocol, table, chain string, rule string) error
- func (h *IPTablesHandler) CreateChain(protocol L3Protocol, table, chain string) error
- func (h *IPTablesHandler) DeleteAllRules(protocol L3Protocol, table, chain string) error
- func (h *IPTablesHandler) DeleteChain(protocol L3Protocol, table, chain string) error
- func (h *IPTablesHandler) DeleteRule(protocol L3Protocol, table, chain string, rule string) error
- func (h *IPTablesHandler) Init() error
- func (h *IPTablesHandler) ListRules(protocol L3Protocol, table, chain string) (rules []string, err error)
- func (h *IPTablesHandler) SetChainDefaultPolicy(protocol L3Protocol, table, chain, defaultPolicy string) error
- type L3Protocol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPTablesAPI ¶
type IPTablesAPI interface { // Init initializes an iptables handler. Init() error IPTablesAPIWrite IPTablesAPIRead }
IPTablesAPI interface covers all methods inside linux calls package needed to manage linux iptables rules.
type IPTablesAPIRead ¶
type IPTablesAPIRead interface { // ListRules lists all rules within the specified chain. ListRules(protocol L3Protocol, table, chain string) (rules []string, err error) }
IPTablesAPIRead interface covers read methods inside linux calls package needed to manage linux iptables rules.
type IPTablesAPIWrite ¶
type IPTablesAPIWrite interface { // CreateChain creates an iptables chain in the specified table. CreateChain(protocol L3Protocol, table, chain string) error // DeleteChain deletes an iptables chain in the specified table. DeleteChain(protocol L3Protocol, table, chain string) error // SetChainDefaultPolicy sets default policy in the specified chain. Should be called only on FILTER tables. SetChainDefaultPolicy(protocol L3Protocol, table, chain, defaultPolicy string) error // AppendRule appends a rule into the specified chain. AppendRule(protocol L3Protocol, table, chain string, rule string) error // DeleteRule deletes a rule from the specified chain. DeleteRule(protocol L3Protocol, table, chain string, rule string) error // DeleteAllRules deletes all rules within the specified chain. DeleteAllRules(protocol L3Protocol, table, chain string) error }
IPTablesAPIWrite interface covers write methods inside linux calls package needed to manage linux iptables rules.
type IPTablesHandler ¶
type IPTablesHandler struct {
// contains filtered or unexported fields
}
IPTablesHandler is a handler for all operations on Linux iptables / ip6tables.
func NewIPTablesHandler ¶
func NewIPTablesHandler() *IPTablesHandler
NewIPTablesHandler creates new instance of iptables handler.
func (*IPTablesHandler) AppendRule ¶
func (h *IPTablesHandler) AppendRule(protocol L3Protocol, table, chain string, rule string) error
AppendRule appends a rule into the specified chain.
func (*IPTablesHandler) CreateChain ¶
func (h *IPTablesHandler) CreateChain(protocol L3Protocol, table, chain string) error
CreateChain creates an iptables chain in the specified table.
func (*IPTablesHandler) DeleteAllRules ¶
func (h *IPTablesHandler) DeleteAllRules(protocol L3Protocol, table, chain string) error
DeleteAllRules deletes all rules within the specified chain.
func (*IPTablesHandler) DeleteChain ¶
func (h *IPTablesHandler) DeleteChain(protocol L3Protocol, table, chain string) error
DeleteChain deletes an iptables chain in the specified table.
func (*IPTablesHandler) DeleteRule ¶
func (h *IPTablesHandler) DeleteRule(protocol L3Protocol, table, chain string, rule string) error
DeleteRule deletes a rule from the specified chain.
func (*IPTablesHandler) Init ¶
func (h *IPTablesHandler) Init() error
Init initializes an iptables handler.
func (*IPTablesHandler) ListRules ¶
func (h *IPTablesHandler) ListRules(protocol L3Protocol, table, chain string) (rules []string, err error)
ListRules lists all rules within the specified chain.
func (*IPTablesHandler) SetChainDefaultPolicy ¶
func (h *IPTablesHandler) SetChainDefaultPolicy(protocol L3Protocol, table, chain, defaultPolicy string) error
SetChainDefaultPolicy sets default policy in the specified chain. Should be called only on FILTER tables.
type L3Protocol ¶
type L3Protocol byte
L3Protocol to differentiate between IPv4 and IPv6
const ( ProtocolIPv4 L3Protocol = iota ProtocolIPv6 )