Merge remote-tracking branch 'origin/main' into feat-post_quantum_ml_kem

# Conflicts:
#	client/internal/peer/status.go
#	client/status/status.go
This commit is contained in:
riccardom
2026-10-16 14:13:53 +02:00
542 changed files with 46241 additions and 12060 deletions
+49 -1
View File
@@ -3,20 +3,28 @@ package peer
import (
"context"
"fmt"
"net"
"net/netip"
"os"
"testing"
"time"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"github.com/netbirdio/netbird/client/iface"
"github.com/netbirdio/netbird/client/iface/configurer"
"github.com/netbirdio/netbird/client/iface/wgaddr"
"github.com/netbirdio/netbird/client/iface/wgproxy"
"github.com/netbirdio/netbird/client/internal/metrics"
"github.com/netbirdio/netbird/client/internal/peer/conntype"
"github.com/netbirdio/netbird/client/internal/peer/dispatcher"
"github.com/netbirdio/netbird/client/internal/peer/guard"
"github.com/netbirdio/netbird/client/internal/peer/ice"
"github.com/netbirdio/netbird/client/internal/peer/worker"
"github.com/netbirdio/netbird/client/internal/stdnet"
"github.com/netbirdio/netbird/monotime"
"github.com/netbirdio/netbird/util"
)
@@ -42,7 +50,7 @@ func TestNewConn_interfaceFilter(t *testing.T) {
ignore := []string{iface.WgInterfaceDefault, "tun0", "zt", "ZeroTier", "utun", "wg", "ts",
"Tailscale", "tailscale"}
filter := stdnet.InterfaceFilter(ignore)
filter := stdnet.InterfaceFilter(ignore, nil)
for _, s := range ignore {
assert.Equal(t, filter(s), false)
@@ -414,3 +422,43 @@ func TestMetricsConnType_RelayedMatchesIsRelayed(t *testing.T) {
"priority %s: isRelayed and the %q metric tag must agree", priority, tag)
}
}
type stubWGIface struct{}
func (s *stubWGIface) UpdatePeer(peerKey string, allowedIps []netip.Prefix, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error {
return nil
}
func (s *stubWGIface) RemovePeer(peerKey string) error { return nil }
func (s *stubWGIface) GetStats() (map[string]configurer.WGStats, error) {
return map[string]configurer.WGStats{}, nil
}
func (s *stubWGIface) GetProxy() wgproxy.Proxy { return nil }
func (s *stubWGIface) Address() wgaddr.Address { return wgaddr.Address{} }
func (s *stubWGIface) RemoveEndpointAddress(key string) error { return nil }
func (s *stubWGIface) IsUserspaceBind() bool { return false }
func (s *stubWGIface) LastActivities() map[string]monotime.Time {
return map[string]monotime.Time{}
}
func TestConn_Close_CallsOnDisconnected(t *testing.T) {
var disconnected []string
conn := newWGTimeoutTestConn(true, &disconnected)
conn.endpointUpdater = NewEndpointUpdater(conn.Log, conn.config.WgConfig, false)
conn.config.WgConfig.WgInterface = &stubWGIface{}
conn.endpointUpdater.wgConfig.WgInterface = &stubWGIface{}
conn.workerRelay = &WorkerRelay{}
ctx, cancel := context.WithCancel(context.Background())
conn.ctx = ctx
conn.ctxCancel = cancel
conn.opened = true
conn.statusICE = worker.NewAtomicStatus()
conn.statusRelay = worker.NewAtomicStatus()
conn.statusRecorder = NewRecorder("https://mgm")
// The connection is closed while in a disconnected or connecting state
// (e.g. peer dropped, ICE failed, or management disconnect).
conn.Close(false)
assert.Equal(t, []string{conn.config.WgConfig.RemoteKey}, disconnected,
"Close must notify onDisconnected so Rosenpass cleans up its peer worker")
}