upnp

package
v0.0.0-...-129a086 Latest Latest
Warning

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

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

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
	LocalIP   net.IP
}

An IGDService is a specific service provided by an IGD.

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) GetExternalIPAddress

func (s *IGDService) GetExternalIPAddress(ctx context.Context) (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

func (*IGDService) GetLocalIPAddress

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

GetLocalIPAddress returns local IP address used to contact this service

func (*IGDService) ID

func (s *IGDService) ID() string

ID returns a unique ID for the servic

type UnsupportedDeviceTypeError

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

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

func (*UnsupportedDeviceTypeError) Error

Jump to

Keyboard shortcuts

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