mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 03:11:02 +01:00
30ebcf38c7
In the case of user space WireGuard mode, use in-memory proxy between the TURN/Relay connection and the WireGuard Bind. We keep the UDP proxy and eBPF proxy for kernel mode. The key change is the new wgproxy/bind and the iface/bind/ice_bind changes. Everything else is just to fulfill the dependencies.
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
//go:build linux && !android
|
|
|
|
package wgproxy
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/netbirdio/netbird/client/iface/wgproxy/ebpf"
|
|
)
|
|
|
|
func TestProxyCloseByRemoteConnEBPF(t *testing.T) {
|
|
if os.Getenv("GITHUB_ACTIONS") != "true" {
|
|
t.Skip("Skipping test as it requires root privileges")
|
|
}
|
|
ctx := context.Background()
|
|
|
|
ebpfProxy := ebpf.NewWGEBPFProxy(51831)
|
|
if err := ebpfProxy.Listen(); err != nil {
|
|
t.Fatalf("failed to initialize ebpf proxy: %s", err)
|
|
}
|
|
|
|
defer func() {
|
|
if err := ebpfProxy.Free(); err != nil {
|
|
t.Errorf("failed to free ebpf proxy: %s", err)
|
|
}
|
|
}()
|
|
|
|
tests := []struct {
|
|
name string
|
|
proxy Proxy
|
|
}{
|
|
{
|
|
name: "ebpf proxy",
|
|
proxy: &ebpf.ProxyWrapper{
|
|
WgeBPFProxy: ebpfProxy,
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
relayedConn := newMockConn()
|
|
err := tt.proxy.AddTurnConn(ctx, nil, relayedConn)
|
|
if err != nil {
|
|
t.Errorf("error: %v", err)
|
|
}
|
|
|
|
_ = relayedConn.Close()
|
|
if err := tt.proxy.CloseConn(); err != nil {
|
|
t.Errorf("error: %v", err)
|
|
}
|
|
})
|
|
}
|
|
}
|