Documentation ¶
Overview ¶
Package client implements the public interface for creating eduVPN/Let's Connect! clients
Index ¶
- Variables
- func GetStateName(s FSMStateID) string
- type Client
- func (c *Client) AddServer(ck *cookie.Cookie, identifier string, _type srvtypes.Type, ni bool) (err error)
- func (c *Client) AuthDone(id string, t srvtypes.Type)
- func (c *Client) Cleanup(ck *cookie.Cookie) error
- func (c *Client) CurrentServer() (*srvtypes.Current, error)
- func (c *Client) Deregister()
- func (c *Client) DiscoOrganizations(ck *cookie.Cookie) (orgs *discotypes.Organizations, err error)
- func (c *Client) DiscoServers(ck *cookie.Cookie) (dss *discotypes.Servers, err error)
- func (c *Client) ExpiryTimes() (*srvtypes.Expiry, error)
- func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.Type, pTCP bool, ...) (cfg *srvtypes.Configuration, err error)
- func (c *Client) GettingConfig() error
- func (c *Client) InState(state FSMStateID) bool
- func (c *Client) InvalidProfile(ctx context.Context, srv *server.Server) (string, error)
- func (c *Client) Register() error
- func (c *Client) RemoveServer(identifier string, _type srvtypes.Type) (err error)
- func (c *Client) RenewSession(ck *cookie.Cookie) error
- func (c *Client) ServerList() (*srvtypes.List, error)
- func (c *Client) SetProfileID(pID string) error
- func (c *Client) SetSecureLocation(orgID string, countryCode string) error
- func (c *Client) SetState(state FSMStateID) error
- func (c *Client) StartFailover(ck *cookie.Cookie, gateway string, mtu int, readRxBytes func() (int64, error)) (bool, error)
- func (c *Client) StartProxyguard(ck *cookie.Cookie, listen string, tcpsp int, peer string, ...) error
- func (c *Client) TokensUpdated(id string, t srvtypes.Type, tok eduoauth.Token)
- func (c *Client) TriggerAuth(ctx context.Context, url string, wait bool) (string, error)
- func (c *Client) TrySave()
- type FSMState
- type FSMStateID
- type FSMStates
- type FSMTransition
- type Proxy
- type ProxyLogger
- type TokenCacher
Constants ¶
This section is empty.
Variables ¶
var ErrNoProxyGuardCancel = errors.New("no ProxyGuard cancel function")
ErrNoProxyGuardCancel indicates that no ProxyGuard cancel function was ever defined. You probably forgot to call `Tunnel`
var ErrNoProxyGuardClient = errors.New("no ProxyGuard client created")
ErrNoProxyGuardClient is an error that is returned when no ProxyGuard client is created
Functions ¶
func GetStateName ¶
func GetStateName(s FSMStateID) string
GetStateName gets the State name for state `s`
Types ¶
type Client ¶
type Client struct { // The name of the client Name string // The servers Servers server.Servers // The fsm FSM fsm.FSM // Whether to enable debugging Debug bool // TokenSetter sets the tokens in the client TokenSetter func(sid string, stype srvtypes.Type, tok srvtypes.Tokens) // TokenGetter gets the tokens from the client TokenGetter func(sid string, stype srvtypes.Type) *srvtypes.Tokens // contains filtered or unexported fields }
Client is the main struct for the VPN client.
func New ¶
func New(name string, version string, directory string, stateCallback func(FSMStateID, FSMStateID, interface{}) bool, debug bool) (c *Client, err error)
New creates a new client with the following parameters:
- name: the name of the client
- directory: the directory where the config files are stored. Absolute or relative
- stateCallback: the callback function for the FSM that takes two states (old and new) and the data as an interface
- debug: whether or not we want to enable debugging
It returns an error if initialization failed, for example when discovery cannot be obtained and when there are no servers.
func (*Client) AddServer ¶
func (c *Client) AddServer(ck *cookie.Cookie, identifier string, _type srvtypes.Type, ni bool) (err error)
AddServer adds a server with identifier and type
func (*Client) AuthDone ¶
AuthDone is called when authorization is done This is defined to satisfy the server.Callbacks interface
func (*Client) CurrentServer ¶
CurrentServer gets the current server that is configured
func (*Client) Deregister ¶
func (c *Client) Deregister()
Deregister 'deregisters' the client, meaning saving the log file and the config and emptying out the client struct.
func (*Client) DiscoOrganizations ¶
func (c *Client) DiscoOrganizations(ck *cookie.Cookie) (orgs *discotypes.Organizations, err error)
DiscoOrganizations gets the organizations list from the discovery server If the list cannot be retrieved an error is returned. If this is the case then a previous version of the list is returned if there is any. This takes into account the frequency of updates, see: https://github.com/eduvpn/documentation/blob/v3/SERVER_DISCOVERY.md#organization-list.
func (*Client) DiscoServers ¶
DiscoServers gets the servers list from the discovery server If the list cannot be retrieved an error is returned. If this is the case then a previous version of the list is returned if there is any. This takes into account the frequency of updates, see: https://github.com/eduvpn/documentation/blob/v3/SERVER_DISCOVERY.md#server-list.
func (*Client) ExpiryTimes ¶
ExpiryTimes returns the different Unix timestamps regarding expiry - The time starting at which the renew button should be shown, after 30 minutes and less than 24 hours - The time starting at which the countdown button should be shown, less than 24 hours - The list of times where notifications should be shown These times are reset when the VPN gets disconnected
func (*Client) GetConfig ¶
func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.Type, pTCP bool, startup bool) (cfg *srvtypes.Configuration, err error)
GetConfig gets a VPN configuration
func (*Client) GettingConfig ¶
GettingConfig is defined here to satisfy the server.Callbacks interface It is called when internally we are getting a config We go to the GettingConfig state
func (*Client) InState ¶
func (c *Client) InState(state FSMStateID) bool
InState returns whether or not the client is in state `state`
func (*Client) InvalidProfile ¶
InvalidProfile is defined here to satisfy the server.Callbacks interface It is called when a profile is invalid Here we call the AskProfile transition
func (*Client) RemoveServer ¶
RemoveServer removes a server
func (*Client) RenewSession ¶
RenewSession is called when the user clicks on the renew session button It re-authorized the server by getting a server without passing tokens
func (*Client) ServerList ¶
ServerList gets the list of servers
func (*Client) SetProfileID ¶
SetProfileID set the profile ID `pID` for the current server
func (*Client) SetSecureLocation ¶
SetSecureLocation sets a secure internet location for organization ID `orgID` with country code `countryCode`
func (*Client) SetState ¶
func (c *Client) SetState(state FSMStateID) error
SetState sets the state for the client FSM to `state`
func (*Client) StartFailover ¶
func (c *Client) StartFailover(ck *cookie.Cookie, gateway string, mtu int, readRxBytes func() (int64, error)) (bool, error)
StartFailover starts the failover procedure
func (*Client) StartProxyguard ¶
func (c *Client) StartProxyguard(ck *cookie.Cookie, listen string, tcpsp int, peer string, gotFD func(fd int, pips string), ready func()) error
StartProxyguard starts proxyguard for proxied WireGuard connections
func (*Client) TokensUpdated ¶
TokensUpdated is called when tokens are updated It updates the cache map and the client tokens This is defined to satisfy the server.Callbacks interface
func (*Client) TriggerAuth ¶
TriggerAuth is called when authorization is triggered This function satisfies the server.Callbacks interface
type FSMStateID ¶
FSMStateID is an alias to the fsm state ID type
const ( // StateDeregistered is the state where we are deregistered StateDeregistered FSMStateID = iota // StateMain is the main state StateMain // StateAddingServer is the state where a server is being added StateAddingServer // StateOAuthStarted means the state where the OAuth procedure is triggered StateOAuthStarted // StateGettingConfig is the state a VPN config is being obtained StateGettingConfig // StateAskLocation is the state where a secure internet location is being asked StateAskLocation // StateAskProfile is the state where a profile is being asked for StateAskProfile // StateGotConfig is the state where a config is obtained StateGotConfig // StateConnecting is the state where the VPN is connecting StateConnecting // StateConnected is the state where the VPN is connected StateConnected // StateDisconnecting is the state where the VPN is disconnecting StateDisconnecting // StateDisconnected is the state where the VPN is disconnected StateDisconnected )
type FSMTransition ¶
type FSMTransition = fsm.Transition
FSMTransition is an alias to the fsm transition type
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a wrapper around ProxyGuard that has the client and a cancel for cancellation by common and a mutex to protect against race conditions
func (*Proxy) Cancel ¶
Cancel cancels a running ProxyGuard tunnel it returns an error if it cannot be canceled
func (*Proxy) NewClient ¶
func (p *Proxy) NewClient(c *proxyguard.Client)
NewClient creates a new ProxyGuard wrapper from client `c`
type ProxyLogger ¶
type ProxyLogger struct{}
ProxyLogger is defined here such that we can update the proxyguard logger
func (*ProxyLogger) Logf ¶
func (pl *ProxyLogger) Logf(msg string, params ...interface{})
Logf logs a message with parameters
type TokenCacher ¶
type TokenCacher struct { // InstituteAccess is the cached map for institute access servers InstituteAccess cacheMap // CustomServer is the cached map for custom server CustomServer cacheMap // SecureInternet is the cached map for the secure internet server SecureInternet *eduoauth.Token }
TokenCacher is a structure that caches tokens for each type of server