server

package
v0.0.0-...-4b2ba41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server implements functions that have to deal with server interaction

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidProfile = errors.New("invalid profile")

ErrInvalidProfile is an error that is returned when an invalid profile has been chosen

Functions

func CountdownTime

func CountdownTime(st time.Time, et time.Time) int64

CountdownTime returns the time when the countdown timer should be shown

func NotificationTimes

func NotificationTimes(st time.Time, et time.Time) []int64

NotificationTimes returns the list when the app should show a notification when the VPN is (about to) expire(d)

func RenewButtonTime

func RenewButtonTime(st time.Time, et time.Time) int64

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

func ReplaceWAYF(template string, authURL string, orgID string) string

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

func (s *Server) Disconnect(ctx context.Context) error

Disconnect sends an API /disconnect to the server

func (*Server) FreshProfiles

func (s *Server) FreshProfiles(ctx context.Context) (*profiles.Info, error)

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) ProfileID

func (s *Server) ProfileID() (string, error)

ProfileID gets the profile ID for the server

func (*Server) Profiles

func (s *Server) Profiles() (*srvtypes.Profiles, error)

Profiles gets the cached profiles from the configuration/state file

func (*Server) SetCurrent

func (s *Server) SetCurrent() error

SetCurrent sets the current server in the state file to this one

func (*Server) SetExpireTime

func (s *Server) SetExpireTime(et time.Time) error

SetExpireTime sets the time `et` when the VPN expires

func (*Server) SetProfileID

func (s *Server) SetProfileID(id string) error

SetProfileID sets the profile id `id` for the server

func (*Server) SetProfileList

func (s *Server) SetProfileList(prfs srvtypes.Profiles) error

SetProfileList sets the profile list `prfs` 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

func NewServers(name string, cb Callbacks, cfg *v2.V2) Servers

NewServers creates a new servers struct

func (*Servers) AddCustom

func (s *Servers) AddCustom(ctx context.Context, id string, ot *int64) error

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) GetServer

func (s *Servers) GetServer(id string, t srvtypes.Type) (*v2.Server, error)

GetServer gets a server from the state file

func (*Servers) NewServer

func (s *Servers) NewServer(identifier string, t srvtypes.Type, api *api.API) Server

NewServer creates a new server

func (*Servers) PublicCurrent

func (s *Servers) PublicCurrent(disco *discovery.Discovery) (*srvtypes.Current, error)

PublicCurrent gets the current server into a type that we can return to the client

func (*Servers) Remove

func (s *Servers) Remove(identifier string, t srvtypes.Type) error

Remove removes a server with id `identifier` and type `t`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL