summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client.go10
-rw-r--r--client/discovery.go10
2 files changed, 14 insertions, 6 deletions
diff --git a/client/client.go b/client/client.go
index 793597a..eb00a16 100644
--- a/client/client.go
+++ b/client/client.go
@@ -192,6 +192,12 @@ func New(name string, version string, directory string, stateCallback func(FSMSt
disco, release := c.discoMan.Discovery(true)
defer release()
+
+ err = disco.Fill()
+ if err != nil {
+ slog.Warn("failed filling discovery cache", "error", err)
+ }
+
disco.MarkServersExpired()
if !c.cfg.HasSecureInternet() {
disco.MarkOrganizationsExpired()
@@ -475,7 +481,7 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.
if _type != srvtypes.TypeCustom {
disco, release := c.discoMan.Discovery(true)
// make sure the servers are fetched fresh
- _, _, dserverr := disco.Servers(ctx)
+ _, _, dserverr := disco.Servers(ctx, false)
if dserverr != nil {
slog.Warn("failed to fetch server discovery when getting config", "error", dserverr)
}
@@ -489,7 +495,7 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.
case srvtypes.TypeSecureInternet:
disco, release := c.discoMan.Discovery(true)
// make sure the organizations are fetched if they need an update
- _, _, dorgerr := disco.Organizations(ctx)
+ _, _, dorgerr := disco.Organizations(ctx, false)
if dorgerr != nil {
slog.Warn("failed to fetch organization discovery when getting config", "error", dorgerr)
}
diff --git a/client/discovery.go b/client/discovery.go
index b434025..802fe48 100644
--- a/client/discovery.go
+++ b/client/discovery.go
@@ -19,7 +19,8 @@ func (c *Client) hasDiscovery() bool {
// If the list cannot be retrieved an error is returned.
// If this is the case then a previous version of the list is returned if there is any.
// This takes into account the frequency of updates, see: https://github.com/eduvpn/documentation/blob/v3/SERVER_DISCOVERY.md#organization-list.
-func (c *Client) DiscoOrganizations(ck *cookie.Cookie, search string) (*discotypes.Organizations, error) {
+// cache is set to true if there should be no network call done
+func (c *Client) DiscoOrganizations(ck *cookie.Cookie, cache bool, search string) (*discotypes.Organizations, error) {
// Not supported with Let's Connect! & govVPN
if !c.hasDiscovery() {
return nil, i18nerr.NewInternal("Organization discovery with this client ID is not supported")
@@ -28,7 +29,7 @@ func (c *Client) DiscoOrganizations(ck *cookie.Cookie, search string) (*discotyp
disco, release := c.discoMan.Discovery(true)
defer release()
- orgs, fresh, err := disco.Organizations(ck.Context())
+ orgs, fresh, err := disco.Organizations(ck.Context(), cache)
if fresh {
defer c.TrySave()
}
@@ -68,7 +69,8 @@ func (c *Client) DiscoOrganizations(ck *cookie.Cookie, search string) (*discotyp
// If the list cannot be retrieved an error is returned.
// If this is the case then a previous version of the list is returned if there is any.
// This takes into account the frequency of updates, see: https://github.com/eduvpn/documentation/blob/v3/SERVER_DISCOVERY.md#server-list.
-func (c *Client) DiscoServers(ck *cookie.Cookie, search string) (*discotypes.Servers, error) {
+// the cache argument is true if no network call should be done
+func (c *Client) DiscoServers(ck *cookie.Cookie, cache bool, search string) (*discotypes.Servers, error) {
// Not supported with Let's Connect! & govVPN
if !c.hasDiscovery() {
return nil, i18nerr.NewInternal("Server discovery with this client ID is not supported")
@@ -76,7 +78,7 @@ func (c *Client) DiscoServers(ck *cookie.Cookie, search string) (*discotypes.Ser
disco, release := c.discoMan.Discovery(true)
defer release()
- servs, fresh, err := disco.Servers(ck.Context())
+ servs, fresh, err := disco.Servers(ck.Context(), cache)
if fresh {
defer c.TrySave()
}