diff options
| author | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-08-29 14:05:20 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-08-29 14:40:24 +0200 |
| commit | 4a23134e1e5d70a9c8c5857790dbf27585ca3b1f (patch) | |
| tree | c7edff437df88d6d127f8bda0a35d59fc0d3dc68 /exports | |
| parent | 5461efc826952833fcdecca5d3daa3ee70423a31 (diff) | |
Discovery: Add cache argument and embed unmarshal on startup
Diffstat (limited to 'exports')
| -rw-r--r-- | exports/exports.go | 10 | ||||
| -rw-r--r-- | exports/exports_test_wrapper.go | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/exports/exports.go b/exports/exports.go index 9be3b66..931bed5 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -634,6 +634,7 @@ func SetSecureLocation(orgID *C.char, cc *C.char) *C.char { // DiscoServers gets the servers from discovery, returned as `types/discovery/discovery.go Servers` marshalled as JSON // // - `c` is the Cookie that needs to be passed. Create a new Cookie using `CookieNew` +// - `cache` indicates whether or not the cache should only be used, meaning no network call // - `search` is the search string for filtering the list. // // If any of the words in the search query is not contained in any of the display names or keywords, the candidate is filtered. @@ -677,7 +678,7 @@ func SetSecureLocation(orgID *C.char, cc *C.char) *C.char { // } , null // //export DiscoServers -func DiscoServers(c C.uintptr_t, search *C.char) (*C.char, *C.char) { +func DiscoServers(c C.uintptr_t, cache C.int, search *C.char) (*C.char, *C.char) { state, stateErr := getVPNState() if stateErr != nil { return nil, getCError(stateErr) @@ -686,7 +687,7 @@ func DiscoServers(c C.uintptr_t, search *C.char) (*C.char, *C.char) { if err != nil { return nil, getCError(err) } - servers, err := state.DiscoServers(ck, goString(search)) + servers, err := state.DiscoServers(ck, cache != 0, goString(search)) if servers == nil && err != nil { return nil, getCError(err) } @@ -700,6 +701,7 @@ func DiscoServers(c C.uintptr_t, search *C.char) (*C.char, *C.char) { // DiscoOrganizations gets the organizations from discovery, returned as `types/discovery/discovery.go Organizations` marshalled as JSON. // // - `c` is the Cookie that needs to be passed. Create a new Cookie using `CookieNew` +// - `cache` indicates whether or not the cache should only be used, meaning no network call // - `search` is the search string for filtering the list. // // If any of the words in the `search` query is not contained in any of the display names or keywords, the candidate is filtered. @@ -752,7 +754,7 @@ func DiscoServers(c C.uintptr_t, search *C.char) (*C.char, *C.char) { // }, null // //export DiscoOrganizations -func DiscoOrganizations(c C.uintptr_t, search *C.char) (*C.char, *C.char) { +func DiscoOrganizations(c C.uintptr_t, cache C.int, search *C.char) (*C.char, *C.char) { state, stateErr := getVPNState() if stateErr != nil { return nil, getCError(stateErr) @@ -761,7 +763,7 @@ func DiscoOrganizations(c C.uintptr_t, search *C.char) (*C.char, *C.char) { if err != nil { return nil, getCError(err) } - orgs, err := state.DiscoOrganizations(ck, goString(search)) + orgs, err := state.DiscoOrganizations(ck, cache != 0, goString(search)) if orgs == nil && err != nil { return nil, getCError(err) } diff --git a/exports/exports_test_wrapper.go b/exports/exports_test_wrapper.go index 0c9b9dc..96abb74 100644 --- a/exports/exports_test_wrapper.go +++ b/exports/exports_test_wrapper.go @@ -510,14 +510,14 @@ func testLetsConnectDiscovery(t *testing.T) { t.Fatalf("failed to add server got a different error: %v, want: %v", addErr, exptErr) } - _, servErr := DiscoServers(ck, nil) + _, servErr := DiscoServers(ck, 0, nil) servErrS := getError(t, servErr) exptErr = "An internal error occurred. The cause of the error is: Server discovery with this client ID is not supported." if servErrS != exptErr { t.Fatalf("discovery servers got a different error: %v, want: %v", servErrS, exptErr) } - _, orgErr := DiscoOrganizations(ck, nil) + _, orgErr := DiscoOrganizations(ck, 0, nil) orgErrS := getError(t, orgErr) exptErr = "An internal error occurred. The cause of the error is: Organization discovery with this client ID is not supported." if orgErrS != exptErr { |
