diff --git a/.golangci.yaml b/.golangci.yaml index e2e33296..a68f5359 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -29,21 +29,20 @@ linters: - testpackage - stylecheck - wrapcheck - - paralleltest - ifshort - gomnd - goerr113 - errorlint - forcetypeassert - errname - - unparam - - makezero - gosec - gocritic - forbidigo - dupl - goconst - varnamelen + - makezero + - paralleltest # We might want to enable this, but it might be a lot of work - cyclop diff --git a/api.go b/api.go index c8a307cf..d8d4b512 100644 --- a/api.go +++ b/api.go @@ -319,20 +319,12 @@ func (h *Headscale) getMapResponse( return nil, err } - dnsConfig, err := getMapResponseDNSConfig( + dnsConfig := getMapResponseDNSConfig( h.cfg.DNSConfig, h.cfg.BaseDomain, *m, peers, ) - if err != nil { - log.Error(). - Str("func", "getMapResponse"). - Err(err). - Msg("Failed generate the DNSConfig") - - return nil, err - } resp := tailcfg.MapResponse{ KeepAlive: false, @@ -378,7 +370,6 @@ func (h *Headscale) getMapResponse( func (h *Headscale) getMapKeepAliveResponse( mKey wgkey.Key, req tailcfg.MapRequest, - m *Machine, ) ([]byte, error) { resp := tailcfg.MapResponse{ KeepAlive: true, diff --git a/app.go b/app.go index 034f86f9..da4e8aa6 100644 --- a/app.go +++ b/app.go @@ -187,13 +187,9 @@ func NewHeadscale(cfg Config) (*Headscale, error) { } if h.cfg.DNSConfig != nil && h.cfg.DNSConfig.Proxied { // if MagicDNS - magicDNSDomains, err := generateMagicDNSRootDomains( + magicDNSDomains := generateMagicDNSRootDomains( h.cfg.IPPrefix, - h.cfg.BaseDomain, ) - if err != nil { - return nil, err - } // we might have routes already from Split DNS if h.cfg.DNSConfig.Routes == nil { h.cfg.DNSConfig.Routes = make(map[string][]dnstype.Resolver) diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index 6b2cf4a2..8398bd8c 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -266,7 +266,6 @@ var deleteNodeCmd = &cobra.Command{ func sharingWorker( cmd *cobra.Command, - args []string, ) (string, *v1.Machine, *v1.Namespace, error) { output, _ := cmd.Flags().GetString("output") namespaceStr, err := cmd.Flags().GetString("namespace") @@ -324,7 +323,7 @@ var shareMachineCmd = &cobra.Command{ Use: "share", Short: "Shares a node from the current namespace to the specified one", Run: func(cmd *cobra.Command, args []string) { - output, machine, namespace, err := sharingWorker(cmd, args) + output, machine, namespace, err := sharingWorker(cmd) if err != nil { ErrorOutput( err, @@ -363,7 +362,7 @@ var unshareMachineCmd = &cobra.Command{ Use: "unshare", Short: "Unshares a node from the specified namespace", Run: func(cmd *cobra.Command, args []string) { - output, machine, namespace, err := sharingWorker(cmd, args) + output, machine, namespace, err := sharingWorker(cmd) if err != nil { ErrorOutput( err, diff --git a/dns.go b/dns.go index e917e953..d50fae63 100644 --- a/dns.go +++ b/dns.go @@ -32,8 +32,7 @@ import ( // This allows us to then calculate the subnets included in the subsequent class block and generate the entries. func generateMagicDNSRootDomains( ipPrefix netaddr.IPPrefix, - baseDomain string, -) ([]dnsname.FQDN, error) { +) []dnsname.FQDN { // TODO(juanfont): we are not handing out IPv6 addresses yet // and in fact this is Tailscale.com's range (note the fd7a:115c:a1e0: range in the fc00::/7 network) ipv6base := dnsname.FQDN("0.e.1.a.c.5.1.1.a.7.d.f.ip6.arpa.") @@ -70,7 +69,7 @@ func generateMagicDNSRootDomains( fqdns = append(fqdns, fqdn) } - return fqdns, nil + return fqdns } func getMapResponseDNSConfig( @@ -78,7 +77,7 @@ func getMapResponseDNSConfig( baseDomain string, m Machine, peers Machines, -) (*tailcfg.DNSConfig, error) { +) *tailcfg.DNSConfig { var dnsConfig *tailcfg.DNSConfig if dnsConfigOrig != nil && dnsConfigOrig.Proxied { // if MagicDNS is enabled // Only inject the Search Domain of the current namespace - shared nodes should use their full FQDN @@ -101,5 +100,5 @@ func getMapResponseDNSConfig( dnsConfig = dnsConfigOrig } - return dnsConfig, nil + return dnsConfig } diff --git a/dns_test.go b/dns_test.go index 19cc803a..dfde8631 100644 --- a/dns_test.go +++ b/dns_test.go @@ -11,8 +11,7 @@ import ( func (s *Suite) TestMagicDNSRootDomains100(c *check.C) { prefix := netaddr.MustParseIPPrefix("100.64.0.0/10") - domains, err := generateMagicDNSRootDomains(prefix, "foobar.headscale.net") - c.Assert(err, check.IsNil) + domains := generateMagicDNSRootDomains(prefix) found := false for _, domain := range domains { @@ -47,8 +46,7 @@ func (s *Suite) TestMagicDNSRootDomains100(c *check.C) { func (s *Suite) TestMagicDNSRootDomains172(c *check.C) { prefix := netaddr.MustParseIPPrefix("172.16.0.0/16") - domains, err := generateMagicDNSRootDomains(prefix, "headscale.net") - c.Assert(err, check.IsNil) + domains := generateMagicDNSRootDomains(prefix) found := false for _, domain := range domains { @@ -178,8 +176,7 @@ func (s *Suite) TestDNSConfigMapResponseWithMagicDNS(c *check.C) { m1peers, err := h.getPeers(m1) c.Assert(err, check.IsNil) - dnsConfig, err := getMapResponseDNSConfig(&dnsConfigOrig, baseDomain, *m1, m1peers) - c.Assert(err, check.IsNil) + dnsConfig := getMapResponseDNSConfig(&dnsConfigOrig, baseDomain, *m1, m1peers) c.Assert(dnsConfig, check.NotNil) c.Assert(len(dnsConfig.Routes), check.Equals, 2) @@ -303,8 +300,7 @@ func (s *Suite) TestDNSConfigMapResponseWithoutMagicDNS(c *check.C) { m1peers, err := h.getPeers(m1) c.Assert(err, check.IsNil) - dnsConfig, err := getMapResponseDNSConfig(&dnsConfigOrig, baseDomain, *m1, m1peers) - c.Assert(err, check.IsNil) + dnsConfig := getMapResponseDNSConfig(&dnsConfigOrig, baseDomain, *m1, m1peers) c.Assert(dnsConfig, check.NotNil) c.Assert(len(dnsConfig.Routes), check.Equals, 0) c.Assert(len(dnsConfig.Domains), check.Equals, 1) diff --git a/poll.go b/poll.go index e3c5c663..47717998 100644 --- a/poll.go +++ b/poll.go @@ -492,7 +492,7 @@ func (h *Headscale) scheduledPollWorker( return case <-keepAliveTicker.C: - data, err := h.getMapKeepAliveResponse(mKey, req, m) + data, err := h.getMapKeepAliveResponse(mKey, req) if err != nil { log.Error(). Str("func", "keepAlive").