Split create Interface based on OS with elevate

This commit is contained in:
mlsmaycon 2021-06-06 21:51:56 +02:00
parent 6e4c232ff2
commit 255ad7faa9

View File

@ -2,12 +2,11 @@ package iface
import (
log "github.com/sirupsen/logrus"
"net"
"golang.zx2c4.com/wireguard/ipc"
"golang.zx2c4.com/wireguard/tun"
"golang.zx2c4.com/wireguard/windows/elevate"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
"net"
)
// assignAddr Adds IP address to the tunnel interface and network route based on the range provided
@ -38,7 +37,7 @@ func createIface(iface string, defaultMTU int) (tun.Device, error) {
var tunDevice tun.Device
err := elevate.DoAsSystem(func() error {
var err error
tunDevice, err = tun.CreateTUNWithRequestedGUID(iface, &windows.GUID{12, 12, 12, [8]byte{12, 12, 12, 12, 12, 12, 12, 12}}, defaultMTU)
tunDevice, err = tun.CreateTUN(iface, defaultMTU)
return err
})
if err != nil {