diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/client.go | 18 | ||||
| -rw-r--r-- | client/discovery.go | 28 |
2 files changed, 26 insertions, 20 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 |
