From eb57e36d3c017bef80277e97db1009c38893ce2d Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Wed, 22 Mar 2023 12:16:54 +0100 Subject: Exports + Client: Refactor registering a client - Make sure the global exports state is only set on successful creating - Only call discovery when adding a server to ensure we get the most up to date args. Creating a client should have no network calls. Fixes #12 - Split creating a client in New and Register in the GO api --- types/discovery/discovery.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'types/discovery') diff --git a/types/discovery/discovery.go b/types/discovery/discovery.go index 5f54721..0d3495a 100644 --- a/types/discovery/discovery.go +++ b/types/discovery/discovery.go @@ -11,36 +11,36 @@ import ( // Defined in URL: "https://disco.eduvpn.org/v2/organization_list.json" type Organizations struct { // Version is the version field. The Go library internally already checks for rollbacks, you can use this for logging - Version uint64 `json:"v"` + Version uint64 `json:"v"` // List is the list/slice of organizations. Omitted if none are there - List []Organization `json:"organization_list,omitempty"` + List []Organization `json:"organization_list,omitempty"` // Timestamp is a timestamp that is internally used by the Go library to keep track of when the organizations was last updated // You can also use this for logging - Timestamp time.Time `json:"go_timestamp"` + Timestamp time.Time `json:"go_timestamp"` } // Organization is the type that defines the upstream discovery format for a single organization type Organization struct { // DisplayName is the map of strings from language tags to display names // Omitted if none is defined - DisplayName MapOrString `json:"display_name,omitempty"` + DisplayName MapOrString `json:"display_name,omitempty"` // OrgID is the organization ID for the server - OrgID string `json:"org_id"` + OrgID string `json:"org_id"` // SecureInternetHome is the secure internet home server that belongs to this organization // Omitted if none is defined - SecureInternetHome string `json:"secure_internet_home,omitempty"` + SecureInternetHome string `json:"secure_internet_home,omitempty"` // KeywordList is the list of keywords // Omitted if none is defined - KeywordList MapOrString `json:"keyword_list,omitempty"` + KeywordList MapOrString `json:"keyword_list,omitempty"` } // Servers is the type that defines the upstream discovery format for the list of servers // url: "https://disco.eduvpn.org/v2/server_list.json" type Servers struct { // Version is the version field in discovery. The Go library already checks for rollbacks, use this for logging - Version uint64 `json:"v"` + Version uint64 `json:"v"` // List is the actual list of servers, omitted from the JSON if empty - List []Server `json:"server_list,omitempty"` + List []Server `json:"server_list,omitempty"` // Timestamp is a timestamp that is internally used by the Go library to keep track of when the organizations was last updated // You can also use this for logging Timestamp time.Time `json:"go_timestamp"` @@ -49,21 +49,21 @@ type Servers struct { // Server is a signle discovery server type Server struct { // AuthenticationURLTemplate is the template to be used for authentication to skip WAYF - AuthenticationURLTemplate string `json:"authentication_url_template"` + AuthenticationURLTemplate string `json:"authentication_url_template"` // BaseURL is the base URL of the server which is used as an identifier for the server by the Go library - BaseURL string `json:"base_url"` + BaseURL string `json:"base_url"` // CountryCode is the country code for the server in case of secure internet, e.g. NL - CountryCode string `json:"country_code"` + CountryCode string `json:"country_code"` // DisplayName is the display name of the server, omitted if empty - DisplayName MapOrString `json:"display_name,omitempty"` + DisplayName MapOrString `json:"display_name,omitempty"` // DisplayName are the keywords of the server, omitted if empty - KeywordList MapOrString `json:"keyword_list,omitempty"` + KeywordList MapOrString `json:"keyword_list,omitempty"` // PublicKeyList are the public keys of the server. Currently not used in this lib but returned by the upstream discovery server - PublicKeyList []string `json:"public_key_list"` + PublicKeyList []string `json:"public_key_list"` // Type is the type of the server, "secure_internet" or "institute_access" - Type string `json:"server_type"` + Type string `json:"server_type"` // SupportContact is the list/slice of support contacts - SupportContact []string `json:"support_contact"` + SupportContact []string `json:"support_contact"` } // MapOrString is a custom type as the upstream discovery format is a map or a value. -- cgit v1.2.3