nat

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: Apache-2.0 Imports: 14 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-nat

GoDoc status

Forked from: fd/go-nat.


The last gx published version of this module was: 1.0.3: QmdwkZHamNNrj7k3G29rnurmW3mFzsDhnyXppNcgYsiBVz

Documentation

Overview

Package nat implements NAT handling facilities

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoExternalAddress = errors.New("no external address")
	ErrNoInternalAddress = errors.New("no internal address")
	ErrNoNATFound        = errors.New("no NAT found")
	DefaultTimeout       = time.Second * 10
)

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(protocol string, internalPort int, description string, timeout time.Duration) (mappedExternalPort int, err error)

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

protocol is either "udp" or "tcp"

func DiscoverGateway

func DiscoverGateway(timeout time.Duration) (NAT, error)

DiscoverGateway attempts to find a gateway device.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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