portmap

package module
v0.0.0-...-e6325c6 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 8 Imported by: 1

README

Map TCP and UDP ports using NAT-PMP or UPNP.  Unlike some other libraries,
guarantee that we don't override other clients' ports, and that the
mappings will expire even if the client crashes.

See portmap-example for an example.

Documentation

Overview

Package portmap implements port mapping using NAT-PMP or uPNP.

Index

Constants

View Source
const (
	NATPMP = 1
	UPNP   = 2
	All    = NATPMP | UPNP
)

Variables

This section is empty.

Functions

func Map

func Map(ctx context.Context, label string, internal uint16, kind int, f func(proto string, status Status, err error)) error

Map runs a portmapping loop for both TCP and UDP. The kind parameter indicates the portmapping protocols to attempt.

The label is passed to the UPNP server (it is not used with NAT-PMP) and may be displayed in the router's user interface.

The callback function is called whenever a mapping is established or changes, or when an error occurs; it may be nil.

Types

type Status

type Status struct {
	Internal, External uint16
	Lifetime           time.Duration
}

Status is passed to the callback of Map

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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