From 308c656f05d0609eeb02891dbe3c30f8b0438765 Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Tue, 2 Sep 2025 14:48:49 +0200 Subject: All: Get rid of debug arg in Register --- client/client.go | 16 ++-------------- client/client_test.go | 6 ------ cmd/eduvpn-cli/main.go | 1 - exports/exports.go | 8 -------- exports/exports_test_wrapper.go | 2 +- wrappers/python/eduvpn_common/loader.py | 1 - wrappers/python/eduvpn_common/main.py | 3 +-- 7 files changed, 4 insertions(+), 33 deletions(-) diff --git a/client/client.go b/client/client.go index 69664e2..5317907 100644 --- a/client/client.go +++ b/client/client.go @@ -61,9 +61,6 @@ type Client struct { // 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) @@ -143,7 +140,7 @@ func (c *Client) goTransition(id fsm.StateID) error { // - 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 New(name string, version string, directory string, stateCallback func(FSMStateID, FSMStateID, any) bool, debug bool) (c *Client, err error) { +func New(name string, version string, directory string, stateCallback func(FSMStateID, FSMStateID, any) bool) (c *Client, err error) { // We create the client by filling fields one by one c = &Client{} @@ -155,13 +152,7 @@ func New(name string, version string, directory string, stateCallback func(FSMSt return nil, i18nerr.NewInternalf("The client registered with an invalid version: '%v'", version) } - // Initialize the logger - lvl := slog.LevelInfo - if debug { - lvl = slog.LevelDebug - } - - logr, err := log.Init(lvl, directory) + logr, err := log.Init(slog.LevelDebug, directory) if err != nil { return nil, i18nerr.WrapInternalf(err, "The log file with directory: '%s' failed to initialize", directory) } @@ -176,9 +167,6 @@ func New(name string, version string, directory string, stateCallback func(FSMSt // Initialize the FSM c.FSM = newFSM(stateCallback) - // Debug only if given - c.Debug = debug - c.cfg = config.NewFromDirectory(directory) // set the servers diff --git a/client/client_test.go b/client/client_test.go index d623037..3ae5775 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -169,7 +169,6 @@ func TestServer(t *testing.T) { go stateCallback(ck, oldState, newState, data) return true }, - false, ) if err != nil { t.Fatalf("Creating client error: %v", err) @@ -217,7 +216,6 @@ func TestTokenExpired(t *testing.T) { go stateCallback(ck, oldState, newState, data) return true }, - false, ) if err != nil { t.Fatalf("Creating client error: %v", err) @@ -276,7 +274,6 @@ func TestInvalidProfileCorrected(t *testing.T) { go stateCallback(ck, oldState, newState, data) return true }, - false, ) if err != nil { t.Fatalf("Creating client error: %v", err) @@ -333,7 +330,6 @@ func TestConfigStartup(t *testing.T) { go stateCallback(ck, oldState, newState, data) return true }, - false, ) if err != nil { t.Fatalf("Creating client error: %v", err) @@ -394,7 +390,6 @@ func TestPreferTCP(t *testing.T) { go stateCallback(ck, oldState, newState, data) return true }, - false, ) if err != nil { t.Fatalf("Creating client error: %v", err) @@ -458,7 +453,6 @@ func TestInvalidClientID(t *testing.T) { func(_ FSMStateID, _ FSMStateID, _ any) bool { return true }, - false, ) if v { if err != nil { diff --git a/cmd/eduvpn-cli/main.go b/cmd/eduvpn-cli/main.go index 8c778a6..5a217c9 100644 --- a/cmd/eduvpn-cli/main.go +++ b/cmd/eduvpn-cli/main.go @@ -154,7 +154,6 @@ func printConfig(url string, cc string, srvType srvtypes.Type, prof string, debu stateCallback(oldState, newState, data, prof, dir) return true }, - debug, ) if err != nil { return err diff --git a/exports/exports.go b/exports/exports.go index 0eae802..774875f 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -127,12 +127,6 @@ func getVPNState() (*client.Client, error) { // // - This callback returns non-zero if the state transition is handled. This is used to check if the client handles the needed transitions // -// `debug`, if non-zero, enables debugging mode for the library, this means: -// -// - Log everything in debug mode, so you can get more detail of what is going on -// -// - Write the state graph to a file in the configDirectory. This can be used to create a FSM png file with mermaid https://mermaid.js.org/ -// // After registering, the FSM is initialized and the state transition `MAIN` should have been completed // If some error occurs during registering, it is returned as a `types/error/error.go Error` // @@ -154,7 +148,6 @@ func Register( version *C.char, configDirectory *C.char, cb C.StateCB, - debug C.int, ) *C.char { _, stateErr := getVPNState() if stateErr == nil { @@ -167,7 +160,6 @@ func Register( func(oldState client.FSMStateID, newState client.FSMStateID, data interface{}) bool { return stateCallback(cb, oldState, newState, data) }, - debug != 0, ) // Only update the state if we get no error if err == nil { diff --git a/exports/exports_test_wrapper.go b/exports/exports_test_wrapper.go index 96abb74..013a7a3 100644 --- a/exports/exports_test_wrapper.go +++ b/exports/exports_test_wrapper.go @@ -99,7 +99,7 @@ func testDoRegister(t *testing.T) string { dirS := C.CString(dir) defer FreeString(dirS) - return getError(t, Register(nameS, versionS, dirS, C.StateCB(C.test_state_callback), 0)) + return getError(t, Register(nameS, versionS, dirS, C.StateCB(C.test_state_callback))) } func mustRegister(t *testing.T) { diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index d458cc4..888b53f 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -85,7 +85,6 @@ def initialize_functions(lib: CDLL) -> None: c_char_p, c_char_p, VPNStateChange, - c_int, ], c_void_p, ) diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index 827ddfc..2bd221d 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -127,7 +127,7 @@ class EduVPN(object): global global_object global_object = None - def register(self, debug: bool = False) -> None: + def register(self) -> None: """Register the Go shared library. This makes sure the FSM is initialized and that we can call Go functions @@ -144,7 +144,6 @@ class EduVPN(object): self.version, self.config_directory, state_callback, - debug, ) if register_err: -- cgit v1.2.3