mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:24:18 -04:00
28 lines
705 B
Go
28 lines
705 B
Go
package device
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
|
|
|
"github.com/netbirdio/netbird/client/iface/bind"
|
|
"github.com/netbirdio/netbird/client/iface/netstack"
|
|
"github.com/netbirdio/netbird/client/iface/wgaddr"
|
|
)
|
|
|
|
func TestNewNetstackDevice(t *testing.T) {
|
|
privateKey, _ := wgtypes.GeneratePrivateKey()
|
|
wgAddress, _ := wgaddr.ParseWGAddress("1.2.3.4/24")
|
|
|
|
relayBind := bind.NewRelayBindJS()
|
|
nsTun := NewNetstackDevice("wtx", wgAddress, 1234, privateKey.String(), 1500, relayBind, netstack.ListenAddr())
|
|
|
|
cfgr, err := nsTun.Create()
|
|
if err != nil {
|
|
t.Fatalf("failed to create netstack device: %v", err)
|
|
}
|
|
if cfgr == nil {
|
|
t.Fatal("expected non-nil configurer")
|
|
}
|
|
}
|