upnpigd

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URN_InterntGatewayDevice1 = "urn:schemas-upnp-org:device:InternetGatewayDevice:1"
	URN_WANDevice1            = "urn:schemas-upnp-org:device:WANDevice:1"
	URN_WANConnectionDevice1  = "urn:schemas-upnp-org:device:WANConnectionDevice:1"
	URN_WANIPConnection1      = "urn:schemas-upnp-org:service:WANIPConnection:1"
	URN_WANPPPConnection1     = "urn:schemas-upnp-org:service:WANPPPConnection:1"

	URN_InternetGatewayDevice2 = "urn:schemas-upnp-org:device:InternetGatewayDevice:2"
	URN_WANDevice2             = "urn:schemas-upnp-org:device:WANDevice:2"
	URN_WANConnectionDevice2   = "urn:schemas-upnp-org:device:WANConnectionDevice:2"
	URN_WANIPConnection2       = "urn:schemas-upnp-org:service:WANIPConnection:2"
	URN_WANPPPConnection2      = "urn:schemas-upnp-org:service:WANPPPConnection:2"
)

Variables

View Source
var (
	URN_InternetGatewayDevices = []string{
		URN_InterntGatewayDevice1,
		URN_InternetGatewayDevice2,
	}
	URN_WANConnections1 = []string{
		URN_WANIPConnection1,
		URN_WANPPPConnection1,
	}
	URN_WANConnections2 = []string{
		URN_WANIPConnection2,
		URN_WANPPPConnection2,
	}
)
View Source
var MulticastADDR = net.UDPAddr{
	IP:   net.IPv4(239, 255, 255, 250),
	Port: 1900,
}

Functions

func Discover

func Discover(ctx context.Context, userAgent string, timeout time.Duration, client *http.Client) (<-chan *Device, error)

Types

type AddPortMappingRequest

type AddPortMappingRequest struct {
	Protocol     string
	InternalPort int
	ExternalPort int
	Description  string
	Duration     time.Duration
}

func (*AddPortMappingRequest) Function

func (r *AddPortMappingRequest) Function() string

func (*AddPortMappingRequest) SOAP

func (r *AddPortMappingRequest) SOAP(urn string, localIP net.IP) (string, error)

type DeletePortMappingRequest

type DeletePortMappingRequest struct {
	Protocol     string
	ExternalPort int
}

func (*DeletePortMappingRequest) Function

func (r *DeletePortMappingRequest) Function() string

func (*DeletePortMappingRequest) SOAP

func (r *DeletePortMappingRequest) SOAP(urn string, _ net.IP) (string, error)

type Device

type Device struct {
	UUID     string
	Name     string
	Services []Service
	URL      *url.URL
}

func NewDevice

func NewDevice(client *http.Client, st string, raw []byte) (*Device, error)

func (*Device) AddPortMapping

func (d *Device) AddPortMapping(ctx context.Context, protocol string, externalPort, internalPort int, description string, leaseDuration time.Duration) error

func (*Device) DeletePortMapping

func (d *Device) DeletePortMapping(ctx context.Context, protocol string, externalPort int) error

func (*Device) GetExternalIP

func (d *Device) GetExternalIP(ctx context.Context) (net.IP, error)

type GetExternalIPRequest

type GetExternalIPRequest struct{}

func (*GetExternalIPRequest) Function

func (r *GetExternalIPRequest) Function() string

func (*GetExternalIPRequest) SOAP

func (r *GetExternalIPRequest) SOAP(urn string, _ net.IP) (string, error)

type Request

type Request interface {
	SOAP(urn string, localIP net.IP) (string, error)
	Function() string
}

type Service

type Service struct {
	ID      string
	URL     string
	URN     string
	LocalIP net.IP

	Client    *http.Client `json:"-"`
	UserAgent string
}

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, r Request) ([]byte, error)

Jump to

Keyboard shortcuts

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