utils

package
v1.1.0-jmanero Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDestinationNatRewriteRules

func AddDestinationNatRewriteRules(opts map[string]interface{}) error

AddDestinationNatRewriteRules destination rewrite rule for the traffic arriving on a specific port.

func AddDestinationNatRules

func AddDestinationNatRules(opts map[string]interface{}) error

AddDestinationNatRules creates destination NAT rules

func AddFilterForwardMappedPortRules

func AddFilterForwardMappedPortRules(opts map[string]interface{}) error

AddFilterForwardMappedPortRules adds a set of rules in forwarding chain of filter table.

func AddFilterForwardRules

func AddFilterForwardRules(v, tableName, chainName string, addr *current.IPConfig, intfName string) error

AddFilterForwardRules adds a set of rules in forwarding chain of filter table.

func AddPostRoutingRules

func AddPostRoutingRules(opts map[string]interface{}) error

AddPostRoutingRules adds a set of rules in postrouting chain of nat table.

func CreateChain

func CreateChain(v, tableName, chainName, chainType, chainHookType, chainPriority string) error

CreateChain creates NAT chain of a specific type.

func CreateFilterForwardChain

func CreateFilterForwardChain(v, tableName, chainName string) error

CreateFilterForwardChain creates forward chain in filter table.

func CreateJumpRule

func CreateJumpRule(v, tableName, srcChainName, dstChainName string) error

CreateJumpRule create a jump rule from one chain to another.

func CreateNatInputChain

func CreateNatInputChain(v, tableName, chainName string) error

CreateNatInputChain creates an input chain in nat table.

NF_INET_LOCAL_IN: all incoming packets addressed to the local computer pass this hook in the function ip_local_deliver().

func CreateNatOutputChain

func CreateNatOutputChain(v, tableName, chainName string) error

CreateNatOutputChain creates an output chain in nat table.

NF_INET_LOCAL_OUT: all outgoing packets created in the local computer pass this hook in the function ip_build_and_send_pkt().

func CreateNatPostRoutingChain

func CreateNatPostRoutingChain(v, tableName, chainName string) error

CreateNatPostRoutingChain creates a postrouting chain in nat table.

NF_INET_POST_ROUTING: this hook in the ipfinishoutput() function before they leave the computer.

func CreateNatPreRoutingChain

func CreateNatPreRoutingChain(v, tableName, chainName string) error

CreateNatPreRoutingChain creates a prerouting chain in nat table.

NF_INET_PRE_ROUTING: incoming packets pass this hook in the ip_rcv() (linux/net/ipv4/ip_input.c) function before they are processed by the routing code.

func CreateRawPreRoutingChain

func CreateRawPreRoutingChain(v, tableName, chainName string) error

CreateRawPreRoutingChain creates a prerouting chain in raw table.

func CreateTable

func CreateTable(v, tableName string) error

CreateTable creates a table.

func DeleteChain

func DeleteChain(v, tableName, chainName string) error

DeleteChain deletes a particular chain.

func DeleteJumpRule

func DeleteJumpRule(v, tableName, srcChainName, dstChainName string) error

DeleteJumpRule deletes the chain jumping rule.

func EncodeInterfaceName

func EncodeInterfaceName(s string) []byte

EncodeInterfaceName returns null-terminated string for netlink communication.

func GetChainName

func GetChainName(prefix, containerID string) string

GetChainName returns nftables chain name based on the provided namespace and interface.

func GetJumpRule

func GetJumpRule(v, tableName, srcChainName, dstChainName string) (*nftables.Rule, error)

GetJumpRule return information about a specific jump rule.

func GetTestContainerID

func GetTestContainerID(s string) string

GetTestContainerID returns the name for a test container.

func IsChainExists

func IsChainExists(v, tableName, chainName string) (bool, error)

IsChainExists checks whether a chain exists.

func IsTableExist

func IsTableExist(v, tableName string) (bool, error)

IsTableExist checks whether a table exists

func LoadDataFromFilePath

func LoadDataFromFilePath(fp string) ([]byte, error)

LoadDataFromFilePath returns the content of a file based on the provided file path.

func RemoveFilterForwardMappedPortRules

func RemoveFilterForwardMappedPortRules(opts map[string]interface{}) error

RemoveFilterForwardMappedPortRules removes a set of rules in forwarding chain of filter table.

Types

type ChainInfo

type ChainInfo struct {
	RuleCount int
	Positions []uint64
	Handles   []uint64
	Rules     []*nftables.Rule
}

ChainInfo holds the rules of a particular chain

func GetChainProps

func GetChainProps(v, tableName, chainName string) (*ChainInfo, error)

GetChainProps returns the rules and other properties of a particular chain.

type MappingEntry

type MappingEntry struct {
	HostPort      int    `json:"hostPort"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"`
	HostIP        string `json:"hostIP,omitempty"`
}

MappingEntry holds the port mapping configuration.

Jump to

Keyboard shortcuts

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