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