iptables

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package iptables implements objects that manipulate netfilter rules by calling the iptables binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iptables added in v0.3.11

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

Iptables adds and removes iptables rules by executing the `iptables` binary.

func New added in v0.3.11

func New(executor runtime.Executor) Iptables

New returns a new Iptables ready to use.

func (Iptables) Add added in v0.3.11

func (i Iptables) Add(r Rule) error

Add appends a rule into the corresponding table and chain.

func (Iptables) Remove added in v0.3.11

func (i Iptables) Remove(r Rule) error

Remove removes an existing rule. If the rule does not exist, an error is returned.

type Rule added in v0.3.11

type Rule struct {
	// Table is the netfilter table to which this rule belongs. It is usually "filter".
	Table string
	// Chain is the netfilter chain to which this rule belongs. Usual values are "INPUT", "OUTPUT".
	Chain string
	// Args is the rest of the netfilter rule.
	// Arguments must be space-separated. Using shell-style quotes or backslashes to group more than one space-separated
	// word as one argument is not allowed.
	Args string
}

Rule is a netfilter/iptables rule.

type RuleSet added in v0.3.11

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

RuleSet is a stateful object that allows adding rules and keeping track of them to remove them later.

func NewRuleSet added in v0.3.11

func NewRuleSet(iptables Iptables) *RuleSet

NewRuleSet builds a RuleSet that uses the provided Iptables instance to add and remove rules.

func (*RuleSet) Add added in v0.3.11

func (i *RuleSet) Add(r Rule) error

Add adds a rule. Added rule will be remembered and removed later together with other rules when Remove is called.

func (*RuleSet) Remove added in v0.3.11

func (i *RuleSet) Remove() error

Remove removes all added rules. If an error occurs, Remove continues to try and remove remaining rules.

Jump to

Keyboard shortcuts

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