device: fail to give bind if it doesn't exist
This commit is contained in:
parent
95c70b8032
commit
c718f3940d
|
@ -5,8 +5,14 @@
|
||||||
|
|
||||||
package device
|
package device
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
func (device *Device) PeekLookAtSocketFd4() (fd int, err error) {
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -20,7 +26,11 @@ func (device *Device) PeekLookAtSocketFd4() (fd int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (device *Device) PeekLookAtSocketFd6() (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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ func deviceUpdateState(device *Device) {
|
||||||
switch newIsUp {
|
switch newIsUp {
|
||||||
case true:
|
case true:
|
||||||
if err := device.BindUpdate(); err != nil {
|
if err := device.BindUpdate(); err != nil {
|
||||||
|
device.log.Error.Printf("Unable to update bind: %v\n", err)
|
||||||
device.isUp.Set(false)
|
device.isUp.Set(false)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue