Remove waitForTUNUp from TUN

Causes issues such as #1156.
This commit is contained in:
Neil Alexander 2024-08-07 19:52:19 +01:00
parent 5e5de3a343
commit 63cd757525
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
5 changed files with 0 additions and 27 deletions

View File

@ -11,7 +11,6 @@ import (
"io" "io"
"net" "net"
"sync" "sync"
"time"
"github.com/Arceliar/phony" "github.com/Arceliar/phony"
wgtun "golang.zx2c4.com/wireguard/tun" wgtun "golang.zx2c4.com/wireguard/tun"
@ -65,20 +64,6 @@ func getSupportedMTU(mtu uint64) uint64 {
return mtu 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 // Name returns the name of the adapter, e.g. "tun0". On Windows, this may
// return a canonical adapter name instead. // return a canonical adapter name instead.
func (tun *TunAdapter) Name() string { func (tun *TunAdapter) Name() string {

View File

@ -80,9 +80,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create TUN: %w", err) 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 tun.iface = iface
if mtu, err := iface.MTU(); err == nil { if mtu, err := iface.MTU(); err == nil {
tun.mtu = getSupportedMTU(uint64(mtu)) tun.mtu = getSupportedMTU(uint64(mtu))

View File

@ -27,9 +27,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create TUN: %w", err) 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 tun.iface = iface
if m, err := iface.MTU(); err == nil { if m, err := iface.MTU(); err == nil {
tun.mtu = getSupportedMTU(uint64(m)) tun.mtu = getSupportedMTU(uint64(m))

View File

@ -21,9 +21,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create TUN: %w", err) 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 tun.iface = iface
if mtu, err := iface.MTU(); err == nil { if mtu, err := iface.MTU(); err == nil {
tun.mtu = getSupportedMTU(uint64(mtu)) tun.mtu = getSupportedMTU(uint64(mtu))

View File

@ -18,9 +18,6 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create TUN: %w", err) 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 tun.iface = iface
if mtu, err := iface.MTU(); err == nil { if mtu, err := iface.MTU(); err == nil {
tun.mtu = getSupportedMTU(uint64(mtu)) tun.mtu = getSupportedMTU(uint64(mtu))