Small fixes and removals, update discoverigd.go.
This commit is contained in:
parent
587c68769d
commit
03572e5988
@ -3,114 +3,41 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/huin/goupnp"
|
"github.com/huin/goupnp"
|
||||||
|
"github.com/huin/goupnp/dcps/internetgateway1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var spaces = " "
|
|
||||||
|
|
||||||
type GetExternalIPAddressRequest struct {
|
|
||||||
XMLName xml.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetExternalIPAddressResponse struct {
|
|
||||||
XMLName xml.Name
|
|
||||||
NewExternalIPAddress string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Uint16Value struct {
|
|
||||||
XMLName xml.Name
|
|
||||||
Value uint16 `xml:",chardata"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGenericPortMappingEntryRequest struct {
|
|
||||||
XMLName xml.Name
|
|
||||||
NewPortMappingIndex Uint16Value
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGenericPortMappingEntryResponse struct {
|
|
||||||
XMLName xml.Name
|
|
||||||
NewRemoteHost string
|
|
||||||
NewExternalPort uint16
|
|
||||||
NewProtocol string
|
|
||||||
NewInternalPort uint16
|
|
||||||
NewInternalClient string
|
|
||||||
NewEnabled string // boolean
|
|
||||||
NewLeaseDuration uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
type indentLevel int
|
|
||||||
|
|
||||||
func (i indentLevel) String() string {
|
|
||||||
return spaces[:i]
|
|
||||||
}
|
|
||||||
|
|
||||||
func displayDevice(indent indentLevel, device *goupnp.Device) {
|
|
||||||
fmt.Println(indent.String(), device)
|
|
||||||
for _, srv := range device.Services {
|
|
||||||
fmt.Printf("%sService %s\n", indent+1, srv.ServiceType)
|
|
||||||
}
|
|
||||||
for i := range device.Devices {
|
|
||||||
displayDevice(indent+1, &device.Devices[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if results, err := goupnp.DiscoverDevices(goupnp.ServiceTypeWANPPPConnection); err != nil {
|
results, err := goupnp.DiscoverDevices(internetgateway1.URN_WANPPPConnection_1)
|
||||||
|
if err != nil {
|
||||||
fmt.Println("Error discovering InternetGatewayDevice with UPnP: ", err)
|
fmt.Println("Error discovering InternetGatewayDevice with UPnP: ", err)
|
||||||
} else {
|
return
|
||||||
fmt.Printf("Discovered %d InternetGatewayDevices:\n", len(results))
|
}
|
||||||
for _, maybeRootDevice := range results {
|
|
||||||
if maybeRootDevice.Err != nil {
|
|
||||||
fmt.Println(maybeRootDevice.Err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
device := &maybeRootDevice.Root.Device
|
fmt.Printf("Discovered %d InternetGatewayDevices:\n", len(results))
|
||||||
|
for _, maybeRootDevice := range results {
|
||||||
|
if maybeRootDevice.Err != nil {
|
||||||
|
fmt.Println(maybeRootDevice.Err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
displayDevice(0, device)
|
device := &maybeRootDevice.Root.Device
|
||||||
wanPPPSrvs := device.FindService(goupnp.ServiceTypeWANPPPConnection)
|
|
||||||
if len(wanPPPSrvs) < 1 {
|
|
||||||
fmt.Printf("Could not find expected service on device %s\n", device.FriendlyName)
|
|
||||||
continue
|
|
||||||
} else if len(wanPPPSrvs) > 1 {
|
|
||||||
fmt.Printf("Got more than one expected service on device %s\n", device.FriendlyName)
|
|
||||||
}
|
|
||||||
srv := wanPPPSrvs[0]
|
|
||||||
|
|
||||||
if scdp, err := srv.RequestSCDP(); err != nil {
|
fmt.Println("Device ", device.FriendlyName)
|
||||||
fmt.Printf("Error requesting SCPD: %v\n", err)
|
wanPPPSrvs := device.FindService(internetgateway1.URN_WANPPPConnection_1)
|
||||||
|
if len(wanPPPSrvs) < 1 {
|
||||||
|
fmt.Printf("Could not find expected service on device %s\n", device.FriendlyName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, srv := range wanPPPSrvs {
|
||||||
|
client := internetgateway1.WANPPPConnection1{srv.NewSOAPClient()}
|
||||||
|
if addr, err := client.GetExternalIPAddress(); err != nil {
|
||||||
|
fmt.Printf("Failed to get external IP address: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Available SCPD actions:")
|
fmt.Printf("External IP address: %v\n", addr)
|
||||||
for _, action := range scdp.Actions {
|
|
||||||
fmt.Println(" ", action.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
srvClient := srv.NewSOAPClient()
|
|
||||||
|
|
||||||
{
|
|
||||||
inAction := GetExternalIPAddressRequest{XMLName: xml.Name{Space: goupnp.ServiceTypeWANPPPConnection, Local: "GetExternalIPAddress"}}
|
|
||||||
var outAction GetExternalIPAddressResponse
|
|
||||||
err := srvClient.PerformAction(goupnp.ServiceTypeWANPPPConnection, "GetExternalIPAddress", &inAction, &outAction)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Failed to GetExternalIPAddress from %s: %v\n", device.FriendlyName, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fmt.Printf("Got GetExternalIPAddress result from %s: %+v\n", device.FriendlyName, outAction)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := uint16(0); i < 10; i++ {
|
|
||||||
inAction := GetGenericPortMappingEntryRequest{XMLName: xml.Name{Space: goupnp.ServiceTypeWANPPPConnection, Local: "GetGenericPortMappingEntry"}, NewPortMappingIndex: Uint16Value{XMLName: xml.Name{"", "NewPortMappingIndex"}, Value: i}}
|
|
||||||
var outAction GetGenericPortMappingEntryResponse
|
|
||||||
err := srvClient.PerformAction(goupnp.ServiceTypeWANPPPConnection, "GetGenericPortMappingEntry", &inAction, &outAction)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Failed to GetGenericPortMappingEntry on %s: %v\n", device.FriendlyName, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fmt.Printf("Got GetGenericPortMappingEntry from %s: %+v\n", device.FriendlyName, outAction)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ const ({{range .ServiceTypes}}
|
|||||||
|
|
||||||
// {{$srvIdent}} is a client for UPnP SOAP service with URN "{{.URN}}".
|
// {{$srvIdent}} is a client for UPnP SOAP service with URN "{{.URN}}".
|
||||||
type {{$srvIdent}} struct {
|
type {{$srvIdent}} struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
{{range .SCPD.Actions}}{{/* loops over *SCPDWithURN values */}}
|
{{range .SCPD.Actions}}{{/* loops over *SCPDWithURN values */}}
|
||||||
|
@ -31,7 +31,7 @@ const (
|
|||||||
|
|
||||||
// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1".
|
// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1".
|
||||||
type LANHostConfigManagement1 struct {
|
type LANHostConfigManagement1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -637,7 +637,7 @@ func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, e
|
|||||||
|
|
||||||
// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1".
|
// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1".
|
||||||
type Layer3Forwarding1 struct {
|
type Layer3Forwarding1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -704,7 +704,7 @@ func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnec
|
|||||||
|
|
||||||
// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1".
|
// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1".
|
||||||
type WANCableLinkConfig1 struct {
|
type WANCableLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1025,7 +1025,7 @@ func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err er
|
|||||||
|
|
||||||
// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1".
|
// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1".
|
||||||
type WANCommonInterfaceConfig1 struct {
|
type WANCommonInterfaceConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -1371,7 +1371,7 @@ func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnection
|
|||||||
|
|
||||||
// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1".
|
// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1".
|
||||||
type WANDSLLinkConfig1 struct {
|
type WANDSLLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -1692,7 +1692,7 @@ func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err er
|
|||||||
|
|
||||||
// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1".
|
// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1".
|
||||||
type WANEthernetLinkConfig1 struct {
|
type WANEthernetLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1728,7 +1728,7 @@ func (client *WANEthernetLinkConfig1) GetEthernetLinkStatus() (NewEthernetLinkSt
|
|||||||
|
|
||||||
// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1".
|
// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1".
|
||||||
type WANIPConnection1 struct {
|
type WANIPConnection1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -2440,7 +2440,7 @@ func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress str
|
|||||||
|
|
||||||
// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1".
|
// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1".
|
||||||
type WANPOTSLinkConfig1 struct {
|
type WANPOTSLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -2760,7 +2760,7 @@ func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRComman
|
|||||||
|
|
||||||
// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1".
|
// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1".
|
||||||
type WANPPPConnection1 struct {
|
type WANPPPConnection1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -35,7 +35,7 @@ const (
|
|||||||
|
|
||||||
// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1".
|
// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1".
|
||||||
type LANHostConfigManagement1 struct {
|
type LANHostConfigManagement1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -641,7 +641,7 @@ func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, e
|
|||||||
|
|
||||||
// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1".
|
// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1".
|
||||||
type Layer3Forwarding1 struct {
|
type Layer3Forwarding1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -708,7 +708,7 @@ func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnec
|
|||||||
|
|
||||||
// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1".
|
// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1".
|
||||||
type WANCableLinkConfig1 struct {
|
type WANCableLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1029,7 +1029,7 @@ func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err er
|
|||||||
|
|
||||||
// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1".
|
// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1".
|
||||||
type WANCommonInterfaceConfig1 struct {
|
type WANCommonInterfaceConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -1375,7 +1375,7 @@ func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnection
|
|||||||
|
|
||||||
// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1".
|
// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1".
|
||||||
type WANDSLLinkConfig1 struct {
|
type WANDSLLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -1696,7 +1696,7 @@ func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err er
|
|||||||
|
|
||||||
// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1".
|
// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1".
|
||||||
type WANEthernetLinkConfig1 struct {
|
type WANEthernetLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1732,7 +1732,7 @@ func (client *WANEthernetLinkConfig1) GetEthernetLinkStatus() (NewEthernetLinkSt
|
|||||||
|
|
||||||
// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1".
|
// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1".
|
||||||
type WANIPConnection1 struct {
|
type WANIPConnection1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -2444,7 +2444,7 @@ func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress str
|
|||||||
|
|
||||||
// WANIPConnection2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:2".
|
// WANIPConnection2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:2".
|
||||||
type WANIPConnection2 struct {
|
type WANIPConnection2 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -3347,7 +3347,7 @@ func (client *WANIPConnection2) AddAnyPortMapping(NewRemoteHost string, NewExter
|
|||||||
|
|
||||||
// WANIPv6FirewallControl1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1".
|
// WANIPv6FirewallControl1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1".
|
||||||
type WANIPv6FirewallControl1 struct {
|
type WANIPv6FirewallControl1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -3663,7 +3663,7 @@ func (client *WANIPv6FirewallControl1) CheckPinholeWorking(UniqueID uint16) (IsW
|
|||||||
|
|
||||||
// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1".
|
// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1".
|
||||||
type WANPOTSLinkConfig1 struct {
|
type WANPOTSLinkConfig1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
@ -3983,7 +3983,7 @@ func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRComman
|
|||||||
|
|
||||||
// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1".
|
// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1".
|
||||||
type WANPPPConnection1 struct {
|
type WANPPPConnection1 struct {
|
||||||
SOAPClient soap.SOAPClient
|
SOAPClient *soap.SOAPClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
@ -85,7 +85,6 @@ func (device *Device) VisitServices(visitor func(*Service)) {
|
|||||||
func (device *Device) FindService(serviceType string) []*Service {
|
func (device *Device) FindService(serviceType string) []*Service {
|
||||||
var services []*Service
|
var services []*Service
|
||||||
device.VisitServices(func(s *Service) {
|
device.VisitServices(func(s *Service) {
|
||||||
fmt.Println(s.ServiceType)
|
|
||||||
if s.ServiceType == serviceType {
|
if s.ServiceType == serviceType {
|
||||||
services = append(services, s)
|
services = append(services, s)
|
||||||
}
|
}
|
||||||
|
26
goupnp.go
26
goupnp.go
@ -11,23 +11,6 @@ import (
|
|||||||
"github.com/huin/goupnp/ssdp"
|
"github.com/huin/goupnp/ssdp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Non-exhaustive set of UPnP service types.
|
|
||||||
const (
|
|
||||||
ServiceTypeLayer3Forwarding = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
|
|
||||||
ServiceTypeWANCommonInterfaceConfig = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
|
|
||||||
// WANPPPConnection is typically useful with regard to the external IP and
|
|
||||||
// port forwarding.
|
|
||||||
// http://upnp.org/specs/gw/UPnP-gw-WANPPPConnection-v1-Service.pdf
|
|
||||||
ServiceTypeWANPPPConnection = "urn:schemas-upnp-org:service:WANPPPConnection:1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Non-exhaustive set of UPnP device types.
|
|
||||||
const (
|
|
||||||
// Device type for InternetGatewayDevice.
|
|
||||||
// http://upnp.org/specs/gw/upnp-gw-internetgatewaydevice-v1-device.pdf
|
|
||||||
DeviceTypeInternetGatewayDevice = "urn:schemas-upnp-org:device:InternetGatewayDevice:1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ContextError is an error that wraps an error with some context information.
|
// ContextError is an error that wraps an error with some context information.
|
||||||
type ContextError struct {
|
type ContextError struct {
|
||||||
Context string
|
Context string
|
||||||
@ -45,10 +28,11 @@ type MaybeRootDevice struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DiscoverDevices attempts to find targets of the given type. This is
|
// DiscoverDevices attempts to find targets of the given type. This is
|
||||||
// typically the entry-point for this package. searchTarget is typically a
|
// typically the entry-point for this package. searchTarget is typically a URN
|
||||||
// value from a DeviceType* or ServiceType* constant. An error is returned for
|
// in the form "urn:schemas-upnp-org:device:..." or
|
||||||
// errors while attempting to send the query. An error or RootDevice is
|
// "urn:schemas-upnp-org:service:...". A single error is returned for errors
|
||||||
// returned for each discovered RootDevice.
|
// while attempting to send the query. An error or RootDevice is returned for
|
||||||
|
// each discovered RootDevice.
|
||||||
func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) {
|
func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) {
|
||||||
httpu, err := httpu.NewHTTPUClient()
|
httpu, err := httpu.NewHTTPUClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user