nattraversal

package
v0.1.10-docs-prerelease Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package nattraversal provides tools for acquiring ports on a Network Address Translator (NAT).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquirePortFromGateway

func AcquirePortFromGateway(gateway UPNPGateway, port uint16) error

AcquirePortFromGateway sets up UDP and TCP forwarding rules for the given port on the given gateway.

func GetExternalIP

func GetExternalIP() (string, error)

GetExternalIP returns a string formatted external IP address from a UPnP-enabled NAT on the network, if such device is discovered.

Types

type UPNPGateway

type UPNPGateway interface {
	Forward(port uint16, desc string) error
	Clear(port uint16) error
}

UPNPGateway is the interface of a UPnP gateway. It supports forwarding a port and clearing a forwarding rule.

func DiscoverUPNPGateway

func DiscoverUPNPGateway() (UPNPGateway, error)

DiscoverUPNPGateway returns a UPNPGateway if one is found on the network. This process is long - about 30 seconds and is expected to fail in some network setups.

Directories

Path Synopsis
Package upnp provides a simple and opinionated interface to UPnP-enabled routers, allowing users to forward ports and discover their external IP address.
Package upnp provides a simple and opinionated interface to UPnP-enabled routers, allowing users to forward ports and discover their external IP address.

Jump to

Keyboard shortcuts

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