upnp

package
v0.0.0-...-d38aeb8 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2018 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocalPortUsed       = errors.New("local port used")
	ErrPortMappingNotFound = errors.New("port mapping not found")
)
View Source
var (
	SSDPMulticastAddr = []byte{239, 255, 255, 250}
)

Functions

func AddUpnpTcpPortMapping

func AddUpnpTcpPortMapping(igdServer string, externalPort int,
	internalIp string, internalPort int) (string, error)

func DeleteUpnpTcpPortMapping

func DeleteUpnpTcpPortMapping(igdServer string, externalPort int) error

func SSDPSearch

func SSDPSearch(intf *net.Interface,
	deviceType string, destIP net.IP,
	timeout time.Duration) (<-chan *SSDPNotify, error)

Types

type Daemon

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

func NewDaemon

func NewDaemon() *Daemon

func (*Daemon) AddPortMapping

func (p *Daemon) AddPortMapping(igdServer string, externalPort int,
	internalIP string, internalPort int) error

func (*Daemon) DeletePortMapping

func (p *Daemon) DeletePortMapping(igdServer string, externalPort int) error

func (*Daemon) ListPortMapping

func (p *Daemon) ListPortMapping() []*PortMappingInfo

type IGD

type IGD struct {
	UUID           string
	FriendlyName   string
	DescriptionURL string

	Services []IGDService
	// contains filtered or unexported fields
}

func GetIGDDevice

func GetIGDDevice(root *UPnPRoot, rootURL string) (*IGD, error)

type IGDService

type IGDService struct {
	ID  string
	URL string
	URN string
}

func GetIGDServices

func GetIGDServices(device *UPnpDevice, rootURL string) ([]IGDService, error)

func (*IGDService) AddPortMapping

func (s *IGDService) AddPortMapping(
	protocol string, externalPort int,
	internalIP string, internalPort int, duration time.Duration,
	description string) error

AddPortMapping adds a port mapping to the specified IGD service.

func (*IGDService) DeletePortMapping

func (s *IGDService) DeletePortMapping(protocol string, externalPort int) error

DeletePortMapping deletes a port mapping from the specified IGD service.

func (*IGDService) GetExternalIPAddress

func (s *IGDService) GetExternalIPAddress() (net.IP, error)

GetExternalIPAddress queries the IGD service for its external IP address. Returns nil if the external IP address is invalid or undefined, along with any relevant errors

type PortMappingInfo

type PortMappingInfo struct {
	IGDServer    string `json:"igdServer"`
	ExternalPort int    `json:"externalPort"`
	InternalIP   string `json:"internalIP"`
	InternalPort int    `json:"internalPort"`

	ExternalIP string `json:"externalIP"`
}

type SSDPNotify

type SSDPNotify struct {
	DeviceUUID                string `json:"uuid"`
	RespondingDeviceType      string `json:"deviceType"`
	DeviceUSN                 string `json:"usn"`
	DeviceDescriptionLocation string `json:"location"`
}

func ParseSSDPNotify

func ParseSSDPNotify(deviceType string, data []byte) (*SSDPNotify, error)

type Store

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

func NewStore

func NewStore(path string) (*Store, error)

func (*Store) AddPortMapping

func (s *Store) AddPortMapping(pm *PortMappingInfo) error

func (*Store) CleanAndUpdate

func (s *Store) CleanAndUpdate(pms []*PortMappingInfo) error

func (*Store) DeletePortMapping

func (s *Store) DeletePortMapping(igdServer string, externalPort int) error

func (*Store) GetAllPortMapping

func (s *Store) GetAllPortMapping() ([]*PortMappingInfo, error)

type UPnPRoot

type UPnPRoot struct {
	Device UPnpDevice `xml:"device"`
}

func GetUPnPData

func GetUPnPData(deviceDescriptionLocation string) (*UPnPRoot, error)

type UPnpDevice

type UPnpDevice struct {
	DeviceType   string        `xml:"deviceType"`
	FriendlyName string        `xml:"friendlyName"`
	UDN          string        `xml:"UDN"`
	Devices      []UPnpDevice  `xml:"deviceList>device"`
	Services     []UPnpService `xml:"serviceList>service"`
}

func (*UPnpDevice) GetChildDevices

func (d *UPnpDevice) GetChildDevices(deviceType string) []UPnpDevice

func (*UPnpDevice) GetChildServices

func (d *UPnpDevice) GetChildServices(serviceType string) []UPnpService

type UPnpService

type UPnpService struct {
	ID         string `xml:"serviceId"`
	Type       string `xml:"serviceType"`
	ControlURL string `xml:"controlURL"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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