From 3107eb901bc63e32b059daef9ce0f694fa890668 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Sat, 11 Jul 2026 20:09:59 +0200 Subject: [PATCH] [client] Trim WGIface to the methods peer uses and inline it into conn.go Drop the unused Address() method from WGIface (only ice.Candidate.Address was ever called, never the wg interface), and move the interface next to its sole user WgConfig in conn.go, removing iface.go. --- client/internal/peer/conn.go | 8 ++++++++ client/internal/peer/iface.go | 22 ---------------------- 2 files changed, 8 insertions(+), 22 deletions(-) delete mode 100644 client/internal/peer/iface.go diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 5029960e1..e853631cb 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -38,6 +38,14 @@ import ( // considered desynced and gets reset. const wgTimeoutEscalationThreshold = 3 +type WGIface interface { + UpdatePeer(peerKey string, allowedIps []netip.Prefix, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error + RemovePeer(peerKey string) error + GetStats() (map[string]configurer.WGStats, error) + GetProxy() wgproxy.Proxy + RemoveEndpointAddress(key string) error +} + // MetricsRecorder is an interface for recording peer connection metrics type MetricsRecorder interface { RecordConnectionStages( diff --git a/client/internal/peer/iface.go b/client/internal/peer/iface.go deleted file mode 100644 index 678396e61..000000000 --- a/client/internal/peer/iface.go +++ /dev/null @@ -1,22 +0,0 @@ -package peer - -import ( - "net" - "net/netip" - "time" - - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" - - "github.com/netbirdio/netbird/client/iface/configurer" - "github.com/netbirdio/netbird/client/iface/wgaddr" - "github.com/netbirdio/netbird/client/iface/wgproxy" -) - -type WGIface interface { - UpdatePeer(peerKey string, allowedIps []netip.Prefix, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error - RemovePeer(peerKey string) error - GetStats() (map[string]configurer.WGStats, error) - GetProxy() wgproxy.Proxy - Address() wgaddr.Address - RemoveEndpointAddress(key string) error -}