From 19882f158fec139622ffe5b52bc9e834a9d3246e Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 20 Mar 2023 14:14:17 +0100 Subject: Types: Split server into subpackage --- types/server/server.go | 74 ++++++++++++++++++++++++++++++++++++++++++++++ types/types.go | 80 -------------------------------------------------- 2 files changed, 74 insertions(+), 80 deletions(-) create mode 100644 types/server/server.go delete mode 100644 types/types.go (limited to 'types') diff --git a/types/server/server.go b/types/server/server.go new file mode 100644 index 0000000..db2dd8b --- /dev/null +++ b/types/server/server.go @@ -0,0 +1,74 @@ +package server + +import "github.com/eduvpn/eduvpn-common/types/protocol" + +type Type int8 + +const ( + TypeUnknown Type = iota + TypeInstituteAccess + TypeSecureInternet + TypeCustom +) + +type Expiry struct { + StartTime int64 `json:"start_time"` + EndTime int64 `json:"end_time"` + ButtonTime int64 `json:"button_time"` + CountdownTime int64 `json:"countdown_time"` + NotificationTimes []int64 `json:"notification_times"` +} + +type Profile struct { + Identifier string `json:"identifier"` + DisplayName map[string]string `json:"display_name,omitempty"` + Protocols []protocol.Protocol `json:"supported_protocols"` +} + +type Profiles struct { + Map map[string]Profile `json:"map,omitempty"` + Current string `json:"current"` +} + +type Tokens struct { + Access string `json:"access_token"` + Refresh string `json:"refresh_token"` + Expires int64 `json:"expires_in"` +} + +type Server struct { + DisplayName map[string]string `json:"display_name,omitempty"` + Identifier string `json:"identifier"` + Profiles Profiles `json:"profiles"` +} + +type Institute struct { + Server + Delisted bool `json:"delisted"` +} + +type SecureInternet struct { + Server + CountryCode string `json:"country_code"` + Delisted bool `json:"delisted"` +} + +type List struct { + Institutes []Institute `json:"institute_access_servers,omitempty"` + SecureInternet *SecureInternet `json:"secure_internet_server,omitempty"` + Custom []Server `json:"custom_servers,omitempty"` +} + +type Configuration struct { + VPNConfig string `json:"config"` + Protocol protocol.Protocol `json:"protocol"` + DefaultGateway bool `json:"default_gateway"` + Tokens Tokens `json:"tokens"` +} + +type Current struct { + Institute *Institute `json:"institute_access_server,omitempty"` + SecureInternet *SecureInternet `json:"secure_internet_server,omitempty"` + Custom *Server `json:"custom_server,omitempty"` + Type Type `json:"server_type"` +} diff --git a/types/types.go b/types/types.go deleted file mode 100644 index bb04fdd..0000000 --- a/types/types.go +++ /dev/null @@ -1,80 +0,0 @@ -// package types lists the various public types that are returned to clients -package types - -import ( - "github.com/eduvpn/eduvpn-common/types/protocol" -) - -type Expiry struct { - StartTime int64 `json:"start_time"` - EndTime int64 `json:"end_time"` - ButtonTime int64 `json:"button_time"` - CountdownTime int64 `json:"countdown_time"` - NotificationTimes []int64 `json:"notification_times"` -} - -type Profile struct { - Identifier string `json:"identifier"` - DisplayName map[string]string `json:"display_name,omitempty"` - Protocols []protocol.Protocol `json:"supported_protocols"` -} - -type Profiles struct { - Map map[string]Profile `json:"map,omitempty"` - Current string `json:"current"` -} - -type Tokens struct { - Access string `json:"access_token"` - Refresh string `json:"refresh_token"` - Expires int64 `json:"expires_in"` -} - -type GenericServer struct { - DisplayName map[string]string `json:"display_name,omitempty"` - Identifier string `json:"identifier"` - Profiles Profiles `json:"profiles"` -} - -type InstituteServer struct { - GenericServer - Delisted bool `json:"delisted"` -} - -type SecureInternetServer struct { - GenericServer - CountryCode string `json:"country_code"` - Delisted bool `json:"delisted"` -} - -type ServerList struct { - Institutes []InstituteServer `json:"institute_access_servers,omitempty"` - SecureInternet *SecureInternetServer `json:"secure_internet_server,omitempty"` - Custom []GenericServer `json:"custom_servers,omitempty"` -} - -type Configuration struct { - VPNConfig string `json:"config"` - Protocol protocol.Protocol `json:"protocol"` - DefaultGateway bool `json:"default_gateway"` - Tokens Tokens `json:"tokens"` -} - -type ServerType int8 - -const ( - SERVER_UNKNOWN ServerType = iota - - SERVER_INSTITUTE_ACCESS - - SERVER_SECURE_INTERNET - - SERVER_CUSTOM -) - -type CurrentServer struct { - Institute *InstituteServer `json:"institute_access_server,omitempty"` - SecureInternet *SecureInternetServer `json:"secure_internet_server,omitempty"` - Custom *GenericServer `json:"custom_server,omitempty"` - Type ServerType `json:"server_type"` -} -- cgit v1.2.3