summaryrefslogtreecommitdiff
path: root/client/server.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-03-22 12:16:54 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-09-25 09:43:37 +0200
commiteb57e36d3c017bef80277e97db1009c38893ce2d (patch)
tree11ae9fa5e75492690e3db4bde349e2accc3fa1c9 /client/server.go
parentf5fe3d75801830ab9f1d380f5b3238b9006cf48b (diff)
Exports + Client: Refactor registering a client
- Make sure the global exports state is only set on successful creating - Only call discovery when adding a server to ensure we get the most up to date args. Creating a client should have no network calls. Fixes #12 - Split creating a client in New and Register in the GO api
Diffstat (limited to 'client/server.go')
-rw-r--r--client/server.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/client/server.go b/client/server.go
index 6c0b4d2..7a14d00 100644
--- a/client/server.go
+++ b/client/server.go
@@ -9,8 +9,8 @@ import (
"github.com/eduvpn/eduvpn-common/internal/oauth"
"github.com/eduvpn/eduvpn-common/internal/server"
discotypes "github.com/eduvpn/eduvpn-common/types/discovery"
- srvtypes "github.com/eduvpn/eduvpn-common/types/server"
"github.com/eduvpn/eduvpn-common/types/protocol"
+ srvtypes "github.com/eduvpn/eduvpn-common/types/server"
"github.com/go-errors/errors"
)
@@ -264,6 +264,15 @@ func (c *Client) AddInstituteServer(url string) (err error) {
// Indicate that we're loading the server
c.FSM.GoTransition(StateLoadingServer)
+ // Check if we are able to fetch discovery, and log if something went wrong
+ if _, err := c.DiscoServers(); err != nil {
+ log.Logger.Warningf("Failed to get discovery servers: %v", err)
+ }
+
+ if _, err := c.DiscoOrganizations(); err != nil {
+ log.Logger.Warningf("Failed to get discovery organizations: %v", err)
+ }
+
// FIXME: Do nothing with discovery here as the client already has it
// So pass a server as the parameter
var dSrv *discotypes.Server
@@ -317,6 +326,15 @@ func (c *Client) AddSecureInternetHomeServer(orgID string) (err error) {
// Indicate that we're loading the server
c.FSM.GoTransition(StateLoadingServer)
+ // Check if we are able to fetch discovery, and log if something went wrong
+ if _, err := c.DiscoServers(); err != nil {
+ log.Logger.Warningf("Failed to get discovery servers: %v", err)
+ }
+
+ if _, err := c.DiscoOrganizations(); err != nil {
+ log.Logger.Warningf("Failed to get discovery organizations: %v", err)
+ }
+
// Get the secure internet URL from discovery
org, dSrv, err := c.Discovery.SecureHomeArgs(orgID)
if err != nil {