utils

package
Version: v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 4 Imported by: 20

Documentation

Index

Constants

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 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