From 50ebbe482e7b38936b47dfda4b6c167390606932 Mon Sep 17 00:00:00 2001 From: Viktor Liu <17948409+lixmal@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:05:13 +0200 Subject: [PATCH] [client] Don't overwrite allowed IPs when updating the wg peer's endpoint address (#2578) This will fix broken routes on routing clients when upgrading/downgrading from/to relayed connections. --- iface/wg_configurer_kernel_unix.go | 5 +++-- iface/wg_configurer_usp.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/iface/wg_configurer_kernel_unix.go b/iface/wg_configurer_kernel_unix.go index 48ea70b7b..8b47082da 100644 --- a/iface/wg_configurer_kernel_unix.go +++ b/iface/wg_configurer_kernel_unix.go @@ -56,8 +56,9 @@ func (c *wgKernelConfigurer) updatePeer(peerKey string, allowedIps string, keepA return err } peer := wgtypes.PeerConfig{ - PublicKey: peerKeyParsed, - ReplaceAllowedIPs: true, + PublicKey: peerKeyParsed, + ReplaceAllowedIPs: false, + // don't replace allowed ips, wg will handle duplicated peer IP AllowedIPs: []net.IPNet{*ipNet}, PersistentKeepaliveInterval: &keepAlive, Endpoint: endpoint, diff --git a/iface/wg_configurer_usp.go b/iface/wg_configurer_usp.go index 04a29a60b..cd1d9d0b6 100644 --- a/iface/wg_configurer_usp.go +++ b/iface/wg_configurer_usp.go @@ -64,8 +64,9 @@ func (c *wgUSPConfigurer) updatePeer(peerKey string, allowedIps string, keepAliv return err } peer := wgtypes.PeerConfig{ - PublicKey: peerKeyParsed, - ReplaceAllowedIPs: true, + PublicKey: peerKeyParsed, + ReplaceAllowedIPs: false, + // don't replace allowed ips, wg will handle duplicated peer IP AllowedIPs: []net.IPNet{*ipNet}, PersistentKeepaliveInterval: &keepAlive, PresharedKey: preSharedKey,