diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-19 15:52:05 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-19 15:52:05 +0200 |
| commit | f1a265190d8fd862bfff680fd0937a7f99759955 (patch) | |
| tree | 63dadf02f4a173587ef24f215cfb001207c9ecec /internal | |
| parent | e78ab789220eb885985067457e1294488ac09ebc (diff) | |
Discovery + Server: Remove unused 'Raw' strings
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/discovery/discovery.go | 20 | ||||
| -rw-r--r-- | internal/server/api.go | 1 | ||||
| -rw-r--r-- | internal/server/common.go | 1 |
3 files changed, 9 insertions, 13 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 1156dd0..01773fa 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -16,8 +16,8 @@ type Discovery struct { Servers types.DiscoveryServers } -// Helper function that gets a disco json -func getDiscoFile(jsonFile string, previousVersion uint64, structure interface{}) (string, error) { +// Helper function that gets a disco json and fills the structure with it +func getDiscoFile(jsonFile string, previousVersion uint64, structure interface{}) error { errorMessage := fmt.Sprintf("failed getting file: %s from the Discovery server", jsonFile) // Get json data discoURL := "https://disco.eduvpn.org/v2/" @@ -25,7 +25,7 @@ func getDiscoFile(jsonFile string, previousVersion uint64, structure interface{} _, fileBody, fileErr := http.HTTPGet(fileURL) if fileErr != nil { - return "", &types.WrappedErrorMessage{Message: errorMessage, Err: fileErr} + return &types.WrappedErrorMessage{Message: errorMessage, Err: fileErr} } // Get signature @@ -34,7 +34,7 @@ func getDiscoFile(jsonFile string, previousVersion uint64, structure interface{} _, sigBody, sigFileErr := http.HTTPGet(sigURL) if sigFileErr != nil { - return "", &types.WrappedErrorMessage{Message: errorMessage, Err: sigFileErr} + return &types.WrappedErrorMessage{Message: errorMessage, Err: sigFileErr} } // Verify signature @@ -49,17 +49,17 @@ func getDiscoFile(jsonFile string, previousVersion uint64, structure interface{} ) if !verifySuccess || verifyErr != nil { - return "", &types.WrappedErrorMessage{Message: errorMessage, Err: verifyErr} + return &types.WrappedErrorMessage{Message: errorMessage, Err: verifyErr} } // Parse JSON to extract version and list jsonErr := json.Unmarshal(fileBody, structure) if jsonErr != nil { - return "", &types.WrappedErrorMessage{Message: errorMessage, Err: jsonErr} + return &types.WrappedErrorMessage{Message: errorMessage, Err: jsonErr} } - return string(fileBody), nil + return nil } // FIXME: Implement based on @@ -165,7 +165,7 @@ func (discovery *Discovery) GetOrganizationsList() (*types.DiscoveryOrganization return &discovery.Organizations, nil } file := "organization_list.json" - body, bodyErr := getDiscoFile(file, discovery.Organizations.Version, &discovery.Organizations) + bodyErr := getDiscoFile(file, discovery.Organizations.Version, &discovery.Organizations) if bodyErr != nil { // Return previous with an error return &discovery.Organizations, &types.WrappedErrorMessage{ @@ -173,7 +173,6 @@ func (discovery *Discovery) GetOrganizationsList() (*types.DiscoveryOrganization Err: bodyErr, } } - discovery.Organizations.RawString = body discovery.Organizations.Timestamp = util.GetCurrentTime() return &discovery.Organizations, nil } @@ -184,7 +183,7 @@ func (discovery *Discovery) GetServersList() (*types.DiscoveryServers, error) { return &discovery.Servers, nil } file := "server_list.json" - body, bodyErr := getDiscoFile(file, discovery.Servers.Version, &discovery.Servers) + bodyErr := getDiscoFile(file, discovery.Servers.Version, &discovery.Servers) if bodyErr != nil { // Return previous with an error return &discovery.Servers, &types.WrappedErrorMessage{ @@ -193,7 +192,6 @@ func (discovery *Discovery) GetServersList() (*types.DiscoveryServers, error) { } } // Update servers timestamp - discovery.Servers.RawString = body discovery.Servers.Timestamp = util.GetCurrentTime() return &discovery.Servers, nil } diff --git a/internal/server/api.go b/internal/server/api.go index 0808c41..05d2528 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -127,7 +127,6 @@ func APIInfo(server Server) error { previousProfile := base.Profiles.Current base.Profiles = structure base.Profiles.Current = previousProfile - base.ProfilesRaw = string(body) return nil } diff --git a/internal/server/common.go b/internal/server/common.go index 37f9bf2..bf72bc6 100644 --- a/internal/server/common.go +++ b/internal/server/common.go @@ -17,7 +17,6 @@ type ServerBase struct { SupportContact []string `json:"support_contact"` Endpoints ServerEndpoints `json:"endpoints"` Profiles ServerProfileInfo `json:"profiles"` - ProfilesRaw string `json:"profiles_raw"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"expire_time"` Type string `json:"server_type"` |
