diff options
| author | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-05-06 12:40:47 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-05-06 12:40:47 +0200 |
| commit | 347b20fc91505584bc9efbeca89590a411b95e79 (patch) | |
| tree | 9dfc600e957c4a881115f8bc8a9cc107a4f0cc9c /client | |
| parent | 9c4985368aee638d982f30ea7bc5c7ee71ae3ab3 (diff) | |
All: Run modernize --test --fix
Diffstat (limited to 'client')
| -rw-r--r-- | client/client.go | 2 | ||||
| -rw-r--r-- | client/client_test.go | 14 | ||||
| -rw-r--r-- | client/fsm.go | 2 | ||||
| -rw-r--r-- | client/id.go | 9 |
4 files changed, 12 insertions, 15 deletions
diff --git a/client/client.go b/client/client.go index d3e438f..6c905ca 100644 --- a/client/client.go +++ b/client/client.go @@ -113,7 +113,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, interface{}) bool, debug bool) (c *Client, err error) { +func New(name string, version string, directory string, stateCallback func(FSMStateID, FSMStateID, any) bool, debug bool) (c *Client, err error) { // We create the client by filling fields one by one c = &Client{} diff --git a/client/client_test.go b/client/client_test.go index 281ce55..9f302c4 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -60,7 +60,7 @@ func stateCallback( ck *cookie.Cookie, _ FSMStateID, newState FSMStateID, - data interface{}, + data any, ) { if newState == StateOAuthStarted { url, ok := data.(string) @@ -82,7 +82,7 @@ func TestServer(t *testing.T) { "org.letsconnect-vpn.app.linux", "0.1.0-test", dir, - func(oldState FSMStateID, newState FSMStateID, data interface{}) bool { + func(oldState FSMStateID, newState FSMStateID, data any) bool { // test if main server server list succeeds if newState == StateMain { _, listErr := state.ServerList() @@ -137,7 +137,7 @@ func TestTokenExpired(t *testing.T) { "org.letsconnect-vpn.app.linux", "0.1.0-test", dir, - func(oldState FSMStateID, newState FSMStateID, data interface{}) bool { + func(oldState FSMStateID, newState FSMStateID, data any) bool { go stateCallback(ck, oldState, newState, data) return true }, @@ -196,7 +196,7 @@ func TestInvalidProfileCorrected(t *testing.T) { "org.letsconnect-vpn.app.linux", "0.1.0-test", dir, - func(oldState FSMStateID, newState FSMStateID, data interface{}) bool { + func(oldState FSMStateID, newState FSMStateID, data any) bool { go stateCallback(ck, oldState, newState, data) return true }, @@ -253,7 +253,7 @@ func TestConfigStartup(t *testing.T) { "org.letsconnect-vpn.app.linux", "0.1.0-test", dir, - func(oldState FSMStateID, newState FSMStateID, data interface{}) bool { + func(oldState FSMStateID, newState FSMStateID, data any) bool { go stateCallback(ck, oldState, newState, data) return true }, @@ -314,7 +314,7 @@ func TestPreferTCP(t *testing.T) { "org.letsconnect-vpn.app.linux", "0.1.0-test", dir, - func(oldState FSMStateID, newState FSMStateID, data interface{}) bool { + func(oldState FSMStateID, newState FSMStateID, data any) bool { go stateCallback(ck, oldState, newState, data) return true }, @@ -379,7 +379,7 @@ func TestInvalidClientID(t *testing.T) { k, "0.1.0-test", dir, - func(_ FSMStateID, _ FSMStateID, _ interface{}) bool { + func(_ FSMStateID, _ FSMStateID, _ any) bool { return true }, false, diff --git a/client/fsm.go b/client/fsm.go index 728d572..d22f947 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -90,7 +90,7 @@ func GetStateName(s FSMStateID) string { } func newFSM( - callback func(FSMStateID, FSMStateID, interface{}) bool, + callback func(FSMStateID, FSMStateID, any) bool, ) fsm.FSM { states := FSMStates{ StateDeregistered: FSMState{ diff --git a/client/id.go b/client/id.go index b4e1670..165e2a0 100644 --- a/client/id.go +++ b/client/id.go @@ -1,5 +1,7 @@ package client +import "slices" + // isAllowedClientID checks if the 'clientID' is in the list of allowed client IDs func isAllowedClientID(clientID string) bool { allowList := []string{ @@ -22,12 +24,7 @@ func isAllowedClientID(clientID string) bool { "org.govvpn.app.macos", "org.govvpn.app.linux", } - for _, x := range allowList { - if x == clientID { - return true - } - } - return false + return slices.Contains(allowList, clientID) } func userAgentName(clientID string) string { |
