upnp

package
v0.0.0-...-0df88b9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootDevice = URN("upnp:rootdevice")
	All        = URN("ssdp:all")
)

Variables

This section is empty.

Functions

func BroadcastDevice

func BroadcastDevice(d *Device, url string, iface *net.Interface) error

BroadcastDevice broadcasts the presence of a UPnP Device, with its SSDP/SCPD served via HTTP at addr.

func DiscoverURLs

func DiscoverURLs(ctx context.Context, urn URN, iface *net.Interface) ([]*url.URL, []error, error)

DiscoverURLs discovers UPnP device manifest URLs using SSDP on the local network. It returns all valid URLs it finds, a slice of errors from invalid SSDP responses, and an error with the actual connection itself.

Types

type Device

type Device struct {
	// Name is the "friendly name" of a UPnP device.
	Name string

	// UDN is a unique identifier that can be used to rediscover a device.
	UDN string

	// DeviceType is yet another URN-alike.
	DeviceType DeviceType

	Icons []Icon

	Manufacturer     string
	ManufacturerURL  string
	ModelDescription string
	ModelName        string
	ModelNumber      string
	ModelURL         string
	SerialNumber     string

	PresentationURL string
	// contains filtered or unexported fields
}

Device is an UPnP device.

func DiscoverDevices

func DiscoverDevices(ctx context.Context, urn URN, iface *net.Interface) ([]*Device, []error, error)

DiscoverDevices discovers UPnP devices using SSDP on the local network. It returns all valid URLs it finds, a slice of errors from invalid SSDP responses or UPnP device manifests, and an error with the actual connection itself.

func (*Device) HTTPHandler

func (d *Device) HTTPHandler(basePath string) http.Handler

ServeHTTP serves the SSDP/SCPD UPnP discovery interface, and marshals SOAP requests.

func (*Device) Handle

func (d *Device) Handle(urn URN, id ServiceID, doc scpd.Document, handler soap.Interface)

func (*Device) SOAPInterface

func (d *Device) SOAPInterface(urn URN) (soap.Interface, bool)

SOAPClient returns a SOAP client for the given URN, and whether or not that client exists. A nil Device always returns (nil, false).

func (*Device) Services

func (d *Device) Services() []URN

Services lists URNs advertised by the device. A nil Device always returns nil.

type DeviceCache

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

DeviceCache is an automatically refreshing cache of UPnP devices, addressable by UDN.

func NewDeviceCache

func NewDeviceCache(urn URN, options DeviceCacheOptions) *DeviceCache

NewDeviceCache returns a DeviceCache searching for the given URN, every refresh period, optionally on a specific network interface.

func (*DeviceCache) DeviceByUDN

func (d *DeviceCache) DeviceByUDN(udn string) (*Device, bool)

DeviceByUDN returns the Device with a given UDN.

func (*DeviceCache) Devices

func (d *DeviceCache) Devices() []*Device

Devices lists all currently known Devices.

func (*DeviceCache) Refresh

func (d *DeviceCache) Refresh()

Refresh forces the DeviceCache to update itself by discovering UPnP devices.

type DeviceCacheOptions

type DeviceCacheOptions struct {
	InitialRefresh time.Duration
	StableRefresh  time.Duration

	Interface *net.Interface
}

type DeviceType

type DeviceType string

type Icon

type Icon struct {
	MIMEType             string
	Width, Height, Depth int
	URL                  string
}

type ServiceID

type ServiceID string

type URN

type URN string

URN is a UPnP service URN.

Directories

Path Synopsis
Package httpu implements HTTPU (HTTP-over-UDP) for use in SSDP.
Package httpu implements HTTPU (HTTP-over-UDP) for use in SSDP.

Jump to

Keyboard shortcuts

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