nat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package nat implements NAT handling facilities

Index

Constants

This section is empty.

Variables

View Source
var ErrNoExternalAddress = errors.New("no external address")
View Source
var ErrNoInternalAddress = errors.New("no internal address")
View Source
var ErrNoNATFound = errors.New("no NAT found")

Functions

func DiscoverNATs

func DiscoverNATs(ctx context.Context) <-chan NAT

DiscoverNATs returns all NATs discovered in the network.

Types

type NAT

type NAT interface {
	// Type returns the kind of NAT port mapping service that is used
	Type() string

	// GetDeviceAddress returns the internal address of the gateway device.
	GetDeviceAddress() (addr net.IP, err error)

	// GetExternalAddress returns the external address of the gateway device.
	GetExternalAddress() (addr net.IP, err error)

	// GetInternalAddress returns the address of the local host.
	GetInternalAddress() (addr net.IP, err error)

	// AddPortMapping maps a port on the local host to an external port.
	AddPortMapping(ctx context.Context, protocol string, internalPort int, description string, timeout time.Duration) (mappedExternalPort int, err error)

	// DeletePortMapping removes a port mapping.
	DeletePortMapping(ctx context.Context, protocol string, internalPort int) (err error)
}

protocol is either "udp" or "tcp"

func DiscoverGateway

func DiscoverGateway(ctx context.Context) (NAT, error)

DiscoverGateway attempts to find a gateway device.

Jump to

Keyboard shortcuts

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