diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-05-07 11:51:34 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-05-29 14:36:10 +0200 |
| commit | 3ecfc012e2db8b464596faf2c3bd4db1cab8697b (patch) | |
| tree | b234ee9aa6729e56232786fee83f92cc5bbb63e3 /exports/exports.go | |
| parent | b1033a6a39fe21fec99be5318ba3536af148a79b (diff) | |
Discovery: Implement search and do not return keywords
This patch implements search by adding a second argument to
DiscoOrganizations and DiscoServers. A search string of = "" returns
everything. This also makes the subset that is returned to the client
even fewer, no keywords.
Diffstat (limited to 'exports/exports.go')
| -rw-r--r-- | exports/exports.go | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/exports/exports.go b/exports/exports.go index 4c9e0dc..d914120 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -671,11 +671,12 @@ 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` +// `search` is the search string for filtering the list. It checks for keywords and display name case insensitive as a substring matching. If search is empty it returns ALL servers currently known in common, including secure internet servers that do not have a display name set // // If it was unsuccessful, it returns an error. Note that when the lib was built in release mode the data is almost always non-nil, even when an error has occurred // This means it has just returned the cached list // -// Example Input: ```DiscoServers(myCookie)``` +// Example Input: ```DiscoServers(myCookie, "")``` // // Example Output: // @@ -701,8 +702,27 @@ func SetSecureLocation(orgID *C.char, cc *C.char) *C.char { // ], .................. // } , null // +// Example Input: ```DiscoServers(myCookie, "heanet")``` +// +// Example Output: +// +// { +// "v": 1695291170, +// "server_list": [ +// { +// "base_url": "https://eduvpn.heanet.ie/", +// "display_name": "HEAnet Staff", +// "server_type": "institute_access", +// "support_contact": [ +// "mailto:noc@heanet.ie", +// "tel:+35316609040" +// ] +// }, +// ] +// } , null +// //export DiscoServers -func DiscoServers(c C.uintptr_t) (*C.char, *C.char) { +func DiscoServers(c C.uintptr_t, search *C.char) (*C.char, *C.char) { state, stateErr := getVPNState() if stateErr != nil { return nil, getCError(stateErr) @@ -711,7 +731,7 @@ func DiscoServers(c C.uintptr_t) (*C.char, *C.char) { if err != nil { return nil, getCError(err) } - servers, err := state.DiscoServers(ck) + servers, err := state.DiscoServers(ck, C.GoString(search)) if servers == nil && err != nil { return nil, getCError(err) } @@ -725,11 +745,12 @@ func DiscoServers(c C.uintptr_t) (*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` +// `search` is the search string for filtering the list. It checks for keywords and display name case insensitive as a substring matching. If search is empty it returns ALL organizations currently known in common // // If it was unsuccessful, it returns an error. Note that when the lib was built in release mode the data is almost always non-nil, even when an error has occurred // This means it has just returned the cached list // -// Example Input: ```DiscoOrganizations(myCookie)``` +// Example Input: ```DiscoOrganizations(myCookie, "")``` // // Example Output: // @@ -760,8 +781,25 @@ func DiscoServers(c C.uintptr_t) (*C.char, *C.char) { // "secure_inte ..................... // }, null // +// Example Input: ```DiscoOrganizations(myCookie, "rash")``` +// +// Example Output: +// +// { +// "v": 1695291170, +// "organization_list": [ +// { +// "display_name": { +// "en": "Academic Network of Albania - RASH" +// }, +// "org_id": "https://idp.rash.al/simplesaml/saml2/idp/metadata.php", +// "secure_internet_home": "https://eduvpn.rash.al/" +// }, +// }, null +// +// //export DiscoOrganizations -func DiscoOrganizations(c C.uintptr_t) (*C.char, *C.char) { +func DiscoOrganizations(c C.uintptr_t, search *C.char) (*C.char, *C.char) { state, stateErr := getVPNState() if stateErr != nil { return nil, getCError(stateErr) @@ -770,7 +808,7 @@ func DiscoOrganizations(c C.uintptr_t) (*C.char, *C.char) { if err != nil { return nil, getCError(err) } - orgs, err := state.DiscoOrganizations(ck) + orgs, err := state.DiscoOrganizations(ck, C.GoString(search)) if orgs == nil && err != nil { return nil, getCError(err) } |
