nat

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper struct {
	// contains filtered or unexported fields
}

Mapper attempts to open a set of ports on a router

func NewPortMapper added in v0.5.7

func NewPortMapper(log logging.Logger, r Router) Mapper

NewPortMapper returns an initialized mapper

func (*Mapper) Map added in v0.5.7

func (dev *Mapper) Map(protocol string, intPort uint16, desc string) (uint16, error)

Map sets up port mapping using given protocol, internal and external ports and returns the final port mapped. It returns 0 if mapping failed after the maximun number of retries

func (*Mapper) UnmapAllPorts

func (dev *Mapper) UnmapAllPorts()

UnmapAllPorts stops mapping all ports from this mapper and attempts to unmap them.

type Router

type Router interface {
	MapPort(protocol string, intPort, extPort uint16, desc string, duration time.Duration) error
	UnmapPort(protocol string, intPort, extPort uint16) error
	ExternalIP() (net.IP, error)
	GetPortMappingEntry(extPort uint16, protocol string) (
		InternalIP string,
		InternalPort uint16,
		Description string,
		err error,
	)
}

Router describes the functionality that a network device must support to be able to open ports to an external IP.

func GetRouter added in v0.5.7

func GetRouter() Router

GetRouter returns a router on the current network.

func NewNoRouter added in v0.5.7

func NewNoRouter() Router

NewNoRouter returns a router that assumes the network is public

Jump to

Keyboard shortcuts

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