summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/util/net/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/util/net/util.go')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/util.go31
1 files changed, 7 insertions, 24 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/util.go b/vendor/k8s.io/apimachinery/pkg/util/net/util.go
index 2e7cb9499..5950087e0 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/util.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/util.go
@@ -17,9 +17,8 @@ limitations under the License.
package net
import (
+ "errors"
"net"
- "net/url"
- "os"
"reflect"
"syscall"
)
@@ -40,34 +39,18 @@ func IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool {
// Returns if the given err is "connection reset by peer" error.
func IsConnectionReset(err error) bool {
- if urlErr, ok := err.(*url.Error); ok {
- err = urlErr.Err
- }
- if opErr, ok := err.(*net.OpError); ok {
- err = opErr.Err
- }
- if osErr, ok := err.(*os.SyscallError); ok {
- err = osErr.Err
- }
- if errno, ok := err.(syscall.Errno); ok && errno == syscall.ECONNRESET {
- return true
+ var errno syscall.Errno
+ if errors.As(err, &errno) {
+ return errno == syscall.ECONNRESET
}
return false
}
// Returns if the given err is "connection refused" error
func IsConnectionRefused(err error) bool {
- if urlErr, ok := err.(*url.Error); ok {
- err = urlErr.Err
- }
- if opErr, ok := err.(*net.OpError); ok {
- err = opErr.Err
- }
- if osErr, ok := err.(*os.SyscallError); ok {
- err = osErr.Err
- }
- if errno, ok := err.(syscall.Errno); ok && errno == syscall.ECONNREFUSED {
- return true
+ var errno syscall.Errno
+ if errors.As(err, &errno) {
+ return errno == syscall.ECONNREFUSED
}
return false
}