Skip to content

Commit 67211e2

Browse files
committed
fix(upnp): bound discovery and SOAP request time
Signed-off-by: colinaumaty <colinaumaty@outlook.com>
1 parent 8d08e0f commit 67211e2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

upnp.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import (
4545
"time"
4646
)
4747

48+
var upnpHTTPClient = &http.Client{Timeout: 3 * time.Second}
49+
4850
// NAT is an interface representing a NAT traversal options for example UPNP or
4951
// NAT-PMP. It provides methods to query and manipulate this traversal to allow
5052
// access to services.
@@ -223,7 +225,7 @@ func getOurIP() (ip string, err error) {
223225
// getServiceURL parses the xml description at the given root url to find the
224226
// url for the WANIPConnection service to be used for port forwarding.
225227
func getServiceURL(rootURL string) (url string, err error) {
226-
r, err := http.Get(rootURL)
228+
r, err := upnpHTTPClient.Get(rootURL)
227229
if err != nil {
228230
return
229231
}
@@ -304,7 +306,7 @@ func soapRequest(url, function, message string) (replyXML []byte, err error) {
304306
req.Header.Set("Cache-Control", "no-cache")
305307
req.Header.Set("Pragma", "no-cache")
306308

307-
r, err := http.DefaultClient.Do(req)
309+
r, err := upnpHTTPClient.Do(req)
308310
if err != nil {
309311
return nil, err
310312
}

0 commit comments

Comments
 (0)