|
|
@ -40,11 +40,7 @@ func Discover() (nat NAT, err error) { |
|
|
|
return |
|
|
|
} |
|
|
|
socket := conn.(*net.UDPConn) |
|
|
|
defer func() { |
|
|
|
if err := socket.Close(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
}() |
|
|
|
defer socket.Close() |
|
|
|
|
|
|
|
if err := socket.SetDeadline(time.Now().Add(3 * time.Second)); err != nil { |
|
|
|
return nil, err |
|
|
@ -201,11 +197,8 @@ func getServiceURL(rootURL string) (url, urnDomain string, err error) { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
defer func() { |
|
|
|
if err := r.Body.Close(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
}() |
|
|
|
defer r.Body.Close() |
|
|
|
|
|
|
|
if r.StatusCode >= 400 { |
|
|
|
err = errors.New(string(r.StatusCode)) |
|
|
|
return |
|
|
@ -303,11 +296,7 @@ func (n *upnpNAT) getExternalIPAddress() (info statusInfo, err error) { |
|
|
|
var response *http.Response |
|
|
|
response, err = soapRequest(n.serviceURL, "GetExternalIPAddress", message, n.urnDomain) |
|
|
|
if response != nil { |
|
|
|
defer func() { |
|
|
|
if err := response.Body.Close(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
}() |
|
|
|
defer response.Body.Close() |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return |
|
|
@ -356,11 +345,7 @@ func (n *upnpNAT) AddPortMapping(protocol string, externalPort, internalPort int |
|
|
|
var response *http.Response |
|
|
|
response, err = soapRequest(n.serviceURL, "AddPortMapping", message, n.urnDomain) |
|
|
|
if response != nil { |
|
|
|
defer func() { |
|
|
|
if err := response.Body.Close(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
}() |
|
|
|
defer response.Body.Close() |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return |
|
|
@ -386,11 +371,7 @@ func (n *upnpNAT) DeletePortMapping(protocol string, externalPort, internalPort |
|
|
|
var response *http.Response |
|
|
|
response, err = soapRequest(n.serviceURL, "DeletePortMapping", message, n.urnDomain) |
|
|
|
if response != nil { |
|
|
|
defer func() { |
|
|
|
if err := response.Body.Close(); err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
}() |
|
|
|
defer response.Body.Close() |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|