From 3934d75ac516a530ceb9f494f7ce0de12cb1b5de Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 28 Nov 2022 15:04:47 +0100 Subject: Lint: Use gocritic linter and fix errors returned by it --- internal/server/common.go | 11 ++++++----- internal/util/util.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'internal') diff --git a/internal/server/common.go b/internal/server/common.go index 3db535c..f0274ed 100644 --- a/internal/server/common.go +++ b/internal/server/common.go @@ -508,16 +508,17 @@ func Config(server Server, clientSupportsWireguard bool, preferTCP bool) (string var configType string var configErr error - // The config supports wireguard, do a specialized request with a public key - if supportsWireguard { + switch { + // The config supports wireguard and optionally openvpn + case supportsWireguard: // A wireguard connect call needs to generate a wireguard key and add it to the config // Also the server could send back an OpenVPN config if it supports OpenVPN config, configType, configErr = wireguardGetConfig(server, preferTCP, supportsOpenVPN) - // The config only supports OpenVPN - } else if supportsOpenVPN { + // The config only supports OpenVPN + case supportsOpenVPN: config, configType, configErr = openVPNGetConfig(server, preferTCP) // The config supports no available protocol because the profile only supports WireGuard but the client doesn't - } else { + default: return "", "", types.NewWrappedError(errorMessage, errors.New("no supported protocol found")) } diff --git a/internal/util/util.go b/internal/util/util.go index 3ce1992..ddd165d 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -40,7 +40,7 @@ func EnsureValidURL(s string) (string, error) { // Make sure the URL ends with a / if returnedURL[len(returnedURL)-1:] != "/" { - returnedURL = returnedURL + "/" + returnedURL += "/" } return returnedURL, nil } -- cgit v1.2.3