From c53831696b5aee61823c0da62a96055d3f0e02fd Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 1 Sep 2019 13:06:25 -0500 Subject: [PATCH] make tun stop check that iface is not nil, in case it wasn't set for some reason (windows bugs) --- src/tuntap/tun.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 8e1e5b0..74d055e 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -189,9 +189,11 @@ func (tun *TunAdapter) Stop() error { func (tun *TunAdapter) _stop() error { tun.isOpen = false - // TODO: we have nothing that cleanly stops all the various goroutines opened // by TUN/TAP, e.g. readers/writers, sessions - tun.iface.Close() + if tun.iface != nil { + // Just in case we failed to start up the iface for some reason, this can apparently happen on Windows + tun.iface.Close() + } return nil }