summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-20 13:21:34 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-20 13:21:34 +0200
commit25d2143a627531fc0475d639c1e8f657ccafa630 (patch)
tree3b5b69b64f5f6879810842464056543e315c64a4 /internal
parentb0e4e454fc94935cf8ee3282a07596ec53268a18 (diff)
Golang-ci-lint: Fixes
Diffstat (limited to 'internal')
-rw-r--r--internal/discovery/discovery.go5
-rw-r--r--internal/fsm/fsm.go10
-rw-r--r--internal/oauth/oauth.go14
-rw-r--r--internal/server/api.go3
-rw-r--r--internal/server/common.go4
-rw-r--r--internal/util/util.go4
-rw-r--r--internal/util/util_test.go4
-rw-r--r--internal/verify/verify_test.go6
8 files changed, 22 insertions, 28 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go
index b3b438c..61b5557 100644
--- a/internal/discovery/discovery.go
+++ b/internal/discovery/discovery.go
@@ -156,10 +156,7 @@ func (discovery *Discovery) DetermineServersUpdate() bool {
// 1 hour from the last update
should_update_time := discovery.Servers.Timestamp.Add(1 * time.Hour)
now := util.GetCurrentTime()
- if !now.Before(should_update_time) {
- return true
- }
- return false
+ return !now.Before(should_update_time)
}
// Get the organization list
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go
index 292e09e..4fc647e 100644
--- a/internal/fsm/fsm.go
+++ b/internal/fsm/fsm.go
@@ -99,11 +99,13 @@ func (fsm *FSM) writeGraph() {
return
}
- f.WriteString(graph)
+ _, writeErr := f.WriteString(graph)
f.Close()
- cmd := exec.Command("mmdc", "-i", graphFile, "-o", graphImgFile, "--scale", "4")
-
- cmd.Start()
+ if writeErr != nil {
+ cmd := exec.Command("mmdc", "-i", graphFile, "-o", graphImgFile, "--scale", "4")
+ // Generating is best effort
+ _ = cmd.Start()
+ }
}
func (fsm *FSM) GoBack() {
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go
index e99b715..d8acfad 100644
--- a/internal/oauth/oauth.go
+++ b/internal/oauth/oauth.go
@@ -200,9 +200,9 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) {
code, success := req.URL.Query()["code"]
// Shutdown after we're done
defer func() {
- if oauth.Session.Server != nil {
- go oauth.Session.Server.Shutdown(oauth.Session.Context)
- }
+ if oauth.Session.Server != nil {
+ go oauth.Session.Server.Shutdown(oauth.Session.Context) //nolint:errcheck
+ }
}()
if !success {
oauth.Session.CallbackError = &types.WrappedErrorMessage{
@@ -310,9 +310,9 @@ func (oauth *OAuth) Cancel() {
Message: "cancelled OAuth",
Err: &OAuthCancelledCallbackError{},
}
- if oauth.Session.Server != nil {
- oauth.Session.Server.Shutdown(oauth.Session.Context)
- }
+ if oauth.Session.Server != nil {
+ oauth.Session.Server.Shutdown(oauth.Session.Context) //nolint:errcheck
+ }
}
func (oauth *OAuth) EnsureTokens() error {
@@ -351,7 +351,7 @@ func (oauth *OAuth) EnsureTokens() error {
type OAuthCancelledCallbackError struct{}
func (e *OAuthCancelledCallbackError) Error() string {
- return fmt.Sprintf("client cancelled OAuth")
+ return "client cancelled OAuth"
}
type OAuthCallbackParameterError struct {
diff --git a/internal/server/api.go b/internal/server/api.go
index b06b25c..76e3c72 100644
--- a/internal/server/api.go
+++ b/internal/server/api.go
@@ -199,7 +199,6 @@ func APIConnectOpenVPN(server Server, profile_id string) (string, time.Time, err
}
// This needs no further return value as it's best effort
-// FIXME: doAuth should not be needed here
func APIDisconnect(server Server) {
- apiAuthorized(server, http.MethodPost, "/disconnect", &httpw.HTTPOptionalParams{Timeout: 1})
+ _, _, _ = apiAuthorized(server, http.MethodPost, "/disconnect", &httpw.HTTPOptionalParams{Timeout: 1})
}
diff --git a/internal/server/common.go b/internal/server/common.go
index 9c941cf..f4f9a42 100644
--- a/internal/server/common.go
+++ b/internal/server/common.go
@@ -475,9 +475,7 @@ func (e *ServerGetCurrentProfileNotFoundError) Error() string {
type ServerGetConfigForceTCPError struct{}
func (e *ServerGetConfigForceTCPError) Error() string {
- return fmt.Sprintf(
- "failed to get config, force TCP is on but the server does not support OpenVPN",
- )
+ return "failed to get config, force TCP is on but the server does not support OpenVPN"
}
type ServerEnsureServerEmptyURLError struct{}
diff --git a/internal/util/util.go b/internal/util/util.go
index e652779..834b8d4 100644
--- a/internal/util/util.go
+++ b/internal/util/util.go
@@ -86,8 +86,8 @@ func ReplaceWAYF(authTemplate string, authURL string, orgID string) string {
// https://github.com/eduvpn/documentation/blob/dc4d53c47dd7a69e95d6650eec408e16eaa814a2/SERVER_DISCOVERY.md#language-matching
func GetLanguageMatched(languageMap map[string]string, languageTag string) string {
- // If no or empty map is given, return the empty string
- if languageMap == nil || len(languageMap) == 0 {
+ // If no map is given, return the empty string
+ if len(languageMap) == 0 {
return ""
}
// Try to find the exact match
diff --git a/internal/util/util_test.go b/internal/util/util_test.go
index 31d01e7..77af603 100644
--- a/internal/util/util_test.go
+++ b/internal/util/util_test.go
@@ -48,7 +48,7 @@ func Test_MakeRandomByteSlice(t *testing.T) {
t.Fatalf("2, Got: %v, want: nil", randomErr)
}
- if bytes.Compare(random2, random) == 0 {
+ if bytes.Equal(random2, random) {
t.Fatalf("Two random byteslices are the same: %v, %v", random2, random)
}
}
@@ -56,7 +56,7 @@ func Test_MakeRandomByteSlice(t *testing.T) {
func Test_GetCurrentTime(t *testing.T) {
time_now := GetCurrentTime()
- time.Sleep(1)
+ time.Sleep(1 * time.Second)
time_after_1_second := GetCurrentTime()
diff --git a/internal/verify/verify_test.go b/internal/verify/verify_test.go
index 47b1dc2..1720c97 100644
--- a/internal/verify/verify_test.go
+++ b/internal/verify/verify_test.go
@@ -10,8 +10,6 @@ import (
)
func Test_verifyWithKeys(t *testing.T) {
- var err error
-
var pk []string
{
file, err := os.Open("test_data/public.key")
@@ -328,9 +326,9 @@ func Test_verifyWithKeys(t *testing.T) {
// Cache file contents in map, mapping file names to contents
files := map[string][]byte{}
loadFile := func(name string) {
- content, loaded := files[name]
+ _, loaded := files[name]
if !loaded {
- content, err = ioutil.ReadFile("test_data/" + name)
+ content, err := ioutil.ReadFile("test_data/" + name)
if err != nil {
panic(err)
}