From ddb1370c734629bae3b55f652f5aadf0a0581308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 21 Nov 2024 20:04:48 +0200 Subject: [PATCH] lint --- hscontrol/types/config.go | 10 +++++----- hscontrol/types/config_test.go | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hscontrol/types/config.go b/hscontrol/types/config.go index 21bade73..afa94e83 100644 --- a/hscontrol/types/config.go +++ b/hscontrol/types/config.go @@ -30,7 +30,7 @@ const ( var ( errOidcMutuallyExclusive = errors.New("oidc_client_secret and oidc_client_secret_path are mutually exclusive") - errServerURLSuffix = errors.New("server_url cannot be part of base_domain in a way that could make the DERP and headscale server unreachable.") + errServerURLSuffix = errors.New("server_url cannot be part of base_domain in a way that could make the DERP and headscale server unreachable") ) type IPAllocationStrategy string @@ -928,9 +928,9 @@ func LoadServerConfig() (*Config, error) { // This is because Tailscale takes over the domain in BaseDomain, // causing the headscale server and DERP to be unreachable. // For Tailscale upstream, the following is true: -// - DERP run on their own domains -// - Control plane runs on login.tailscale.com/controlplane.tailscale.com -// - MagicDNS (BaseDomain) for users is on a *.ts.net domain per tailnet (e.g. tail-scale.ts.net) +// - DERP run on their own domains. +// - Control plane runs on login.tailscale.com/controlplane.tailscale.com. +// - MagicDNS (BaseDomain) for users is on a *.ts.net domain per tailnet (e.g. tail-scale.ts.net). func isSafeServerURL(serverURL, baseDomain string) error { server, err := url.Parse(serverURL) if err != nil { @@ -946,7 +946,7 @@ func isSafeServerURL(serverURL, baseDomain string) error { s := len(serverDomainParts) b := len(baseDomainParts) - for i := 0; i < len(baseDomainParts); i++ { + for i := range 0..len(baseDomainParts) { if serverDomainParts[s-i-1] != baseDomainParts[b-i-1] { return nil } diff --git a/hscontrol/types/config_test.go b/hscontrol/types/config_test.go index 54de13d1..b36b376e 100644 --- a/hscontrol/types/config_test.go +++ b/hscontrol/types/config_test.go @@ -340,7 +340,7 @@ tls_letsencrypt_challenge_type: TLS-ALPN-01 // server_url: headscale.com, base: headscale.net // // NOT OK -// server_url: server.headscale.com, base: headscale.com +// server_url: server.headscale.com, base: headscale.com. func TestSafeServerURL(t *testing.T) { tests := []struct { serverURL, baseDomain, @@ -388,6 +388,7 @@ func TestSafeServerURL(t *testing.T) { err := isSafeServerURL(tt.serverURL, tt.baseDomain) if tt.wantErr != "" { assert.EqualError(t, err, tt.wantErr) + return } assert.NoError(t, err)