From 3ecfc012e2db8b464596faf2c3bd4db1cab8697b Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 7 May 2024 11:51:34 +0200 Subject: 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. --- docs/src/api/functiondocs.md | 52 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'docs/src/api') diff --git a/docs/src/api/functiondocs.md b/docs/src/api/functiondocs.md index 58134f7..5d7d9ac 100644 --- a/docs/src/api/functiondocs.md +++ b/docs/src/api/functiondocs.md @@ -289,19 +289,21 @@ Example Output: ## DiscoOrganizations Signature: ```go -func DiscoOrganizations(c C.uintptr_t) (*C.char, *C.char) +func DiscoOrganizations(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` +`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: @@ -332,22 +334,41 @@ Example Output: "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 + ## DiscoServers Signature: ```go -func DiscoServers(c C.uintptr_t) (*C.char, *C.char) +func DiscoServers(c C.uintptr_t, search *C.char) (*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` +`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: @@ -373,6 +394,25 @@ Example Output: ], .................. } , 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 + ## ExpiryTimes Signature: ```go -- cgit v1.2.3