Support relay switch

This commit is contained in:
Owen
2025-02-23 20:18:25 -05:00
parent b68502de9e
commit cd3ec0b259

View File

@@ -419,18 +419,29 @@ func (s *WireGuardService) addPeer(peer Peer) error {
} }
// add keep alive using *time.Duration of 1 second // add keep alive using *time.Duration of 1 second
keepalive := time.Second keepalive := time.Second
// endpoint, err := net.ResolveUDPAddr("udp", peer.Endpoint)
// if err != nil { var peerConfig wgtypes.PeerConfig
// return fmt.Errorf("failed to resolve endpoint address: %w", err) if peer.Endpoint != "" {
// } endpoint, err := net.ResolveUDPAddr("udp", peer.Endpoint)
if err != nil {
return fmt.Errorf("failed to resolve endpoint address: %w", err)
}
// make the endpoint localhost to test // make the endpoint localhost to test
peerConfig := wgtypes.PeerConfig{ peerConfig = wgtypes.PeerConfig{
PublicKey: pubKey, PublicKey: pubKey,
AllowedIPs: allowedIPs, AllowedIPs: allowedIPs,
PersistentKeepaliveInterval: &keepalive, PersistentKeepaliveInterval: &keepalive,
// Endpoint: endpoint, Endpoint: endpoint,
}
} else {
peerConfig = wgtypes.PeerConfig{
PublicKey: pubKey,
AllowedIPs: allowedIPs,
PersistentKeepaliveInterval: &keepalive,
}
logger.Info("Added peer with no endpoint!")
} }
config := wgtypes.Config{ config := wgtypes.Config{