mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-01 12:33:53 +01:00
23 lines
457 B
Go
23 lines
457 B
Go
|
package iface
|
||
|
|
||
|
import "sync"
|
||
|
|
||
|
// NewWGIFace Creates a new Wireguard interface instance
|
||
|
func NewWGIFace(ifaceName string, address string, mtu int, tunAdapter TunAdapter) (*WGIface, error) {
|
||
|
wgIface := &WGIface{
|
||
|
mu: sync.Mutex{},
|
||
|
}
|
||
|
|
||
|
wgAddress, err := parseWGAddress(address)
|
||
|
if err != nil {
|
||
|
return wgIface, err
|
||
|
}
|
||
|
|
||
|
tun := newTunDevice(wgAddress, mtu, tunAdapter)
|
||
|
wgIface.tun = tun
|
||
|
|
||
|
wgIface.configurer = newWGConfigurer(tun)
|
||
|
|
||
|
return wgIface, nil
|
||
|
}
|