Prevent sigsegv with bad address

Fixes #210
Fixes #201
This commit is contained in:
Owen
2025-12-18 10:29:37 -05:00
parent 1cbf41e094
commit 3305f711b9

View File

@@ -477,6 +477,8 @@ func (s *WireGuardService) handleConfig(msg websocket.WSMessage) {
// Ensure the WireGuard interface and peers are configured // Ensure the WireGuard interface and peers are configured
if err := s.ensureWireguardInterface(config); err != nil { if err := s.ensureWireguardInterface(config); err != nil {
logger.Error("Failed to ensure WireGuard interface: %v", err) logger.Error("Failed to ensure WireGuard interface: %v", err)
logger.Error("Clients functionality will be disabled until the interface can be created")
return
} }
if err := s.ensureWireguardPeers(config.Peers); err != nil { if err := s.ensureWireguardPeers(config.Peers); err != nil {
@@ -652,6 +654,11 @@ func (s *WireGuardService) ensureWireguardPeers(peers []Peer) error {
// For netstack, we need to manage peers differently // For netstack, we need to manage peers differently
// We'll configure peers directly on the device using IPC // We'll configure peers directly on the device using IPC
// Check if device is initialized
if s.device == nil {
return fmt.Errorf("WireGuard device is not initialized")
}
// First, clear all existing peers by getting current config and removing them // First, clear all existing peers by getting current config and removing them
currentConfig, err := s.device.IpcGet() currentConfig, err := s.device.IpcGet()
if err != nil { if err != nil {