aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@tailscale.io>2019-10-22 20:15:27 +0200
committerDavid Crawshaw <crawshaw@tailscale.io>2019-10-22 20:55:36 +0200
commit18b15446b018126e5f6b4bbd67f0a317bbf8aa30 (patch)
tree0e6cd4bfb4e01b5db1da39b5f840bd41a671639c
parentglobal: fix a few typos courtesy of codespell (diff)
downloadwireguard-go-dc/patch.tar.xz
wireguard-go-dc/patch.zip
tun: extra error context in CreateTUNFromFile on darwindc/patch
This function works on iOS with Go 1.13.0 (cc8838d645b), but net.InterfaceByName reports an error with Go 1.13.3 (e64356a448): tun creation: net.InterfaceByName("utun1"): route ip+net: sysctl: operation not supported Extra context information gives a clue as to what is going on.
-rw-r--r--tun/tun_darwin.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go
index 6d2e6dd..01274ba 100644
--- a/tun/tun_darwin.go
+++ b/tun/tun_darwin.go
@@ -178,13 +178,13 @@ func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
name, err := tun.Name()
if err != nil {
tun.tunFile.Close()
- return nil, err
+ return nil, fmt.Errorf("tun.Name: %v", err)
}
tunIfindex, err := func() (int, error) {
iface, err := net.InterfaceByName(name)
if err != nil {
- return -1, err
+ return -1, fmt.Errorf("net.InterfaceByName(%q): %v", name, err)
}
return iface.Index, nil
}()
@@ -196,7 +196,7 @@ func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
tun.routeSocket, err = unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
if err != nil {
tun.tunFile.Close()
- return nil, err
+ return nil, fmt.Errorf("unix.Socket: %v", err)
}
go tun.routineRouteListener(tunIfindex)