diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-28 14:30:55 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-28 14:30:55 +0100 |
| commit | bb760ad9036b586fd4f07b96623e8421e1dccaf0 (patch) | |
| tree | c06fa76d5fe89dadb3e7ad6d4f2c1d5fe6f94912 | |
| parent | 0bfb35520d7e138e6219e550187e0b55bc8a29ac (diff) | |
Formatting: Run golines
| -rw-r--r-- | client/client_test.go | 13 | ||||
| -rw-r--r-- | client/fsm.go | 9 | ||||
| -rw-r--r-- | exports/exports.go | 18 | ||||
| -rw-r--r-- | internal/fsm/fsm.go | 9 | ||||
| -rw-r--r-- | internal/oauth/oauth.go | 18 | ||||
| -rw-r--r-- | internal/oauth/oauth_test.go | 5 | ||||
| -rw-r--r-- | internal/server/common.go | 16 | ||||
| -rw-r--r-- | internal/server/custom.go | 5 | ||||
| -rw-r--r-- | internal/server/instituteaccess.go | 5 |
9 files changed, 80 insertions, 18 deletions
diff --git a/client/client_test.go b/client/client_test.go index 1b9a488..23e97ca 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -187,9 +187,15 @@ func TestConnectOAuthParameters(t *testing.T) { // missing state {&failedCallbackParameterError, httpw.URLParameters{"iss": iss, "code": "42"}}, // invalid state - {&failedCallbackStateMatchError, httpw.URLParameters{"iss": iss, "code": "42", "state": "21"}}, + { + &failedCallbackStateMatchError, + httpw.URLParameters{"iss": iss, "code": "42", "state": "21"}, + }, // invalid iss - {&failedCallbackISSMatchError, httpw.URLParameters{"iss": "37", "code": "42", "state": "21"}}, + { + &failedCallbackISSMatchError, + httpw.URLParameters{"iss": "37", "code": "42", "state": "21"}, + }, } for _, test := range tests { @@ -377,7 +383,8 @@ func TestPreferTCP(t *testing.T) { t.Fatalf("Config error: %v", configErr) } - if configType == "openvpn" && !strings.HasSuffix(config, "remote eduvpnserver 1194 udp\nremote eduvpnserver 1194 tcp") { + if configType == "openvpn" && + !strings.HasSuffix(config, "remote eduvpnserver 1194 udp\nremote eduvpnserver 1194 tcp") { t.Fatalf("Suffix for disable prefer TCP is not in the right order for config: %s", config) } } diff --git a/client/fsm.go b/client/fsm.go index 79d0f62..0effb2a 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -109,7 +109,10 @@ func newFSM( {To: StateNoServer, Description: "Reload list"}, {To: StateLoadingServer, Description: "User clicks a server in the UI"}, {To: StateChosenServer, Description: "The server has been chosen"}, - {To: StateSearchServer, Description: "The user is trying to choose a new server in the UI"}, + { + To: StateSearchServer, + Description: "The user is trying to choose a new server in the UI", + }, {To: StateConnected, Description: "The user is already connected"}, {To: StateAskLocation, Description: "Change the location in the main screen"}, }, @@ -193,7 +196,9 @@ func newFSM( }, }, StateConnected: FSMState{ - Transitions: []FSMTransition{{To: StateDisconnecting, Description: "App wants to disconnect"}}, + Transitions: []FSMTransition{ + {To: StateDisconnecting, Description: "App wants to disconnect"}, + }, }, } returnedFSM := fsm.FSM{} diff --git a/exports/exports.go b/exports/exports.go index 124a3a5..1c5ead5 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -235,7 +235,11 @@ func RemoveCustomServer(name *C.char, url *C.char) *C.error { } //export GetConfigSecureInternet -func GetConfigSecureInternet(name *C.char, orgID *C.char, preferTCP C.int) (*C.char, *C.char, *C.error) { +func GetConfigSecureInternet( + name *C.char, + orgID *C.char, + preferTCP C.int, +) (*C.char, *C.char, *C.error) { nameStr := C.GoString(name) state, stateErr := GetVPNState(nameStr) if stateErr != nil { @@ -247,7 +251,11 @@ func GetConfigSecureInternet(name *C.char, orgID *C.char, preferTCP C.int) (*C.c } //export GetConfigInstituteAccess -func GetConfigInstituteAccess(name *C.char, url *C.char, preferTCP C.int) (*C.char, *C.char, *C.error) { +func GetConfigInstituteAccess( + name *C.char, + url *C.char, + preferTCP C.int, +) (*C.char, *C.char, *C.error) { nameStr := C.GoString(name) state, stateErr := GetVPNState(nameStr) if stateErr != nil { @@ -259,7 +267,11 @@ func GetConfigInstituteAccess(name *C.char, url *C.char, preferTCP C.int) (*C.ch } //export GetConfigCustomServer -func GetConfigCustomServer(name *C.char, url *C.char, preferTCP C.int) (*C.char, *C.char, *C.error) { +func GetConfigCustomServer( + name *C.char, + url *C.char, + preferTCP C.int, +) (*C.char, *C.char, *C.error) { nameStr := C.GoString(name) state, stateErr := GetVPNState(nameStr) if stateErr != nil { diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 0163fed..5bfa712 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -137,7 +137,14 @@ func (fsm *FSM) writeGraph() { func (fsm *FSM) GoTransitionRequired(newState StateID, data interface{}) error { oldState := fsm.Current if !fsm.GoTransitionWithData(newState, data) { - return types.NewWrappedError("failed required transition", fmt.Errorf("required transition not handled, from: %s -> to: %s", fsm.GetStateName(oldState), fsm.GetStateName(newState))) + return types.NewWrappedError( + "failed required transition", + fmt.Errorf( + "required transition not handled, from: %s -> to: %s", + fsm.GetStateName(oldState), + fsm.GetStateName(newState), + ), + ) } return nil } diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 6abdb7f..9233448 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -139,7 +139,10 @@ func (oauth *OAuth) AccessToken() (string, error) { // Check if refresh is even possible by doing a simple check if the refresh token is empty // This is not needed but reduces API calls to the server if tokens.refresh == "" { - return "", types.NewWrappedError(errorMessage, &TokensInvalidError{Cause: "no refresh token is present"}) + return "", types.NewWrappedError( + errorMessage, + &TokensInvalidError{Cause: "no refresh token is present"}, + ) } // Otherwise refresh and then later return the access token if we are successful @@ -366,7 +369,11 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { defer func() { // writing the html is best effort if oauth.session.CallbackError != nil { - _ = writeResponseHTML(w, "Authorization Failed", "The authorization has failed. See the log file for more information.") + _ = writeResponseHTML( + w, + "Authorization Failed", + "The authorization has failed. See the log file for more information.", + ) } else { _ = writeResponseHTML(w, "Authorized", "The client has been successfully authorized. You can close this browser window.") } @@ -472,7 +479,12 @@ func (oauth *OAuth) AuthURL(name string, postProcessAuth func(string) string) (s } // Fill the struct with the necessary fields filled for the next call to getting the HTTP client - oauthSession := ExchangeSession{ClientID: name, ISS: oauth.ISS, State: state, Verifier: verifier} + oauthSession := ExchangeSession{ + ClientID: name, + ISS: oauth.ISS, + State: state, + Verifier: verifier, + } oauth.session = oauthSession // set up the listener to get the redirect URI diff --git a/internal/oauth/oauth_test.go b/internal/oauth/oauth_test.go index 2427220..693984e 100644 --- a/internal/oauth/oauth_test.go +++ b/internal/oauth/oauth_test.go @@ -14,7 +14,10 @@ func Test_verifiergen(t *testing.T) { // Verifier must be at minimum 43 and at max 128 characters... // However... Our verifier is exactly 43! if len(verifier) != 43 { - t.Fatalf("Got verifier length: %d, want a verifier with at least 43 characters", len(verifier)) + t.Fatalf( + "Got verifier length: %d, want a verifier with at least 43 characters", + len(verifier), + ) } _, unescapeErr := url.QueryUnescape(verifier) diff --git a/internal/server/common.go b/internal/server/common.go index e8eedd0..3db535c 100644 --- a/internal/server/common.go +++ b/internal/server/common.go @@ -340,7 +340,10 @@ func (base *Base) ValidProfiles(clientSupportsWireguard bool) ProfileInfo { } validProfiles = append(validProfiles, profile) } - return ProfileInfo{Current: base.Profiles.Current, Info: ProfileListInfo{ProfileList: validProfiles}} + return ProfileInfo{ + Current: base.Profiles.Current, + Info: ProfileListInfo{ProfileList: validProfiles}, + } } func ValidProfiles(server Server, clientSupportsWireguard bool) (*ProfileInfo, error) { @@ -352,12 +355,19 @@ func ValidProfiles(server Server, clientSupportsWireguard bool) (*ProfileInfo, e } profiles := base.ValidProfiles(clientSupportsWireguard) if len(profiles.Info.ProfileList) == 0 { - return nil, types.NewWrappedError(errorMessage, errors.New("no profiles found with supported protocols")) + return nil, types.NewWrappedError( + errorMessage, + errors.New("no profiles found with supported protocols"), + ) } return &profiles, nil } -func wireguardGetConfig(server Server, preferTCP bool, supportsOpenVPN bool) (string, string, error) { +func wireguardGetConfig( + server Server, + preferTCP bool, + supportsOpenVPN bool, +) (string, string, error) { errorMessage := "failed getting server WireGuard configuration" base, baseErr := server.Base() diff --git a/internal/server/custom.go b/internal/server/custom.go index f8899b3..d376727 100644 --- a/internal/server/custom.go +++ b/internal/server/custom.go @@ -31,7 +31,10 @@ func (servers *Servers) GetCustomServer(url string) (*InstituteAccessServer, err if server, ok := servers.CustomServers.Map[url]; ok { return server, nil } - return nil, types.NewWrappedError("failed to get institute access server", fmt.Errorf("no custom server with URL: %s", url)) + return nil, types.NewWrappedError( + "failed to get institute access server", + fmt.Errorf("no custom server with URL: %s", url), + ) } func (servers *Servers) RemoveCustomServer(url string) { diff --git a/internal/server/instituteaccess.go b/internal/server/instituteaccess.go index f76323c..9b6f735 100644 --- a/internal/server/instituteaccess.go +++ b/internal/server/instituteaccess.go @@ -46,7 +46,10 @@ func (servers *Servers) GetInstituteAccess(url string) (*InstituteAccessServer, if server, ok := servers.InstituteServers.Map[url]; ok { return server, nil } - return nil, types.NewWrappedError("failed to get institute access server", fmt.Errorf("no institute access server with URL: %s", url)) + return nil, types.NewWrappedError( + "failed to get institute access server", + fmt.Errorf("no institute access server with URL: %s", url), + ) } func (servers *Servers) RemoveInstituteAccess(url string) { |
