]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: fail to give bind if it doesn't exist
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 17 May 2019 13:35:20 +0000 (15:35 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 17 May 2019 13:35:20 +0000 (15:35 +0200)
device/boundif_android.go
device/device.go

index ecc9331619f638889c3c84ef9504cded998a835b..6d0fecf5d3cce8d55e1d3b915050bd4c80c66674 100644 (file)
@@ -5,8 +5,14 @@
 
 package device
 
+import "errors"
+
 func (device *Device) PeekLookAtSocketFd4() (fd int, err error) {
-       sysconn, err := device.net.bind.(*nativeBind).ipv4.SyscallConn()
+       nb, ok := device.net.bind.(*nativeBind)
+       if !ok {
+               return 0, errors.New("no socket exists")
+       }
+       sysconn, err := nb.ipv4.SyscallConn()
        if err != nil {
                return
        }
@@ -20,7 +26,11 @@ func (device *Device) PeekLookAtSocketFd4() (fd int, err error) {
 }
 
 func (device *Device) PeekLookAtSocketFd6() (fd int, err error) {
-       sysconn, err := device.net.bind.(*nativeBind).ipv6.SyscallConn()
+       nb, ok := device.net.bind.(*nativeBind)
+       if !ok {
+               return 0, errors.New("no socket exists")
+       }
+       sysconn, err := nb.ipv6.SyscallConn()
        if err != nil {
                return
        }
index ef269f5a9fc0a082c1540440f0032732b71659ea..fa7ed88fa720070fda57b66223dfb48f2728e488 100644 (file)
@@ -133,6 +133,7 @@ func deviceUpdateState(device *Device) {
        switch newIsUp {
        case true:
                if err := device.BindUpdate(); err != nil {
+                       device.log.Error.Printf("Unable to update bind: %v\n", err)
                        device.isUp.Set(false)
                        break
                }