summaryrefslogtreecommitdiff
path: root/src/discovery.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 16:22:07 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-20 16:22:07 +0200
commitb73e1489b06fd4546da6ba32697331584db02e71 (patch)
tree3893b79958b551d2552efb6d20e729d916346ec6 /src/discovery.go
parent63dfe633c7e62f570d44af6e0ea17967155cb5db (diff)
Refactor: Eliminate most uses of pointers in structs
Diffstat (limited to 'src/discovery.go')
-rw-r--r--src/discovery.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/discovery.go b/src/discovery.go
index 4498779..c7682f0 100644
--- a/src/discovery.go
+++ b/src/discovery.go
@@ -33,8 +33,8 @@ func (e *DiscoVerifyError) Error() string {
}
type DiscoList struct {
- Organizations *string `json:"organizations"`
- Servers *string `json:"servers"`
+ Organizations string `json:"organizations"`
+ Servers string `json:"servers"`
}
// Helper function that gets a disco json
@@ -82,45 +82,37 @@ func (e *GetListError) Error() string {
// FIXME: Implement these properly based on version and time info
func (eduvpn *VPNState) DetermineOrganizationsUpdate() bool {
- return eduvpn.DiscoList == nil || eduvpn.DiscoList.Organizations == nil
+ return eduvpn.DiscoList.Organizations == ""
}
func (eduvpn *VPNState) DetermineServersUpdate() bool {
- return eduvpn.DiscoList == nil || eduvpn.DiscoList.Servers == nil
-}
-
-func (eduvpn *VPNState) EnsureDisco() {
- if eduvpn.DiscoList == nil {
- eduvpn.DiscoList = &DiscoList{}
- }
+ return eduvpn.DiscoList.Servers == ""
}
// Get the organization list
func (eduvpn *VPNState) GetOrganizationsList() (string, error) {
if !eduvpn.DetermineOrganizationsUpdate() {
- return *eduvpn.DiscoList.Organizations, nil
+ return eduvpn.DiscoList.Organizations, nil
}
file := "organization_list.json"
body, err := getDiscoFile(file)
if err != nil {
return "", &GetListError{File: file, Err: err}
}
- eduvpn.EnsureDisco()
- eduvpn.DiscoList.Organizations = &body
+ eduvpn.DiscoList.Organizations = body
return body, nil
}
// Get the server list
func (eduvpn *VPNState) GetServersList() (string, error) {
if !eduvpn.DetermineServersUpdate() {
- return *eduvpn.DiscoList.Servers, nil
+ return eduvpn.DiscoList.Servers, nil
}
file := "server_list.json"
body, err := getDiscoFile("server_list.json")
if err != nil {
return "", &GetListError{File: file, Err: err}
}
- eduvpn.EnsureDisco()
- eduvpn.DiscoList.Servers = &body
+ eduvpn.DiscoList.Servers = body
return body, nil
}