iptables

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FwdTable  = "nat"
	FwdChain  = "PREROUTING"
	FwdTarget = "DNAT"
)

Functions

This section is empty.

Types

type IPTablesInstance added in v0.9.1

type IPTablesInstance struct {
	*iptables.IPTables
}

func NewIPTablesInstance added in v0.9.1

func NewIPTablesInstance() (*IPTablesInstance, error)

func (*IPTablesInstance) CreateForward added in v0.9.1

func (ipt *IPTablesInstance) CreateForward(rule *Rule) error

func (*IPTablesInstance) DeleteAllForwards added in v0.9.1

func (ipt *IPTablesInstance) DeleteAllForwards() error

func (*IPTablesInstance) DeleteForwardById added in v0.9.1

func (ipt *IPTablesInstance) DeleteForwardById(ruleId int) error

func (*IPTablesInstance) DeleteForwardByRule added in v0.9.1

func (ipt *IPTablesInstance) DeleteForwardByRule(rule *Rule) error

func (*IPTablesInstance) ListForward added in v0.9.1

func (ipt *IPTablesInstance) ListForward(outputFormat string) (map[int]string, error)

func (*IPTablesInstance) ValidateForward added in v0.9.1

func (ipt *IPTablesInstance) ValidateForward(rule *Rule) error

type Rule added in v0.7.1

type Rule struct {
	Iface   string `json:"iface" yaml:"iface" default:"lo"`
	Proto   string `json:"proto" yaml:"proto" default:"tcp"`
	Dport   int    `json:"dport" yaml:"dport"`
	Saddr   string `json:"saddr" yaml:"saddr"`
	Sport   int    `json:"sport" yaml:"sport"`
	Comment string `json:"comment,omitempty" yaml:"comment,omitempty"`
}

func ExtractRuleInfo added in v0.9.1

func ExtractRuleInfo(rawRule string) (*Rule, error)

ExtractRuleInfo extract forward information from rule if it matches the requirements. Returns the Rule struct and error

func NewRule added in v0.9.1

func NewRule(iface string, proto string, dport int, saddr string, sport int) *Rule

func (*Rule) String added in v0.9.1

func (rule *Rule) String() []string

String returns a list of string that compose the iptables rule. Eg: -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 3000 -m comment --comment fwdctl -j DNAT --to-destination 192.168.199.105:80

Jump to

Keyboard shortcuts

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