upnp

package module
v0.0.0-...-e91dfdd Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: MIT Imports: 7 Imported by: 2

README

upnp

Golang UPNP implementation to open gateway ports and get WAN address

Available functons include:

  • AddMappingPort
  • DelMappingPort
  • ExternalIPAddress

Documentation

Overview

upnp functions to open ports on router

Index

Constants

View Source
const (
	BroadcastRetryCount      = 3
	BroadcastWaitTimeSeconds = 3
	ServiceType              = "urn:schemas-upnp-org:service:WANIPConnection:1"
)

Variables

This section is empty.

Functions

func GetLocalAddress

func GetLocalAddress() net.IP

Types

type Gateway

type Gateway struct {
	GatewayName   string
	Host          string
	DeviceDescUrl string
	Cache         string
	ST            string
	ControlURL    string
	OutsideIP     net.IP
}

type Service

type Service struct {
	ServiceType string `xml:"serviceType"`
	//ServiceId   string `xml:"serviceId"`
	//SCPDURL     string `xml:"SCPDURL"`
	ControlURL string `xml:"controlURL"`
}

Device Description xml elements

type UPNP

type UPNP struct {
	Gateway *Gateway
}

func NewUPNP

func NewUPNP() (*UPNP, error)

NewUPNP returns a new UPNP object with a populated Gateway object.

func (*UPNP) AddPortMapping

func (u *UPNP) AddPortMapping(localPort, remotePort int, protocol string) error

AddPortMapping to the WAN/Internet

func (*UPNP) DelPortMapping

func (u *UPNP) DelPortMapping(remotePort int, protocol string) error

func (*UPNP) DeviceDesc

func (u *UPNP) DeviceDesc() error

func (*UPNP) ExternalIPAddress

func (u *UPNP) ExternalIPAddress() (net.IP, error)

Jump to

Keyboard shortcuts

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