summaryrefslogtreecommitdiff
path: root/types/server
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-03-22 12:16:54 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2023-09-25 09:43:37 +0200
commiteb57e36d3c017bef80277e97db1009c38893ce2d (patch)
tree11ae9fa5e75492690e3db4bde349e2accc3fa1c9 /types/server
parentf5fe3d75801830ab9f1d380f5b3238b9006cf48b (diff)
Exports + Client: Refactor registering a client
- Make sure the global exports state is only set on successful creating - Only call discovery when adding a server to ensure we get the most up to date args. Creating a client should have no network calls. Fixes #12 - Split creating a client in New and Register in the GO api
Diffstat (limited to 'types/server')
-rw-r--r--types/server/server.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/types/server/server.go b/types/server/server.go
index ae73f45..82730ab 100644
--- a/types/server/server.go
+++ b/types/server/server.go
@@ -20,14 +20,14 @@ const (
// Expiry is the struct that gives the time at which certain expiry elements should be shown
type Expiry struct {
// StartTime is the start time of the VPN in Unix
- StartTime int64 `json:"start_time"`
+ StartTime int64 `json:"start_time"`
// EndTime is the end time of the VPN in Unix.
- EndTime int64 `json:"end_time"`
+ EndTime int64 `json:"end_time"`
// ButtonTime is the Unix time at which to start showing the renew button in the UI
- ButtonTime int64 `json:"button_time"`
+ ButtonTime int64 `json:"button_time"`
// CountdownTime is the Unix time at which to start showing more detailed countdown timer.
// E.g. first start with days (7 days left), and when the current time is after this time, show e.g. 9 minutes and 59 seconds
- CountdownTime int64 `json:"countdown_time"`
+ CountdownTime int64 `json:"countdown_time"`
// NotificationTimes is the slice/list of times at which to show a notification that the VPN is about to expire
NotificationTimes []int64 `json:"notification_times"`
}
@@ -38,28 +38,28 @@ type Profile struct {
// It is a map where country codes are mapped to names, this is to be consistent with the format of other display names
// E.g. {"en": "Default Profile"}
// If this is empty, the field is omitted from the JSON
- DisplayName map[string]string `json:"display_name,omitempty"`
+ DisplayName map[string]string `json:"display_name,omitempty"`
// Protocols is the list of protocols that this profile supports
- Protocols []protocol.Protocol `json:"supported_protocols"`
+ Protocols []protocol.Protocol `json:"supported_protocols"`
}
// Profiles is the map of profiles with the current defined
type Profiles struct {
// Map, the map of profiles from profile ID to the profile contents
// If this is empty, the field is omitted from the JSON
- Map map[string]Profile `json:"map,omitempty"`
+ Map map[string]Profile `json:"map,omitempty"`
// Current is the current profile ID that is defined
- Current string `json:"current"`
+ Current string `json:"current"`
}
// Tokens are the OAuth tokens for the server
type Tokens struct {
// Access is the access token
- Access string `json:"access_token"`
+ Access string `json:"access_token"`
// Refresh is the refresh token
Refresh string `json:"refresh_token"`
// Expires is the Unix timestamp when the token expires
- Expires int64 `json:"expires_in"`
+ Expires int64 `json:"expires_in"`
}
// Server is the basic type for a server. This is the base for secure internet and institute access. Custom servers are equal to this type
@@ -68,10 +68,10 @@ type Server struct {
DisplayName map[string]string `json:"display_name,omitempty"`
// Identifier is the Base URL for Institute Access and Custom Server. For Secure Internet this is the organization ID
// This identifier should be passed to the Go library for e.g. getting a config
- Identifier string `json:"identifier"`
+ Identifier string `json:"identifier"`
// Profiles is the profiles that this server has defined
// It could be that this is empty if the library has not discovered the profiles just yet
- Profiles Profiles `json:"profiles"`
+ Profiles Profiles `json:"profiles"`
}
// Institute defines an institute access server
@@ -91,17 +91,17 @@ type SecureInternet struct {
CountryCode string `json:"country_code"`
// Delisted is a boolean that indicates whether or not this server is delisted from discovery
// If it is, the UI should show a warning symbol or move the server to a new category, which is up to the client
- Delisted bool `json:"delisted"`
+ Delisted bool `json:"delisted"`
}
// List is the list of servers
type List struct {
// Institutes is the list/slice of institute access servers. If none are defined, this is omitted in the JSON
- Institutes []Institute `json:"institute_access_servers,omitempty"`
+ Institutes []Institute `json:"institute_access_servers,omitempty"`
// Secure Internet is the secure internet server if any. If none is there, it is omitted in the JSON
SecureInternet *SecureInternet `json:"secure_internet_server,omitempty"`
// Custom is the list/slice of custom servers. If none are defined, this is omitted in the JSON
- Custom []Server `json:"custom_servers,omitempty"`
+ Custom []Server `json:"custom_servers,omitempty"`
}
// Configuration is the configuration that you get back when you call the get config function
@@ -109,14 +109,14 @@ type Configuration struct {
// VPNConfig is the VPN Configuration, a WireGuard or OpenVPN Configuration
// In case of OpenVPN, we append "script-security 0" to disable scripts from being run by default.
// A client may override this, e.g. for, very trusted, pre-provisioned VPNs
- VPNConfig string `json:"config"`
+ VPNConfig string `json:"config"`
// Protocol defines which protocol the configuration is for, OpenVPN or WireGuard
- Protocol protocol.Protocol `json:"protocol"`
+ Protocol protocol.Protocol `json:"protocol"`
// DefaultGateway is a boolean that indicates whether or not this configuration should be configured as a default gateway
- DefaultGateway bool `json:"default_gateway"`
+ DefaultGateway bool `json:"default_gateway"`
// Tokens is the updated tokens that we get back from the VPN configuration
// They should be used by the client to save them in e.g. the keyring
- Tokens Tokens `json:"tokens"`
+ Tokens Tokens `json:"tokens"`
}
// Current is the struct that defines the current server
@@ -125,11 +125,11 @@ type Current struct {
// The following three are mutually exclusive
// Institute is the institute access server if any, if none is there this field is omitted in the JSON
- Institute *Institute `json:"institute_access_server,omitempty"`
+ Institute *Institute `json:"institute_access_server,omitempty"`
// Secure Internet is the secure internet server if any, if none is there this field is omitted in the JSON
SecureInternet *SecureInternet `json:"secure_internet_server,omitempty"`
// Custom is the custom server if any, if none is there this field is omitted in the JSON
- Custom *Server `json:"custom_server,omitempty"`
+ Custom *Server `json:"custom_server,omitempty"`
// Type is the type of server that is there to check which of the three types should be non-nil
- Type Type `json:"server_type"`
+ Type Type `json:"server_type"`
}