diff options
| -rw-r--r-- | internal/config/v1/v1.go | 13 | ||||
| -rw-r--r-- | internal/config/v2/convert.go | 10 |
2 files changed, 14 insertions, 9 deletions
diff --git a/internal/config/v1/v1.go b/internal/config/v1/v1.go index 1d96d13..04fdf6b 100644 --- a/internal/config/v1/v1.go +++ b/internal/config/v1/v1.go @@ -9,7 +9,6 @@ import ( "github.com/eduvpn/eduvpn-common/internal/api/profiles" "github.com/eduvpn/eduvpn-common/internal/discovery" - "github.com/eduvpn/eduvpn-common/types/server" ) // Profiles is the list of profiles @@ -36,8 +35,6 @@ type Base struct { type InstituteServer struct { // Base is the base of the server Base Base `json:"base"` - // Profiles are the list of profiles - Profiles Profiles `json:"profiles"` } // InstituteServers is a list of institute access servers @@ -67,6 +64,14 @@ type SecureInternetHome struct { CurrentLocation string `json:"current_location"` } +type Type int8 + +const ( + CustomServerType Type = iota + InstituteAccessServerType + SecureInternetServerType +) + // Servers represents the list of servers type Servers struct { // Custom are the "custom" servers; the servers that are added by the user @@ -77,7 +82,7 @@ type Servers struct { // Also obtained through discovery SecureInternetHome SecureInternetHome `json:"secure_internet_home"` // IsType represents which server type was last configured - IsType server.Type `json:"is_secure_internet"` + IsType Type `json:"is_secure_internet"` } // V1 is the top-level struct for the first version of the state file diff --git a/internal/config/v2/convert.go b/internal/config/v2/convert.go index 21f39a9..439716a 100644 --- a/internal/config/v2/convert.go +++ b/internal/config/v2/convert.go @@ -26,8 +26,8 @@ func convertV1Server(list v1.InstituteServers, iscurrent bool, t server.Type) (m if iscurrent && k == list.CurrentURL { lc = &key } - prfs := v.Profiles.Public() - prfs.Current = v.Profiles.Current + prfs := v.Base.Profiles.Public() + prfs.Current = v.Base.Profiles.Current ret[key] = &Server{ Profiles: prfs, LastAuthorizeTime: v1AuthTime(v.Base.StartTime, v.Base.StartTimeOAuth), @@ -42,11 +42,11 @@ func FromV1(ver1 *v1.V1) *V2 { gsrvs := ver1.Servers var lc *ServerKey - cust, glc := convertV1Server(gsrvs.Custom, gsrvs.IsType == server.TypeCustom, server.TypeCustom) + cust, glc := convertV1Server(gsrvs.Custom, gsrvs.IsType == v1.CustomServerType, server.TypeCustom) if lc == nil { lc = glc } - res, glc := convertV1Server(gsrvs.Institute, gsrvs.IsType == server.TypeInstituteAccess, server.TypeInstituteAccess) + res, glc := convertV1Server(gsrvs.Institute, gsrvs.IsType == v1.InstituteAccessServerType, server.TypeInstituteAccess) if lc == nil { lc = glc } @@ -69,7 +69,7 @@ func FromV1(ver1 *v1.V1) *V2 { T: server.TypeSecureInternet, ID: sec.HomeOrganizationID, } - if gsrvs.IsType == server.TypeSecureInternet { + if gsrvs.IsType == v1.SecureInternetServerType { lc = &t } prfs := v.Profiles.Public() |
