diff --git a/src/tun/tun.go b/src/tun/tun.go index e6795c64..e7ba3a0f 100644 --- a/src/tun/tun.go +++ b/src/tun/tun.go @@ -11,7 +11,6 @@ import ( "io" "net" "sync" - "time" "github.com/Arceliar/phony" wgtun "golang.zx2c4.com/wireguard/tun" @@ -65,20 +64,6 @@ func getSupportedMTU(mtu uint64) uint64 { return mtu } -func waitForTUNUp(ch <-chan wgtun.Event) bool { - t := time.After(time.Second * 5) - for { - select { - case ev := <-ch: - if ev == wgtun.EventUp { - return true - } - case <-t: - return false - } - } -} - // Name returns the name of the adapter, e.g. "tun0". On Windows, this may // return a canonical adapter name instead. func (tun *TunAdapter) Name() string { diff --git a/src/tun/tun_bsd.go b/src/tun/tun_bsd.go index 7f26260c..da5b3297 100644 --- a/src/tun/tun_bsd.go +++ b/src/tun/tun_bsd.go @@ -80,9 +80,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { if err != nil { return fmt.Errorf("failed to create TUN: %w", err) } - if !waitForTUNUp(iface.Events()) { - return fmt.Errorf("TUN did not come up in time") - } tun.iface = iface if mtu, err := iface.MTU(); err == nil { tun.mtu = getSupportedMTU(uint64(mtu)) diff --git a/src/tun/tun_darwin.go b/src/tun/tun_darwin.go index a9d734bb..aa30b7f3 100644 --- a/src/tun/tun_darwin.go +++ b/src/tun/tun_darwin.go @@ -27,9 +27,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { if err != nil { return fmt.Errorf("failed to create TUN: %w", err) } - if !waitForTUNUp(iface.Events()) { - return fmt.Errorf("TUN did not come up in time") - } tun.iface = iface if m, err := iface.MTU(); err == nil { tun.mtu = getSupportedMTU(uint64(m)) diff --git a/src/tun/tun_linux.go b/src/tun/tun_linux.go index c98cdd73..98d63db4 100644 --- a/src/tun/tun_linux.go +++ b/src/tun/tun_linux.go @@ -21,9 +21,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { if err != nil { return fmt.Errorf("failed to create TUN: %w", err) } - if !waitForTUNUp(iface.Events()) { - return fmt.Errorf("TUN did not come up in time") - } tun.iface = iface if mtu, err := iface.MTU(); err == nil { tun.mtu = getSupportedMTU(uint64(mtu)) diff --git a/src/tun/tun_other.go b/src/tun/tun_other.go index fc940818..0ddd0c1e 100644 --- a/src/tun/tun_other.go +++ b/src/tun/tun_other.go @@ -18,9 +18,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { if err != nil { return fmt.Errorf("failed to create TUN: %w", err) } - if !waitForTUNUp(iface.Events()) { - return fmt.Errorf("TUN did not come up in time") - } tun.iface = iface if mtu, err := iface.MTU(); err == nil { tun.mtu = getSupportedMTU(uint64(mtu))