This commit is contained in:
miloschwartz
2025-11-18 14:52:44 -05:00
parent 5b8c13322b
commit 1a7aba8bbe
2 changed files with 10 additions and 5 deletions

View File

@@ -16,10 +16,6 @@ import (
// ConfigureInterface configures a network interface with an IP address and brings it up
func ConfigureInterface(interfaceName string, wgData WgData) error {
if interfaceName == "" {
return nil
}
var ipAddr string = wgData.TunnelIP
// Parse the IP address and network

View File

@@ -18,12 +18,21 @@ func createTUNFromFD(tunFd uint32, mtuInt int) (tun.Device, error) {
logger.Error("Unable to dup tun fd: %v", err)
return nil, err
}
err = unix.SetNonblock(dupTunFd, true)
if err != nil {
unix.Close(dupTunFd)
return nil, err
}
return tun.CreateTUNFromFile(os.NewFile(uintptr(dupTunFd), "/dev/tun"), mtuInt)
file := os.NewFile(uintptr(dupTunFd), "/dev/tun")
device, err := tun.CreateTUNFromFile(file, mtuInt)
if err != nil {
file.Close()
return nil, err
}
return device, nil
}
func uapiOpen(interfaceName string) (*os.File, error) {