mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-23 08:51:29 +02:00
29 lines
688 B
Go
29 lines
688 B
Go
//go:build !android
|
|
|
|
package iface
|
|
|
|
import (
|
|
"github.com/pion/transport/v2"
|
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
|
|
|
"sync"
|
|
)
|
|
|
|
// NewWGIFace Creates a new WireGuard interface instance
|
|
func NewWGIFace(iFaceName string, address string, mtu int, preSharedKey *wgtypes.Key, tunAdapter TunAdapter, transportNet transport.Net) (*WGIface, error) {
|
|
wgIFace := &WGIface{
|
|
mu: sync.Mutex{},
|
|
}
|
|
|
|
wgAddress, err := parseWGAddress(address)
|
|
if err != nil {
|
|
return wgIFace, err
|
|
}
|
|
|
|
wgIFace.tun = newTunDevice(iFaceName, wgAddress, mtu, transportNet)
|
|
|
|
wgIFace.configurer = newWGConfigurer(iFaceName, preSharedKey)
|
|
wgIFace.userspaceBind = !WireGuardModuleIsLoaded()
|
|
return wgIFace, nil
|
|
}
|