golibnatpmp

package module
v0.0.0-...-9a8d1e7 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2013 License: BSD-3-Clause Imports: 2 Imported by: 0

README

golibnatpmp

golibnatpmp is a Go wrapper for the libnatpmp C library, thingly veiled in Go idiomatic goodness.

Before attempting to build this package, run setup.sh (caveat emptor) to download and unpack the necessary parts.

API Documentation is available from http://godoc.org/github.com/nhelke/golibnatpmp

Like the C library this code wraps, this package is BSD licensed, cf. the LICENSE file that ships with the code.

Documentation

Overview

This package is not thread safe. All calls to it should happen from a single thread or goroutine or be synchronised by some other mechanism

Index

Constants

View Source
const (
	UDP protocol = 1
	TCP protocol = 2
)

Values to pass to sendnewportmappingrequest()

Variables

This section is empty.

Functions

This section is empty.

Types

type NATPMP

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

func NewNATPMP

func NewNATPMP() (NATPMP, error)

Initialize a natpmp_t object.

The gateway is detected automaticaly. Equivalent to `NewNATPMPWithGW(0)`

func NewNATPMPWithGW

func NewNATPMPWithGW(forcedgw uint32) (natpmp NATPMP, err error)

Initialize a natpmp_t object.

The gateway is not detected automaticaly and the passed gateway address is used unless forcedgw == 0

func (NATPMP) Close

func (self NATPMP) Close() (err error)

Close resources associated with a natpmp_t object

func (NATPMP) SendNewPortMappingRequest

func (self NATPMP) SendNewPortMappingRequest(protocol protocol,
	privateport, publicport uint16,
	lifetimeInSeconds uint32) <-chan NewPortMappingResponse

Send a new port mapping NAT-PMP request to the network gateway

Arguments : protocol is either golibnatpmp.TCP or golibnatpmp.UDP, lifetime is in seconds.

To remove a port mapping, set lifetime to zero.

To remove all port mappings to the host, set lifetime and both ports to zero.

func (NATPMP) SendPublicAddressRequest

func (self NATPMP) SendPublicAddressRequest() <-chan PublicAddressResponse

Send a public address NAT-PMP request to the network gateway

type NewPortMappingResponse

type NewPortMappingResponse struct {
	PrivatePort       uint16
	MappedPublicPort  uint16
	LifetimeInSeconds uint32
	Err               error
}

This struct's fields may only be considered valid if Err is nil

type PublicAddressResponse

type PublicAddressResponse struct {
	IP  uint32
	Err error
}

IP is only valid if Err is nil

Jump to

Keyboard shortcuts

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