utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerClient added in v0.1.2

type DockerClient interface {
	ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
}

type IPTabler added in v0.1.2

type IPTabler interface {
	AppendUnique(table, chain string, rulespec ...string) error
	List(table, chain string) ([]string, error)
	Delete(table, chain string, rulespec ...string) error
}

type PortMapping

type PortMapping struct {
	BridgeIP    string
	IP          string
	PublicPort  uint16
	PrivatePort uint16
}

type Utils added in v0.1.2

type Utils struct {
	IPTables     IPTabler
	DockerClient DockerClient
}

func NewUtils added in v0.1.2

func NewUtils(
	ipt IPTabler,
	cli DockerClient,
) (*Utils, error)

func (*Utils) AddNatPreroutingRule added in v0.1.2

func (u *Utils) AddNatPreroutingRule(mapping PortMapping) error

func (*Utils) ComparePortMappings added in v0.1.2

func (*Utils) ComparePortMappings(dockerMapping, rulesMapping []PortMapping) ([]PortMapping, []PortMapping)

ComparePortMappings compares the port mappings retrieved from the Docker API with the NAT rules and returns the rules that need to be added and removed

func (*Utils) RemoveNatPreroutingRule added in v0.1.2

func (u *Utils) RemoveNatPreroutingRule(mapping PortMapping) error

func (*Utils) RetrieveDockerPortMapping added in v0.1.2

func (u *Utils) RetrieveDockerPortMapping() ([]PortMapping, error)

func (*Utils) RetrieveNatMapping added in v0.1.2

func (u *Utils) RetrieveNatMapping() []PortMapping

Jump to

Keyboard shortcuts

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