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 (*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
Click to show internal directories.
Click to hide internal directories.