Documentation
¶
Overview ¶
Package server implements functions that have to deal with server interaction
Index ¶
- Variables
- func CountdownTime(st time.Time, et time.Time) int64
- func NotificationTimes(st time.Time, et time.Time) []int64
- func RenewButtonTime(st time.Time, et time.Time) int64
- func ReplaceWAYF(template string, authURL string, orgID string) string
- type Callbacks
- type CurrentServer
- type Server
- func (s *Server) Disconnect(ctx context.Context) error
- func (s *Server) FreshProfiles(ctx context.Context) (*profiles.Info, error)
- func (s *Server) ProfileID() (string, error)
- func (s *Server) Profiles() (*srvtypes.Profiles, error)
- func (s *Server) SetCurrent() error
- func (s *Server) SetExpireTime(et time.Time) error
- func (s *Server) SetProfileID(id string) error
- func (s *Server) SetProfileList(prfs srvtypes.Profiles) error
- type Servers
- func (s *Servers) AddCustom(ctx context.Context, id string, ot *int64) error
- func (s *Servers) AddInstitute(ctx context.Context, disco *discovery.Discovery, id string, ot *int64) error
- func (s *Servers) AddSecure(ctx context.Context, disco *discovery.Discovery, orgID string, ot *int64) error
- func (s *Servers) ConnectWithCallbacks(ctx context.Context, srv *Server, pTCP bool) (*srvtypes.Configuration, error)
- func (s *Servers) CurrentServer() (*CurrentServer, error)
- func (s *Servers) GetCustom(ctx context.Context, id string, tok *eduoauth.Token, disableAuth bool) (*Server, error)
- func (s *Servers) GetInstitute(ctx context.Context, id string, disco *discovery.Discovery, ...) (*Server, error)
- func (s *Servers) GetSecure(ctx context.Context, orgID string, disco *discovery.Discovery, ...) (*Server, error)
- func (s *Servers) GetServer(id string, t srvtypes.Type) (*v2.Server, error)
- func (s *Servers) NewServer(identifier string, t srvtypes.Type, api *api.API) Server
- func (s *Servers) PublicCurrent(disco *discovery.Discovery) (*srvtypes.Current, error)
- func (s *Servers) Remove(identifier string, t srvtypes.Type) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidProfile = errors.New("invalid profile")
ErrInvalidProfile is an error that is returned when an invalid profile has been chosen
Functions ¶
func CountdownTime ¶
CountdownTime returns the time when the countdown timer should be shown
func NotificationTimes ¶
NotificationTimes returns the list when the app should show a notification when the VPN is (about to) expire(d)
func RenewButtonTime ¶
RenewButtonTime returns the time when the renew button should be shown for the server Implemented according to: https://github.com/eduvpn/documentation/blob/cdf4d054f7652d74e4192494e8bb0e21040e46ac/API.md#session-expiry
func ReplaceWAYF ¶
ReplaceWAYF replaces an authorization template containing of @RETURN_TO@ and @ORG_ID@ with the authorization URL and the organization ID See https://github.com/eduvpn/documentation/blob/dc4d53c47dd7a69e95d6650eec408e16eaa814a2/SERVER_DISCOVERY_SKIP_WAYF.md
Types ¶
type Callbacks ¶
type Callbacks interface {
// api.Callbacks is the API callback interface
api.Callbacks
// GettingConfig is called when the config is obtained
GettingConfig() error
// InvalidProfile is called when an invalid profile is found
InvalidProfile(context.Context, *Server) (string, error)
}
Callbacks defines the interface for doing certain callback operations
type CurrentServer ¶
type CurrentServer struct {
// it embeds the state file server
*v2.Server
// Key is the server key
Key v2.ServerKey
// contains filtered or unexported fields
}
CurrentServer contains the information for the current active server
func (*CurrentServer) ServerWithCallbacks ¶
func (cs *CurrentServer) ServerWithCallbacks(ctx context.Context, disco *discovery.Discovery, tokens *eduoauth.Token, disableAuth bool) (*Server, error)
ServerWithCallbacks gets the current server as a server struct and triggers callbacks as needed
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the struct for a single server
func (*Server) Disconnect ¶
Disconnect sends an API /disconnect to the server
func (*Server) FreshProfiles ¶
FreshProfiles gets the profiles for the server It only does a /info network request if the profiles have not been cached force indicates whether or not the profiles should be fetched fresh
func (*Server) SetCurrent ¶
SetCurrent sets the current server in the state file to this one
func (*Server) SetExpireTime ¶
SetExpireTime sets the time `et` when the VPN expires
func (*Server) SetProfileID ¶
SetProfileID sets the profile id `id` for the server
type Servers ¶
type Servers struct {
// contains filtered or unexported fields
}
Servers is the main struct that contains information for configuring the servers
func NewServers ¶
NewServers creates a new servers struct
func (*Servers) AddCustom ¶
AddCustom adds a custom server to the internal server list `ctx` is the context used for cancellation `id` is the identifier of the server, the base URL `ot` specifies specifies the start time OAuth was already triggered
func (*Servers) AddInstitute ¶
func (s *Servers) AddInstitute(ctx context.Context, disco *discovery.Discovery, id string, ot *int64) error
AddInstitute adds an institute access server `ctx` is the context used for cancellation `disco` are the discovery servers `id` is the identifier for the server, the base url `ot` specifies specifies the start time OAuth was already triggered
func (*Servers) AddSecure ¶
func (s *Servers) AddSecure(ctx context.Context, disco *discovery.Discovery, orgID string, ot *int64) error
AddSecure adds a secure internet server `ctx` is the context used for cancellation `disco` are the discovery servers `orgID` is the organiztaion ID `ot` specifies specifies the start time OAuth was already triggered
func (*Servers) ConnectWithCallbacks ¶
func (s *Servers) ConnectWithCallbacks(ctx context.Context, srv *Server, pTCP bool) (*srvtypes.Configuration, error)
ConnectWithCallbacks handles the /connect flow It calls callbacks as needed
func (*Servers) CurrentServer ¶
func (s *Servers) CurrentServer() (*CurrentServer, error)
CurrentServer gets the current server from the state file and wraps it into a neat type
func (*Servers) GetCustom ¶
func (s *Servers) GetCustom(ctx context.Context, id string, tok *eduoauth.Token, disableAuth bool) (*Server, error)
GetCustom gets a custom server `ctx` is the context for cancellation `id` is the identifier of the server `tok` are the tokens such that we can initialize the API `disableAuth` is set to True when authorization should not be triggered
func (*Servers) GetInstitute ¶
func (s *Servers) GetInstitute(ctx context.Context, id string, disco *discovery.Discovery, tok *eduoauth.Token, disableAuth bool) (*Server, error)
GetInstitute gets an institute access server `ctx` is the context used for cancellation `id` is the identifier for the server, the base url `disco` are the discovery servers `tok` are the tokens such that we do not have to trigger auth `disableAuth` is true when auth should never be triggered
func (*Servers) GetSecure ¶
func (s *Servers) GetSecure(ctx context.Context, orgID string, disco *discovery.Discovery, tok *eduoauth.Token, disableAuth bool) (*Server, error)
GetSecure gets a secure internet server `ctx` is the context used for cancellation `orgID` is the organization ID that identifies the server `disco` are the discovery servers `tok` are the tokens such that the server can be found without triggering auth `disableAuth` is set to true when authorization should not be triggered
func (*Servers) PublicCurrent ¶
PublicCurrent gets the current server into a type that we can return to the client