mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Merge pull request #26 from kevin-gillet/25-fix-olm-ipv6-parsing
fix: add ipv6 endpoint formatter
Former-commit-id: 7448a3127d
This commit is contained in:
@@ -3,6 +3,7 @@ package peermonitor
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -204,12 +205,18 @@ func (pm *PeerMonitor) HandleFailover(siteID int, relayEndpoint string) {
|
|||||||
return
|
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
|
// Configure WireGuard to use the relay
|
||||||
wgConfig := fmt.Sprintf(`private_key=%s
|
wgConfig := fmt.Sprintf(`private_key=%s
|
||||||
public_key=%s
|
public_key=%s
|
||||||
allowed_ip=%s/32
|
allowed_ip=%s/32
|
||||||
endpoint=%s:21820
|
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)
|
||||||
|
|
||||||
err := pm.device.IpcSet(wgConfig)
|
err := pm.device.IpcSet(wgConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user