mirror of
https://github.com/fosrl/olm.git
synced 2026-02-21 04:16:42 +00:00
@@ -16,10 +16,6 @@ import (
|
|||||||
|
|
||||||
// ConfigureInterface configures a network interface with an IP address and brings it up
|
// ConfigureInterface configures a network interface with an IP address and brings it up
|
||||||
func ConfigureInterface(interfaceName string, wgData WgData) error {
|
func ConfigureInterface(interfaceName string, wgData WgData) error {
|
||||||
if interfaceName == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var ipAddr string = wgData.TunnelIP
|
var ipAddr string = wgData.TunnelIP
|
||||||
|
|
||||||
// Parse the IP address and network
|
// Parse the IP address and network
|
||||||
|
|||||||
11
olm/unix.go
11
olm/unix.go
@@ -18,12 +18,21 @@ func createTUNFromFD(tunFd uint32, mtuInt int) (tun.Device, error) {
|
|||||||
logger.Error("Unable to dup tun fd: %v", err)
|
logger.Error("Unable to dup tun fd: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = unix.SetNonblock(dupTunFd, true)
|
err = unix.SetNonblock(dupTunFd, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
unix.Close(dupTunFd)
|
||||||
return nil, err
|
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) {
|
func uapiOpen(interfaceName string) (*os.File, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user