upnp

package
v0.0.0-...-016f32e Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package upnp implements UPnP InternetGatewayDevice discovery, querying, and port mapping.

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Debugging

Functions

func EnableLog

func EnableLog()

Types

type IGD

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

A container for relevant properties of a UPnP InternetGatewayDevice.

func Discover

func Discover() []IGD

Discover discovers UPnP InternetGatewayDevices. The order in which the devices appear in the result list is not deterministic.

func (*IGD) AddPortMapping

func (n *IGD) AddPortMapping(protocol Protocol, externalPort, internalPort int, description string, timeout int) error

Add a port mapping to all relevant services on the specified InternetGatewayDevice. Port mapping will fail and return an error if action is fails for _any_ of the relevant services. For this reason, it is generally better to configure port mapping for each individual service instead.

func (*IGD) DeletePortMapping

func (n *IGD) DeletePortMapping(protocol Protocol, externalPort int) error

Delete a port mapping from all relevant services on the specified InternetGatewayDevice. Port mapping will fail and return an error if action is fails for _any_ of the relevant services. For this reason, it is generally better to configure port mapping for each individual service instead.

func (*IGD) FriendlyIdentifier

func (n *IGD) FriendlyIdentifier() string

The InternetGatewayDevice's friendly identifier (friendly name + IP address).

func (*IGD) FriendlyName

func (n *IGD) FriendlyName() string

The InternetGatewayDevice's friendly name.

func (*IGD) URL

func (n *IGD) URL() *url.URL

The URL of the InternetGatewayDevice's root device description.

func (*IGD) UUID

func (n *IGD) UUID() string

The InternetGatewayDevice's UUID.

type IGDService

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

A container for relevant properties of a UPnP service of an IGD.

func (*IGDService) AddPortMapping

func (s *IGDService) AddPortMapping(localIPAddress string, protocol Protocol, externalPort, internalPort int, description string, timeout int) error

Add a port mapping to the specified IGD service.

func (*IGDService) DeletePortMapping

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

Delete a port mapping from the specified IGD service.

func (*IGDService) GetExternalIPAddress

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

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

func (*IGDService) ID

func (s *IGDService) ID() string

type Protocol

type Protocol string
const (
	TCP Protocol = "TCP"
	UDP          = "UDP"
)

Jump to

Keyboard shortcuts

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