From 7dbc3bbe2ca65fb7ec200ab7aa713855b0bdc11d Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 20 Sep 2022 19:17:42 +0200 Subject: State Register: Fix crash if discoServers/discoOrgs is nil --- state.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/state.go b/state.go index 6510b48..933ede2 100644 --- a/state.go +++ b/state.go @@ -90,7 +90,7 @@ func (state *VPNState) Register( _, currentServerErr := state.Servers.GetCurrentServer() // Only actually return the error if we have no disco servers and no current server - if discoServersErr != nil && discoServers.Version == 0 && currentServerErr != nil { + if discoServersErr != nil && (discoServers == nil || discoServers.Version == 0) && currentServerErr != nil { state.Logger.Error( fmt.Sprintf( "No configured servers, discovery servers is empty and no servers with error: %s", @@ -102,7 +102,7 @@ func (state *VPNState) Register( discoOrgs, discoOrgsErr := state.GetDiscoOrganizations() // Only actually return the error if we have no disco organizations and no current server - if discoOrgsErr != nil && discoOrgs.Version == 0 && currentServerErr != nil { + if discoOrgsErr != nil && (discoOrgs == nil || discoOrgs.Version == 0) && currentServerErr != nil { state.Logger.Error( fmt.Sprintf( "No configured organizations, discovery organizations empty and no servers with error: %s", -- cgit v1.2.3