aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/huin/goupnp/service_client.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-10-29 01:05:01 +0800
committerFelix Lange <fjl@twurst.com>2016-10-29 01:05:01 +0800
commit289b30715d097edafd5562f66cb3567a70b2d330 (patch)
tree7eaaa6da97c84727469303b986e364606ece57ce /vendor/github.com/huin/goupnp/service_client.go
parent77703045765343c489ded2f43e3ed0f332c5f148 (diff)
downloaddexon-289b30715d097edafd5562f66cb3567a70b2d330.tar
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.gz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.bz2
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.lz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.xz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.zst
dexon-289b30715d097edafd5562f66cb3567a70b2d330.zip
Godeps, vendor: convert dependency management to trash (#3198)
This commit converts the dependency management from Godeps to the vendor folder, also switching the tool from godep to trash. Since the upstream tool lacks a few features proposed via a few PRs, until those PRs are merged in (if), use github.com/karalabe/trash. You can update dependencies via trash --update. All dependencies have been updated to their latest version. Parts of the build system are reworked to drop old notions of Godeps and invocation of the go vet command so that it doesn't run against the vendor folder, as that will just blow up during vetting. The conversion drops OpenCL (and hence GPU mining support) from ethash and our codebase. The short reasoning is that there's noone to maintain and having opencl libs in our deps messes up builds as go install ./... tries to build them, failing with unsatisfied link errors for the C OpenCL deps. golang.org/x/net/context is not vendored in. We expect it to be fetched by the user (i.e. using go get). To keep ci.go builds reproducible the package is "vendored" in build/_vendor.
Diffstat (limited to 'vendor/github.com/huin/goupnp/service_client.go')
-rw-r--r--vendor/github.com/huin/goupnp/service_client.go88
1 files changed, 88 insertions, 0 deletions
diff --git a/vendor/github.com/huin/goupnp/service_client.go b/vendor/github.com/huin/goupnp/service_client.go
new file mode 100644
index 000000000..9111c93cb
--- /dev/null
+++ b/vendor/github.com/huin/goupnp/service_client.go
@@ -0,0 +1,88 @@
+package goupnp
+
+import (
+ "fmt"
+ "net/url"
+
+ "github.com/huin/goupnp/soap"
+)
+
+// ServiceClient is a SOAP client, root device and the service for the SOAP
+// client rolled into one value. The root device, location, and service are
+// intended to be informational. Location can be used to later recreate a
+// ServiceClient with NewServiceClientByURL if the service is still present;
+// bypassing the discovery process.
+type ServiceClient struct {
+ SOAPClient *soap.SOAPClient
+ RootDevice *RootDevice
+ Location *url.URL
+ Service *Service
+}
+
+// NewServiceClients discovers services, and returns clients for them. err will
+// report any error with the discovery process (blocking any device/service
+// discovery), errors reports errors on a per-root-device basis.
+func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error) {
+ var maybeRootDevices []MaybeRootDevice
+ if maybeRootDevices, err = DiscoverDevices(searchTarget); err != nil {
+ return
+ }
+
+ clients = make([]ServiceClient, 0, len(maybeRootDevices))
+
+ for _, maybeRootDevice := range maybeRootDevices {
+ if maybeRootDevice.Err != nil {
+ errors = append(errors, maybeRootDevice.Err)
+ continue
+ }
+
+ deviceClients, err := NewServiceClientsFromRootDevice(maybeRootDevice.Root, maybeRootDevice.Location, searchTarget)
+ if err != nil {
+ errors = append(errors, err)
+ continue
+ }
+ clients = append(clients, deviceClients...)
+ }
+
+ return
+}
+
+// NewServiceClientsByURL creates client(s) for the given service URN, for a
+// root device at the given URL.
+func NewServiceClientsByURL(loc *url.URL, searchTarget string) ([]ServiceClient, error) {
+ rootDevice, err := DeviceByURL(loc)
+ if err != nil {
+ return nil, err
+ }
+ return NewServiceClientsFromRootDevice(rootDevice, loc, searchTarget)
+}
+
+// NewServiceClientsFromDevice creates client(s) for the given service URN, in
+// a given root device. The loc parameter is simply assigned to the
+// Location attribute of the returned ServiceClient(s).
+func NewServiceClientsFromRootDevice(rootDevice *RootDevice, loc *url.URL, searchTarget string) ([]ServiceClient, error) {
+ device := &rootDevice.Device
+ srvs := device.FindService(searchTarget)
+ if len(srvs) == 0 {
+ return nil, fmt.Errorf("goupnp: service %q not found within device %q (UDN=%q)",
+ searchTarget, device.FriendlyName, device.UDN)
+ }
+
+ clients := make([]ServiceClient, 0, len(srvs))
+ for _, srv := range srvs {
+ clients = append(clients, ServiceClient{
+ SOAPClient: srv.NewSOAPClient(),
+ RootDevice: rootDevice,
+ Location: loc,
+ Service: srv,
+ })
+ }
+ return clients, nil
+}
+
+// GetServiceClient returns the ServiceClient itself. This is provided so that the
+// service client attributes can be accessed via an interface method on a
+// wrapping type.
+func (client *ServiceClient) GetServiceClient() *ServiceClient {
+ return client
+}