igdman

package
v0.0.0-...-fd97e0e Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2016 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package igdman provides a basic management interface for Internet Gateway Devices (IGDs), primarily intended to help with creating port mappings from external ports to ports on internal ips.

igdman uses either UPnP or NAT-PMP, depending on what's discovered on the network.

Internally, igdman uses miniupnpc (https://github.com/miniupnp/miniupnp) and go-nat-pmp (https://code.google.com/p/go-nat-pmp/).

Basic Usage:

igd, err := igdman.NewIGD()
if err != nil {
    log.Fatalf("Unable to get IGD: %s", err)
}
err := igd.AddPortMapping(TCP, "192.168.1.210", 80, 8080, 0)
if err != nil {
    log.Fatalf("Unable to map port: %s", err)
}

Index

Constants

View Source
const (
	TCP = protocol("TCP")
	UDP = protocol("UDP")
)
View Source
const (
	IGD_URL_LABEL             = "Found valid IGD : "
	LOCAL_IP_ADDRESS_LABEL    = "Local LAN ip address : "
	EXTERNAL_IP_ADDRESS_LABEL = "ExternalIPAddress = "
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func NewNATPMPIGD

func NewNATPMPIGD() (igd *natpmpIGD, err error)

func NewUpnpIGD

func NewUpnpIGD() (igd *upnpIGD, err error)

Types

type IGD

type IGD interface {
	// GetExternalIP returns the IGD's external (public) IP address
	GetExternalIP() (ip string, err error)

	// AddPortMapping maps the given external port on the IGD to the internal
	// port, with an optional expiration.
	AddPortMapping(proto protocol, internalIP string, internalPort int, externalPort int, expiration time.Duration) error

	// RemovePortMapping removes the mapping from the given external port.
	RemovePortMapping(proto protocol, externalPort int) error
}

Interface IGD represents an Internet Gateway Device.

func NewIGD

func NewIGD() (igd IGD, err error)

NewIGD obtains a new IGD (either UPnP or NAT-PMP, depending on what's available)

Jump to

Keyboard shortcuts

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