Documentation ¶
Overview ¶
Package firewall wraps basic iptables call to control filtering of incoming/outgoing traffic.
Index ¶
- func ExecuteCommand(ctx context.Context, conn *ssh.Conn, ruleOpt ...RuleOption) error
- type Chain
- type Command
- type L4Proto
- type RuleOption
- func OptionAppendRule(chain Chain) RuleOption
- func OptionDPort(port int) RuleOption
- func OptionDPortRange(portFrom, portTo int) RuleOption
- func OptionDeleteRule(chain Chain) RuleOption
- func OptionJumpTarget(target Target) RuleOption
- func OptionProto(proto L4Proto) RuleOption
- func OptionWait(seconds int) RuleOption
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommand ¶
ExecuteCommand Adds/deletes an iptables rule.
Types ¶
type Command ¶
type Command string
Command is an enum type defining firewall command.
const ( // CommandAppend add rule. CommandAppend Command = "-A" // CommandDelete del rule. CommandDelete = "-D" )
type L4Proto ¶
type L4Proto string
L4Proto is an enum type describing layer 4 protocol to filter.
const ( // L4ProtoTCP Layer 4 protocol: TCP. L4ProtoTCP L4Proto = "tcp" // L4ProtoUDP Layer 4 protocol: UDP. L4ProtoUDP = "udp" )
type RuleOption ¶
type RuleOption func(*[]string)
RuleOption is used to provide extra options for iptables to filter by.
func OptionAppendRule ¶
func OptionAppendRule(chain Chain) RuleOption
OptionAppendRule appends a new rule to a given chain.
func OptionDPort ¶
func OptionDPort(port int) RuleOption
OptionDPort sets up the destination port option to a single value.
func OptionDPortRange ¶
func OptionDPortRange(portFrom, portTo int) RuleOption
OptionDPortRange sets up the destination port option to a value range.
func OptionDeleteRule ¶
func OptionDeleteRule(chain Chain) RuleOption
OptionDeleteRule deletes a rule from a given chain.
func OptionJumpTarget ¶
func OptionJumpTarget(target Target) RuleOption
OptionJumpTarget sets up the target option to request jump to a new chain.
func OptionProto ¶
func OptionProto(proto L4Proto) RuleOption
OptionProto sets up the Layer4 protocol option.
func OptionWait ¶
func OptionWait(seconds int) RuleOption
OptionWait sets up the wait time for xtables lock.