utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 47

Documentation

Index

Constants

View Source
const (
	PROTOCOL_TCP  = 6
	PROTOCOL_UDP  = 17
	PROTOCOL_SCTP = 132
)

Assigned Internet Protocol Numbers https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

View Source
const MaxHashLen = sha512.Size * 2

Variables

This section is empty.

Functions

func ChainExists added in v0.8.4

func ChainExists(ipt *iptables.IPTables, table, chain string) (bool, error)

ChainExists checks whether an iptables chain exists.

func ClearChain added in v0.8.4

func ClearChain(ipt *iptables.IPTables, table, chain string) error

ClearChain idempotently clear the iptables rules in the specified table/chain. If the chain does not exist, a new one will be created

func DeleteChain added in v0.8.4

func DeleteChain(ipt *iptables.IPTables, table, chain string) error

DeleteChain idempotently deletes the specified table/chain. It does not return an errors if the chain does not exist

func DeleteConntrackEntriesForDstIP added in v0.9.0

func DeleteConntrackEntriesForDstIP(dstIP string, protocol uint8) error

DeleteConntrackEntriesForDstIP delete the conntrack entries for the connections specified by the given destination IP and protocol

func DeleteConntrackEntriesForDstPort added in v0.9.0

func DeleteConntrackEntriesForDstPort(port uint16, protocol uint8, family netlink.InetFamily) error

DeleteConntrackEntriesForDstPort delete the conntrack entries for the connections specified by the given destination port, protocol and IP family

func DeleteRule added in v0.8.4

func DeleteRule(ipt *iptables.IPTables, table, chain string, rulespec ...string) error

DeleteRule idempotently delete the iptables rule in the specified table/chain. It does not return an error if the referring chain doesn't exist

func EnsureChain added in v0.8.4

func EnsureChain(ipt *iptables.IPTables, table, chain string) error

EnsureChain idempotently creates the iptables chain. It does not return an error if the chain already exists.

func FormatChainName

func FormatChainName(name string, id string) string

FormatChainName generates a chain name to be used with iptables. Ensures that the generated chain name is exactly maxChainLength chars in length.

func FormatComment

func FormatComment(name string, id string) string

FormatComment returns a comment used for easier rule identification within iptables.

func MustFormatChainNameWithPrefix added in v0.8.2

func MustFormatChainNameWithPrefix(name string, id string, prefix string) string

MustFormatChainNameWithPrefix generates a chain name similar to FormatChainName, but adds a custom prefix between chainPrefix and unique identifier. Ensures that the generated chain name is exactly maxChainLength chars in length. Panics if the given prefix is too long.

func MustFormatHashWithPrefix added in v0.8.2

func MustFormatHashWithPrefix(length int, prefix string, toHash string) string

MustFormatHashWithPrefix returns a string of given length that begins with the given prefix. It is filled with entropy based on the given string toHash.

Types

This section is empty.

Directories

Path Synopsis
Buildversion is a destination for the linker trickery so we can auto set the build-version
Buildversion is a destination for the linker trickery so we can auto set the build-version

Jump to

Keyboard shortcuts

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