From cd9396993057ba25ef904a890f2e01e5b73b1286 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 24 Oct 2019 23:37:39 +0100 Subject: [PATCH] Fix isOpen for TUN/TAP actor --- src/tuntap/tun.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 06feede..f0250c9 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -143,9 +143,12 @@ func (tun *TunAdapter) Start() error { } func (tun *TunAdapter) _start() error { + if tun.isOpen { + return errors.New("TUN/TAP module is already started") + } current := tun.config.GetCurrent() if tun.config == nil || tun.listener == nil || tun.dialer == nil { - return errors.New("No configuration available to TUN/TAP") + return errors.New("no configuration available to TUN/TAP") } var boxPub crypto.BoxPubKey boxPubHex, err := hex.DecodeString(current.EncryptionPublicKey) @@ -182,7 +185,11 @@ func (tun *TunAdapter) _start() error { // IsStarted returns true if the module has been started. func (tun *TunAdapter) IsStarted() bool { - return tun.isOpen + var isOpen bool + phony.Block(tun, func() { + isOpen = tun.isOpen + }) + return isOpen } // Start the setup process for the TUN/TAP adapter. If successful, starts the