summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-09-02 15:14:02 +0200
committerJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-09-02 15:14:02 +0200
commit5e05784cab953b0e24609398106dd33da7738d21 (patch)
treead6f1a8eaa16a5dc38d7849941abe6537d48d00b /client
parent53b40a5353df751d10c8480749b2c1929895c3e6 (diff)
client: Log more in debug and increase rotation to 10MB
Diffstat (limited to 'client')
-rw-r--r--client/client.go13
-rw-r--r--client/fsm.go9
2 files changed, 20 insertions, 2 deletions
diff --git a/client/client.go b/client/client.go
index 5317907..d986fa6 100644
--- a/client/client.go
+++ b/client/client.go
@@ -174,6 +174,8 @@ func New(name string, version string, directory string, stateCallback func(FSMSt
c.disco = c.cfg.Discovery()
+ slog.Debug("Client registered", "name", name, "version", version, "directory", directory)
+
if !c.hasDiscovery() {
return c, nil
}
@@ -249,6 +251,7 @@ func (c *Client) TokensUpdated(id string, t srvtypes.Type, tok eduoauth.Token) {
}
if c.TokenSetter == nil {
+ slog.Debug("not updating client tokens")
return
}
// Update the client
@@ -335,7 +338,6 @@ func (c *Client) locationCallback(ck *cookie.Cookie, orgID string) error {
// TrySave tries to save the internal state file
// If an error occurs it logs it
func (c *Client) TrySave() {
- slog.Debug("saving state file")
if c.cfg == nil {
slog.Warn("no state file to save")
return
@@ -351,6 +353,7 @@ func (c *Client) AddServer(ck *cookie.Cookie, identifier string, _type srvtypes.
c.mu.Lock()
defer c.mu.Unlock()
+ slog.Debug("client wants to add a server", "id", identifier, "type", _type)
if !c.hasDiscovery() && _type != srvtypes.TypeCustom {
return i18nerr.NewInternalf("Adding a non-custom server when the client does not use discovery is not supported, identifier: %s, type: %v", identifier, _type)
}
@@ -426,6 +429,8 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.
defer c.mu.Unlock()
previousState := c.FSM.Current
+ slog.Debug("client wants to get a VPN config", "server_id", identifier, "server_type", _type, "prefer_tcp", pTCP, "startup", startup)
+
if !c.hasDiscovery() && _type != srvtypes.TypeCustom {
return nil, i18nerr.NewInternalf("Getting a non-custom server when the client does not use discovery is not supported, identifier: %s, type: %d", identifier, _type)
}
@@ -507,6 +512,7 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes.
// RemoveServer removes a server
func (c *Client) RemoveServer(identifier string, _type srvtypes.Type) (err error) {
+ slog.Debug("client wants to remove a server", "id", identifier, "type", _type)
identifier, err = c.convertIdentifier(identifier, _type)
if err != nil {
return err
@@ -533,6 +539,7 @@ func (c *Client) CurrentServer() (*srvtypes.Current, error) {
// SetProfileID set the profile ID `pID` for the current server
func (c *Client) SetProfileID(pID string) error {
+ slog.Debug("Client sets profile ID", "id", pID)
srv, err := c.Servers.CurrentServer()
if err != nil {
return i18nerr.WrapInternalf(err, "Failed to set the profile ID: '%s'", pID)
@@ -565,6 +572,7 @@ func (c *Client) retrieveTokens(sid string, t srvtypes.Type) (*eduoauth.Token, e
// Cleanup cleans up the VPN connection by sending a /disconnect
func (c *Client) Cleanup(ck *cookie.Cookie) error {
+ slog.Debug("client wants to cleanup VPN connection")
defer c.TrySave()
srv, err := c.Servers.CurrentServer()
if err != nil {
@@ -596,6 +604,7 @@ func (c *Client) SetSecureLocation(orgID string, countryCode string) error {
if err != nil {
return i18nerr.WrapInternalf(err, "Failed to get the secure internet server with id: '%s' for setting a location", orgID)
}
+ slog.Debug("setting secure internet location", "org_id", orgID, "code", countryCode)
srv.CountryCode = countryCode
defer c.TrySave()
@@ -614,6 +623,7 @@ func (c *Client) SetSecureLocation(orgID string, countryCode string) error {
// 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 (c *Client) RenewSession(ck *cookie.Cookie) error {
+ slog.Debug("client wants to renew the session")
// getting the current serving with nil tokens means re-authorize
srv, err := c.Servers.CurrentServer()
if err != nil {
@@ -636,6 +646,7 @@ func (c *Client) RenewSession(ck *cookie.Cookie) error {
// StartFailover starts the failover procedure
func (c *Client) StartFailover(ck *cookie.Cookie, gateway string, mtu int, readRxBytes func() (int64, error)) (bool, error) {
f := failover.New(readRxBytes)
+ slog.Debug("client wants to start the failover test", "gateway", gateway, "mtu", mtu)
// get current profile
d, err := f.Start(ck.Context(), gateway, mtu)
diff --git a/client/fsm.go b/client/fsm.go
index 673f3fb..e3a8cc0 100644
--- a/client/fsm.go
+++ b/client/fsm.go
@@ -170,7 +170,14 @@ func newFSM(
},
}
- return fsm.NewFSM(StateMain, states, callback, GetStateName)
+ cbLogged := func(oldState FSMStateID, newState FSMStateID, data any) bool {
+ if oldState != newState {
+ slog.Debug("FSM transition", "old", GetStateName(oldState), "new", GetStateName(newState))
+ }
+ return callback(oldState, newState, data)
+ }
+
+ return fsm.NewFSM(StateMain, states, cbLogged, GetStateName)
}
// SetState sets the state for the client FSM to `state`