p2p/nat: add timeout for UPnP SOAP requests

This commit is contained in:
Felix Lange 2015-06-04 14:05:52 +02:00
parent 6a831ca015
commit fc6a5ae3ec

View File

@ -12,6 +12,8 @@ import (
"github.com/huin/goupnp/dcps/internetgateway2" "github.com/huin/goupnp/dcps/internetgateway2"
) )
const soapRequestTimeout = 3 * time.Second
type upnp struct { type upnp struct {
dev *goupnp.RootDevice dev *goupnp.RootDevice
service string service string
@ -131,6 +133,7 @@ func discover(out chan<- *upnp, target string, matcher func(*goupnp.RootDevice,
} }
// check for a matching IGD service // check for a matching IGD service
sc := goupnp.ServiceClient{service.NewSOAPClient(), devs[i].Root, service} sc := goupnp.ServiceClient{service.NewSOAPClient(), devs[i].Root, service}
sc.SOAPClient.HTTPClient.Timeout = soapRequestTimeout
upnp := matcher(devs[i].Root, sc) upnp := matcher(devs[i].Root, sc)
if upnp == nil { if upnp == nil {
return return