linuxcalls

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

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

	// protocol deletes all rules within the specified chain.
	DeleteAllRules(proto 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
)

Jump to

Keyboard shortcuts

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