linuxcalls

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// command names
	IPv4SaveCmd    string = "iptables-save"
	IPv4RestoreCmd string = "iptables-restore"
	IPv6RestoreCmd string = "ip6tables-restore"
	IPv6SaveCmd    string = "ip6tables-save"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerConfig added in v3.2.0

type HandlerConfig struct {
	MinRuleCountForPerfRuleAddition int `json:"min-rule-count-for-performance-rule-addition"`
}

HandlerConfig holds the IPTablesHandler related configuration.

type IPTablesAPI

type IPTablesAPI interface {
	// Init initializes an iptables handler.
	Init(config *HandlerConfig) 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

	// AppendRules appends rules into the specified chain.
	AppendRules(protocol L3Protocol, table, chain string, rules ...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) AppendRules added in v3.2.0

func (h *IPTablesHandler) AppendRules(protocol L3Protocol, table, chain string, rules ...string) error

AppendRules appends rules 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(config *HandlerConfig) 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
)

Jump to

Keyboard shortcuts

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