nat

package
Version: v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: GPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// CRC16("github.com/privatix/dappctrl/nat") = 0x1999
	ErrBadMechanism errors.Error = 0x1999<<8 + iota
	ErrTooShortLifetime
	ErrLocalAddressNotFound
	ErrAddMapping
	ErrNoRouterDiscovered
)

Errors.

Variables

This section is empty.

Functions

func Map

func Map(ctx context.Context, conf *Config, logger log.Logger, m Interface,
	protocol string, extPort, intPort int, name string) error

Map adds a port mapping on NAT interface and keeps it alive until interface is closed.

func Run

func Run(ctx context.Context, conf *Config,
	logger log.Logger, ports []uint16)

Run matches and opens external network ports.

Types

type Config

type Config struct {
	CheckTimeout       int64  // In milliseconds.
	MapTimeout         int64  // In milliseconds.
	MapUpdateInterval  int64  // In milliseconds.
	Mechanism          string // upnp, pmp or any
	SoapRequestTimeout int64  // In milliseconds.
}

Config is a configuration for service to traversal NAT.

func NewConfig

func NewConfig() *Config

NewConfig creates new configuration for service to traversal NAT.

type Interface

type Interface interface {
	AddMapping(protocol string, extPort, intPort int,
		name string, lifetime time.Duration) error
	DeleteMapping(protocol string, extPort, intPort int) error
}

Interface an implementation of nat.Interface can map local ports to ports accessible from the Internet.

func Parse

func Parse(config *Config) (Interface, error)

Parse parses a NAT interface description.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL