Documentation
¶
Overview ¶
Package v2 implements version 2 of the state file
Index ¶
- type Server
- type ServerKey
- type V2
- func (cfg *V2) AddServer(id string, t server.Type, srv Server) error
- func (cfg *V2) CurrentServer() (*Server, *ServerKey, error)
- func (cfg *V2) GetServer(id string, t server.Type) (*Server, error)
- func (cfg *V2) HasSecureInternet() bool
- func (cfg *V2) PublicCurrent(disco *discovery.Discovery) (*server.Current, error)
- func (cfg *V2) PublicList(disco *discovery.Discovery) *server.List
- func (cfg *V2) RemoveServer(id string, t server.Type) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// Profiles are the list of profiles
Profiles server.Profiles `json:"profiles"`
// LastAuthorizeTime is the time we last authorized
// This is used for determining when to show e.g. the renew button
LastAuthorizeTime time.Time `json:"last_authorize_time,omitempty"`
// ExpireTime is the time at which the VPN expires
ExpireTime time.Time `json:"expire_time,omitempty"`
// CountryCode is the country code for the server in case of secure internet
// Otherwise it is an empty string
CountryCode string `json:"country_code,omitempty"`
// LocationProfiles are current profiles for each secure internet location
LocationProfiles map[string]string `json:"location_profiles,omitempty"`
}
Server is the struct for each server
type ServerKey ¶
type ServerKey struct {
// T is the type of server, e.g. secure internet
T server.Type
// ID is the identifier for the server
ID string
}
ServerKey is the key type of the server map
func (ServerKey) MarshalText ¶
MarshalText convers the server key into one that can be used in a map
func (*ServerKey) UnmarshalText ¶
UnmarshalText converts the marshaled key into a ServerType struct
type V2 ¶
type V2 struct {
// List is the list of servers
List map[ServerKey]*Server `json:"server_list,omitempty"`
// LastChosen represents the key of the last chosen server
// A server is chosen if we got a config for it
LastChosen *ServerKey `json:"last_chosen_id,omitempty"`
// Discovery is the cached list of discovery JSON
Discovery discovery.Discovery `json:"discovery"`
}
V2 is the top-level struct for the state file
func (*V2) CurrentServer ¶
CurrentServer gets the last chosen server It returns the server, the server type and an error if it doesn't exist
func (*V2) GetServer ¶
GetServer gets a server with id `id` and type `t` If the server doesn't exist it returns nil and an error
func (*V2) HasSecureInternet ¶
HasSecureInternet returns true whether or not the state file has a secure internet server in it
func (*V2) PublicCurrent ¶
PublicCurrent gets the current server as a type that should be returned to the client It returns this server or nil and an error if it doesn't exist
func (*V2) PublicList ¶
PublicList gets all the servers in a format that is returned to the client