summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/client.go18
-rw-r--r--client/discovery.go28
-rw-r--r--exports/exports.go5
3 files changed, 28 insertions, 23 deletions
diff --git a/client/client.go b/client/client.go
index 393a6ed..9a26485 100644
--- a/client/client.go
+++ b/client/client.go
@@ -57,24 +57,6 @@ type Client struct {
discoMan DiscoManager
}
-func (c *Client) DiscoveryStartup(cb func()) {
- fcb := func() {
- if cb == nil {
- return
- }
-
- c.mu.Lock()
- defer c.mu.Unlock()
-
- if c.FSM.Current != StateMain {
- return
- }
-
- cb()
- }
- c.discoMan.Startup(context.Background(), fcb)
-}
-
// GettingConfig is defined here to satisfy the server.Callbacks interface
// It is called when internally we are getting a config
// We go to the GettingConfig state
diff --git a/client/discovery.go b/client/discovery.go
index 4d56c6d..0529b87 100644
--- a/client/discovery.go
+++ b/client/discovery.go
@@ -25,7 +25,7 @@ func (c *Client) hasDiscovery() bool {
func (c *Client) DiscoOrganizations(ck *cookie.Cookie, search string) (*discotypes.Organizations, error) {
// Not supported with Let's Connect! & govVPN
if !c.hasDiscovery() {
- return nil, i18nerr.NewInternal("Server/organization discovery with this client ID is not supported")
+ return nil, i18nerr.NewInternal("Organization discovery with this client ID is not supported")
}
disco, release := c.discoMan.Discovery(true)
@@ -74,7 +74,7 @@ func (c *Client) DiscoOrganizations(ck *cookie.Cookie, search string) (*discotyp
func (c *Client) DiscoServers(ck *cookie.Cookie, search string) (*discotypes.Servers, error) {
// Not supported with Let's Connect! & govVPN
if !c.hasDiscovery() {
- return nil, i18nerr.NewInternal("Server/organization discovery with this client ID is not supported")
+ return nil, i18nerr.NewInternal("Server discovery with this client ID is not supported")
}
disco, release := c.discoMan.Discovery(true)
@@ -115,6 +115,30 @@ func (c *Client) DiscoServers(ck *cookie.Cookie, search string) (*discotypes.Ser
}, err
}
+func (c *Client) DiscoveryStartup(cb func()) error {
+ // Not supported with Let's Connect! & govVPN
+ if !c.hasDiscovery() {
+ return i18nerr.NewInternal("Server/organization discovery startup with this client ID is not supported")
+ }
+
+ fcb := func() {
+ if cb == nil {
+ return
+ }
+
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if c.FSM.Current != StateMain {
+ return
+ }
+
+ cb()
+ }
+ c.discoMan.Startup(context.Background(), fcb)
+ return nil
+}
+
type DiscoManager struct {
disco *discovery.Discovery
diff --git a/exports/exports.go b/exports/exports.go
index 36372b4..f1b55cd 100644
--- a/exports/exports.go
+++ b/exports/exports.go
@@ -1029,7 +1029,6 @@ func getCookie(c C.uintptr_t) (*cookie.Cookie, error) {
return v, nil
}
-
// DiscoveryStartup does a discovery request in the background
//
// The `refresh` argument is a callback that is called when the refreshing is done
@@ -1042,13 +1041,13 @@ func DiscoveryStartup(refresh C.RefreshList) *C.char {
if stateErr != nil {
return getCError(stateErr)
}
- state.DiscoveryStartup(func() {
+ startupErr := state.DiscoveryStartup(func() {
if refresh == nil {
return
}
C.call_refresh_list(refresh)
})
- return nil
+ return getCError(startupErr)
}
// SetTokenHandler sets the token getters and token setters for OAuth