natpmp

package
v0.0.0-...-1e25372 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResponseSizeTooSmall    = errors.New("response size is too small")
	ErrResponseSizeUnexpected  = errors.New("response size is unexpected")
	ErrProtocolVersionUnknown  = errors.New("protocol version is unknown")
	ErrOperationCodeUnexpected = errors.New("operation code is unexpected")
)
View Source
var (
	ErrVersionNotSupported       = errors.New("version is not supported")
	ErrNotAuthorized             = errors.New("not authorized")
	ErrNetworkFailure            = errors.New("network failure")
	ErrOutOfResources            = errors.New("out of resources")
	ErrOperationCodeNotSupported = errors.New("operation code is not supported")
	ErrResultCodeUnknown         = errors.New("result code is unknown")
)
View Source
var (
	ErrNetworkProtocolUnknown = errors.New("network protocol is unknown")
	ErrLifetimeTooLong        = errors.New("lifetime is too long")
)
View Source
var (
	ErrGatewayIPUnspecified = errors.New("gateway IP is unspecified")
	ErrConnectionTimeout    = errors.New("connection timeout")
)
View Source
var (
	ErrRequestSizeTooSmall = errors.New("message size is too small")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a NAT-PMP protocol client.

func New

func New() (client *Client)

New creates a new NAT-PMP client.

func (*Client) AddPortMapping

func (c *Client) AddPortMapping(ctx context.Context, gateway netip.Addr,
	protocol string, internalPort, requestedExternalPort uint16,
	lifetime time.Duration) (durationSinceStartOfEpoch time.Duration,
	assignedInternalPort, assignedExternalPort uint16, assignedLifetime time.Duration,
	err error)

Add or delete a port mapping. To delete a mapping, set both the requestedExternalPort and lifetime to 0. See https://www.ietf.org/rfc/rfc6886.html#section-3.3

func (*Client) ExternalAddress

func (c *Client) ExternalAddress(ctx context.Context, gateway netip.Addr) (
	durationSinceStartOfEpoch time.Duration,
	externalIPv4Address netip.Addr, err error)

ExternalAddress fetches the duration since the start of epoch and the external IPv4 address of the gateway. See https://www.ietf.org/rfc/rfc6886.html#section-3.2

Jump to

Keyboard shortcuts

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