summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-20 19:17:42 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-20 19:17:42 +0200
commit7dbc3bbe2ca65fb7ec200ab7aa713855b0bdc11d (patch)
tree0239a0091e9b3fed9e4d4466d858d6724d157e4a
parent5abf8464d66209ccd2b81aac1cdafea62b7852e2 (diff)
State Register: Fix crash if discoServers/discoOrgs is nil
-rw-r--r--state.go4
1 files 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",