summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_darwin.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 19:48:27 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 19:50:31 +0100
commitc040dea7985b7b5a35ca2fa746c3385732c44bd1 (patch)
treed9dc0633a65e854ffeea40d3bcf9f54ea8ec018a /tun/tun_darwin.go
parent5cdb862f15fc4d0772ace2ca3fd0271233012185 (diff)
tun: use errors.Is for unwrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun/tun_darwin.go')
-rw-r--r--tun/tun_darwin.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go
index 7c7f3e2..f513d03 100644
--- a/tun/tun_darwin.go
+++ b/tun/tun_darwin.go
@@ -6,6 +6,7 @@
package tun
import (
+ "errors"
"fmt"
"io/ioutil"
"net"
@@ -31,13 +32,9 @@ type NativeTun struct {
func retryInterfaceByIndex(index int) (iface *net.Interface, err error) {
for i := 0; i < 20; i++ {
iface, err = net.InterfaceByIndex(index)
- if err != nil {
- if opErr, ok := err.(*net.OpError); ok {
- if syscallErr, ok := opErr.Err.(*os.SyscallError); ok && syscallErr.Err == syscall.ENOMEM {
- time.Sleep(time.Duration(i) * time.Second / 3)
- continue
- }
- }
+ if err != nil && errors.Is(err, syscall.ENOMEM) {
+ time.Sleep(time.Duration(i) * time.Second / 3)
+ continue
}
return iface, err
}