From d48acfba39669f2d563c88a89ceea86d049c7fda Mon Sep 17 00:00:00 2001 From: FranceNuage Date: Thu, 4 Sep 2025 14:09:58 +0200 Subject: [PATCH 1/2] fix: add ipv6 endpoint formatter Former-commit-id: 5b443a41a3c7d88a33aef0febf40196772f91eb5 --- peermonitor/peermonitor.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/peermonitor/peermonitor.go b/peermonitor/peermonitor.go index df90de2..683d56f 100644 --- a/peermonitor/peermonitor.go +++ b/peermonitor/peermonitor.go @@ -3,6 +3,7 @@ package peermonitor import ( "context" "fmt" + "strings" "sync" "time" @@ -204,12 +205,18 @@ func (pm *PeerMonitor) HandleFailover(siteID int, relayEndpoint string) { return } + // Check for IPv6 and format the endpoint correctly + formattedEndpoint := relayEndpoint + if strings.Contains(relayEndpoint, ":") { + formattedEndpoint = fmt.Sprintf("[%s]", relayEndpoint) + } + // Configure WireGuard to use the relay wgConfig := fmt.Sprintf(`private_key=%s public_key=%s allowed_ip=%s/32 endpoint=%s:21820 -persistent_keepalive_interval=1`, pm.privateKey, config.PublicKey, config.ServerIP, relayEndpoint) +persistent_keepalive_interval=1`, pm.privateKey, config.PublicKey, config.ServerIP, formattedEndpoint) // Use the correctly formatted endpoint here err := pm.device.IpcSet(wgConfig) if err != nil { From b426f14190b63a6d0020e6f6db4f67a7f05245d8 Mon Sep 17 00:00:00 2001 From: FranceNuage Date: Thu, 4 Sep 2025 14:16:41 +0200 Subject: [PATCH 2/2] fix: remove comment Former-commit-id: e669d543c42d9779939386289bcdc5a10e11b61c --- peermonitor/peermonitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peermonitor/peermonitor.go b/peermonitor/peermonitor.go index 683d56f..696ee00 100644 --- a/peermonitor/peermonitor.go +++ b/peermonitor/peermonitor.go @@ -216,7 +216,7 @@ func (pm *PeerMonitor) HandleFailover(siteID int, relayEndpoint string) { public_key=%s allowed_ip=%s/32 endpoint=%s:21820 -persistent_keepalive_interval=1`, pm.privateKey, config.PublicKey, config.ServerIP, formattedEndpoint) // Use the correctly formatted endpoint here +persistent_keepalive_interval=1`, pm.privateKey, config.PublicKey, config.ServerIP, formattedEndpoint) err := pm.device.IpcSet(wgConfig) if err != nil {