diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-02-11 13:58:50 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-05 12:26:10 +0200 |
| commit | 12a0a2700d64f99b8f14d03c8de1c1ea5e922eff (patch) | |
| tree | dfc59a5d11d407b2ec91bf9e7987835f16e62458 /src | |
| parent | 03649c96c57e1bc6db026871489c02d4937f0439 (diff) | |
Begin exposing functions using a map
Signed-off-by: jwijenbergh <jeroenwijenbergh@protonmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/server.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/server.go b/src/server.go index 314ceae..87b9672 100644 --- a/src/server.go +++ b/src/server.go @@ -10,7 +10,7 @@ import ( // Struct that defines the json format for // url: "https://disco.eduvpn.org/v2/organization_list.json" type organizations struct { - v string `json:"v"` + V uint64 `json:"v"` OrganizationList []struct { DisplayName struct { En string `json:"en"` @@ -26,7 +26,7 @@ type organizations struct { // Struct that defines the json format for // url: "https://disco.eduvpn.org/v2/server_list.json" type servers struct { - v string `json:"v"` + V uint64 `json:"v"` ServerList []struct { BaseUrl string `json:"base_url"` CountryCode string `json:"country_code"` @@ -101,14 +101,32 @@ func getDiscoJson(jsonFile string, structure interface{}) bool { return true } +// Global maps that are used for storing info +var organizationsMap = map[uint64]organizations{} +var serversMap = map[uint64]servers{} + // Get the organization list -func GetOrganizationList() bool { +// Returns the unix timestamp of the data +func GetOrganizationsList() uint64 { organizations := organizations{} - return getDiscoJson("organization_list.json", &organizations) + success := getDiscoJson("organization_list.json", &organizations) + + if success { + organizationsMap[organizations.V] = organizations + } + + return organizations.V } // Get the server list -func GetServerList() bool { +// Return the unix timestamp of the data +func GetServerList() uint64 { servers := servers{} - return getDiscoJson("server_list.json", &servers) + success := getDiscoJson("server_list.json", &servers) + + if success { + serversMap[servers.V] = servers + } + + return servers.V } |
