diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-07-15 10:16:11 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-07-17 14:00:03 +0000 |
| commit | 2fc994a73a1a50469c09544a17a2cbd9a6e8c67b (patch) | |
| tree | 3184175e36383655f9a4a63ec5c1be03c11d1626 /client/discovery.go | |
| parent | 6f2b23fcd476848368a027cc5ad15a300bc25fa8 (diff) | |
Client: Move DiscoveryStartup to correct file and check client_id
Diffstat (limited to 'client/discovery.go')
| -rw-r--r-- | client/discovery.go | 28 |
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 |
