nat

package
v0.0.0-...-50ffc52 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRuleNotFound = errors.New("error: rule not found")
)
View Source
var Fix = Check

Functions

func AddDestinationNatRule

func AddDestinationNatRule(conn *nftables.Conn, table, chain string, pm PortMapping) (uint64, error)

AddDestinationNatRule creates a destination NAT rule

func ChainExists

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

ChainExists checks whether a chain exists.

func Check

func Check() error

func CreateChain

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

CreateChain creates NAT chain of a specific type.

func CreateTable

func CreateTable(v, tableName string) error

CreateTable creates a table.

func DeleteRules

func DeleteRules(handles []uint64) error

func EncodeInterfaceName

func EncodeInterfaceName(s string) []byte

EncodeInterfaceName returns null-terminated string for netlink communication.

func GetRuleMatchingUserDataBytes

func GetRuleMatchingUserDataBytes(table, chain string, userdata []byte) (*nftables.Rule, error)

func GetRules

func GetRules(table, chain string) ([]*nftables.Rule, error)

func SetPortmap

func SetPortmap(iface, ip string, portmap []string) ([]uint64, error)

func TableExists

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

TableExists checks whether a table exists

Types

type PortMapping

type PortMapping struct {
	HostPort      int    `json:"hostPort"`
	ContainerHost string `json:"containerHost"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"`
}

PortMapping holds the port mapping configuration.

func (PortMapping) Bytes

func (pm PortMapping) Bytes() []byte

type Unmapper

type Unmapper func() error

Jump to

Keyboard shortcuts

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