summaryrefslogtreecommitdiff
path: root/internal/config/v1
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-06 16:26:59 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commit3152078aec8334357a61171838f664eb03299211 (patch)
tree57da9dd39a70e44f05f104adc442b0166053b85c /internal/config/v1
parent819d7f9914cbb34abb76b932c05b030a34986ec2 (diff)
Config: New state file
Caches less. Also convert the V1 state file
Diffstat (limited to 'internal/config/v1')
-rw-r--r--internal/config/v1/v1.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/config/v1/v1.go b/internal/config/v1/v1.go
new file mode 100644
index 0000000..1e374b1
--- /dev/null
+++ b/internal/config/v1/v1.go
@@ -0,0 +1,60 @@
+// Package v1 implements a minimum set of the v1 config to convert it to a v2 config
+// In version 1 of the config we used the internal state as the config
+// This was bad as now if we want to change some internal representation the config also changes
+// This package can be removed when most people have migrated from v1 to v2
+package v1
+
+import (
+ "time"
+
+ "github.com/eduvpn/eduvpn-common/internal/api/profiles"
+ "github.com/eduvpn/eduvpn-common/internal/discovery"
+ "github.com/eduvpn/eduvpn-common/types/server"
+)
+
+type Profiles struct {
+ profiles.Info
+ Current string `json:"current_profile"`
+}
+
+type Base struct {
+ BaseURL string `json:"base_url"`
+ Profiles Profiles `json:"profiles"`
+ StartTime time.Time `json:"start_time"`
+ StartTimeOAuth time.Time `json:"start_time_oauth"`
+ ExpireTime time.Time `json:"expire_time"`
+}
+
+type InstituteServer struct {
+ Base Base `json:"base"`
+ Profiles Profiles `json:"profiles"`
+}
+
+type InstituteServers struct {
+ Map map[string]InstituteServer `json:"map"`
+ CurrentURL string `json:"current_url"`
+}
+
+type (
+ CustomServer = InstituteServer
+ CustomServers = InstituteServers
+)
+
+type SecureInternetHome struct {
+ BaseMap map[string]*Base `json:"base_map"`
+ DisplayName map[string]string `json:"display_name"`
+ HomeOrganizationID string `json:"home_organization_id"`
+ CurrentLocation string `json:"current_location"`
+}
+
+type Servers struct {
+ Custom CustomServers `json:"custom_servers"`
+ Institute InstituteServers `json:"institute_servers"`
+ SecureInternetHome SecureInternetHome `json:"secure_internet_home"`
+ IsType server.Type `json:"is_secure_internet"`
+}
+
+type V1 struct {
+ Discovery discovery.Discovery `json:"discovery"`
+ Servers Servers `json:"servers"`
+}