Commit fc6a5ae3 authored by Felix Lange's avatar Felix Lange

p2p/nat: add timeout for UPnP SOAP requests

parent 6a831ca0
...@@ -12,6 +12,8 @@ import ( ...@@ -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, ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment