upnp

package
v1.27.6 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MPL-2.0 Imports: 19 Imported by: 8

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discover

func Discover(ctx context.Context, _, timeout time.Duration) []nat.Device

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

Types

type IGDService

type IGDService struct {
	UUID      string
	Device    upnpDevice
	ServiceID string
	URL       string
	URN       string
	LocalIPv4 net.IP
	Interface *net.Interface

	nat.Service
}

An IGDService is a specific service provided by an IGD.

func (*IGDService) AddPinhole added in v1.27.2

func (s *IGDService) AddPinhole(ctx context.Context, protocol nat.Protocol, intAddr nat.Address, duration time.Duration) ([]net.IP, error)

AddPinhole adds an IPv6 pinhole in accordance to http://upnp.org/specs/gw/UPnP-gw-WANIPv6FirewallControl-v1-Service.pdf This is attempted for each IPv6 on the interface.

func (*IGDService) AddPortMapping

func (s *IGDService) AddPortMapping(ctx context.Context, protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)

AddPortMapping adds a port mapping to the specified IGD service.

func (*IGDService) DeletePortMapping

func (s *IGDService) DeletePortMapping(ctx context.Context, protocol nat.Protocol, externalPort int) error

DeletePortMapping deletes a port mapping from the specified IGD service.

func (*IGDService) GetExternalIPv4Address added in v1.27.2

func (s *IGDService) GetExternalIPv4Address(ctx context.Context) (net.IP, error)

GetExternalIPv4Address 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

func (*IGDService) GetLocalIPv4Address added in v1.27.2

func (s *IGDService) GetLocalIPv4Address() net.IP

GetLocalIPv4Address returns local IP address used to contact this service

func (*IGDService) ID

func (s *IGDService) ID() string

ID returns a unique ID for the service

func (*IGDService) SupportsIPVersion added in v1.27.2

func (s *IGDService) SupportsIPVersion(version nat.IPVersion) bool

SupportsIPVersion checks whether this is a WANIPv6FirewallControl device, in which case pinholing instead of port mapping should be done

type UnsupportedDeviceTypeError added in v0.14.50

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

UnsupportedDeviceTypeError for unsupported UPnP device types (i.e upnp:rootdevice)

func (*UnsupportedDeviceTypeError) Error added in v0.14.50

Jump to

Keyboard shortcuts

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