summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
commit0c9a300a58d9dacce7b84ff93222eed35eab5721 (patch)
tree423d1f05024f5c050e09f8d239f15b2e8681e640 /state.go
parenta1939a105dc4ddab27489b1bac3b22f674536e41 (diff)
Refactor: Do not log in internal packages
The reason behind this is that we then do not have to pass a lot to each function. Logging inside internal packages is less useful as we want to let them return errors and only log in the 'public' facing API or let the client decide
Diffstat (limited to 'state.go')
-rw-r--r--state.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/state.go b/state.go
index 93cf217..2f7e785 100644
--- a/state.go
+++ b/state.go
@@ -59,15 +59,12 @@ func (state *VPNState) Register(name string, directory string, stateCallback fun
}
// Initialize the FSM
- state.FSM.Init(name, stateCallback, &state.Logger, directory, debug)
+ state.FSM.Init(name, stateCallback, directory, debug)
state.Debug = debug
// Initialize the Config
state.Config.Init(name, directory)
- // Initialize Discovery
- state.Discovery.Init(&state.FSM, &state.Logger)
-
// Try to load the previous configuration
if state.Config.Load(&state) != nil {
// This error can be safely ignored, as when the config does not load, the struct will not be filled
@@ -153,7 +150,7 @@ func (state *VPNState) SetSecureLocation(countryCode string) error {
return &types.WrappedErrorMessage{Message: "failed asking secure location", Err: serverErr}
}
- state.Servers.SetSecureLocation(server, &state.FSM, &state.Logger)
+ state.Servers.SetSecureLocation(server, &state.FSM)
return nil
}
@@ -178,7 +175,7 @@ func (state *VPNState) addSecureInternetHomeServer(orgID string) (server.Server,
}
// Add the secure internet server
- server, serverErr := state.Servers.AddSecureInternet(secureOrg, secureServer, &state.FSM, &state.Logger)
+ server, serverErr := state.Servers.AddSecureInternet(secureOrg, secureServer, &state.FSM)
if serverErr != nil {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: serverErr}
@@ -221,7 +218,7 @@ func (state *VPNState) addInstituteServer(url string) (server.Server, error) {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: discoErr}
}
// Add the secure internet server
- server, serverErr := state.Servers.AddInstituteAccessServer(instituteServer, &state.FSM, &state.Logger)
+ server, serverErr := state.Servers.AddInstituteAccessServer(instituteServer, &state.FSM)
if serverErr != nil {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: serverErr}
@@ -238,7 +235,7 @@ func (state *VPNState) addCustomServer(url string) (server.Server, error) {
customServer := &types.DiscoveryServer{BaseURL: url, DisplayName: map[string]string{"en": url}, Type: "custom_server"}
// A custom server is just an institute access server under the hood
- server, serverErr := state.Servers.AddCustomServer(customServer, &state.FSM, &state.Logger)
+ server, serverErr := state.Servers.AddCustomServer(customServer, &state.FSM)
if serverErr != nil {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: serverErr}
@@ -368,6 +365,7 @@ func (state *VPNState) SetDisconnected() error {
}
state.FSM.GoTransitionWithData(fsm.HAS_CONFIG, state.getServerInfoData(), false)
+
return nil
}