summaryrefslogtreecommitdiff
path: root/client/discovery.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/discovery.go')
-rw-r--r--client/discovery.go28
1 files changed, 26 insertions, 2 deletions
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