go-nat-pmp: github.com/jackpal/go-nat-pmp Index | Files

package natpmp

import "github.com/jackpal/go-nat-pmp"

Index

Package Files

natpmp.go network.go recorder.go

Constants

const RECOMMENDED_MAPPING_LIFETIME_SECONDS = 3600

The recommended mapping lifetime for AddPortMapping.

type AddPortMappingResult Uses

type AddPortMappingResult struct {
    SecondsSinceStartOfEpoc      uint32
    InternalPort                 uint16
    MappedExternalPort           uint16
    PortMappingLifetimeInSeconds uint32
}

Results of the NAT-PMP AddPortMapping operation

type Client Uses

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

Client is a NAT-PMP protocol client.

func NewClient Uses

func NewClient(gateway net.IP) (nat *Client)

Create a NAT-PMP client for the NAT-PMP server at the gateway. Uses default timeout which is around 128 seconds.

func NewClientWithTimeout Uses

func NewClientWithTimeout(gateway net.IP, timeout time.Duration) (nat *Client)

Create a NAT-PMP client for the NAT-PMP server at the gateway, with a timeout. Timeout defines the total amount of time we will keep retrying before giving up.

func (*Client) AddPortMapping Uses

func (n *Client) AddPortMapping(protocol string, internalPort, requestedExternalPort int, lifetime int) (result *AddPortMappingResult, err error)

Add (or delete) a port mapping. To delete a mapping, set the requestedExternalPort and lifetime to 0. Note that this call can take up to 128 seconds to return.

func (*Client) GetExternalAddress Uses

func (n *Client) GetExternalAddress() (result *GetExternalAddressResult, err error)

Get the external address of the router.

Note that this call can take up to 128 seconds to return.

type GetExternalAddressResult Uses

type GetExternalAddressResult struct {
    SecondsSinceStartOfEpoc uint32
    ExternalIPAddress       [4]byte
}

Results of the NAT-PMP GetExternalAddress operation.

Package natpmp imports 3 packages (graph) and is imported by 301 packages. Updated 2019-07-17. Refresh now. Tools for package owners.