Skip to content

Commit 7c87c7f

Browse files
committed
all: fix full-tree golangci-lint findings
The new full-tree golangci-lint check reports issues the --new-from-rev diff lint hid: nine wsl_v5 whitespace gaps, a prealloc, and an unparam (setCSRFCookie never errored, so drop the return and update callers). gocyclo on the central UpdateNodeFromMapRequest and an SA1019 NetMap deprecation in an integration helper are suppressed with reasons.
1 parent 822af58 commit 7c87c7f

13 files changed

Lines changed: 17 additions & 17 deletions

File tree

cmd/headscale/cli/nodes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ var listNodeRoutesCmd = &cobra.Command{
146146
}
147147

148148
nodes := resp.JSON200.Nodes
149+
149150
if identifier != 0 {
150151
idStr := strconv.FormatUint(identifier, util.Base10)
151152
for _, node := range nodes {

hscontrol/derp/derp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func loadDERPMapFromPath(path string) (*tailcfg.DERPMap, error) {
2828
}
2929

3030
var derpMap tailcfg.DERPMap
31+
3132
err = yaml.Unmarshal(b, &derpMap)
3233

3334
return &derpMap, err

hscontrol/derp/server/derp_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (d *DERPServer) GenerateRegion() (tailcfg.DERPRegion, error) {
8080
host, portStr, err := net.SplitHostPort(serverURL.Host)
8181

8282
var port int
83+
8384
if err != nil {
8485
host = serverURL.Host
8586
if serverURL.Scheme == "https" {

hscontrol/mapper/node_conn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ func (mc *multiChannelNodeConn) send(data *tailcfg.MapResponse) error {
309309
snapshot = append(snapshot, conn)
310310
}
311311
}
312+
312313
mc.mutex.RUnlock()
313314

314315
if len(snapshot) == 0 {

hscontrol/oidc.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,10 @@ func (a *AuthProviderOIDC) authHandler(
156156
}
157157

158158
// Set the state and nonce cookies to protect against CSRF attacks
159-
state, err := setCSRFCookie(writer, req, "state")
160-
if err != nil {
161-
httpUserError(writer, err)
162-
return
163-
}
159+
state := setCSRFCookie(writer, req, "state")
164160

165161
// Set the state and nonce cookies to protect against CSRF attacks
166-
nonce, err := setCSRFCookie(writer, req, "nonce")
167-
if err != nil {
168-
httpUserError(writer, err)
169-
return
170-
}
162+
nonce := setCSRFCookie(writer, req, "nonce")
171163

172164
registrationInfo := AuthInfo{
173165
AuthID: authID,
@@ -928,7 +920,7 @@ func getCookieName(baseName, value string) string {
928920
return fmt.Sprintf("%s_%s", baseName, value[:n])
929921
}
930922

931-
func setCSRFCookie(w http.ResponseWriter, r *http.Request, name string) (string, error) {
923+
func setCSRFCookie(w http.ResponseWriter, r *http.Request, name string) string {
932924
val := rands.HexString(64)
933925

934926
//nolint:gosec // G124: Secure set conditionally via r.TLS; HttpOnly + SameSite set below
@@ -948,5 +940,5 @@ func setCSRFCookie(w http.ResponseWriter, r *http.Request, name string) (string,
948940
}
949941
http.SetCookie(w, c)
950942

951-
return val, nil
943+
return val
952944
}

hscontrol/oidc_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ func TestSetCSRFCookieSameSite(t *testing.T) {
186186
w := httptest.NewRecorder()
187187
r := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/auth/abcdef0123456789", nil)
188188

189-
_, err := setCSRFCookie(w, r, "state")
190-
require.NoError(t, err)
189+
setCSRFCookie(w, r, "state")
191190

192191
cookies := w.Result().Cookies()
193192
require.Len(t, cookies, 1)

hscontrol/servertest/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ func (c *TestClient) startPollLoop() {
204204

205205
go func() {
206206
defer close(c.pollDone)
207+
207208
_ = c.direct.PollNetMap(c.pollCtx, c)
208209
}()
209210
}

hscontrol/state/state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,7 @@ func (s *State) HandleNodeFromPreAuthKey(
24322432
node.User = nil
24332433
node.Expiry = nil
24342434
}
2435+
24352436
node.AuthKey = pak
24362437
node.AuthKeyID = &pak.ID
24372438
// Do NOT reset IsOnline here. Online status is managed exclusively by
@@ -2793,7 +2794,7 @@ func isAutoDerivedGivenName(given, hostname string) bool {
27932794
// - node.PeerChangeFromMapRequest
27942795
// - node.ApplyPeerChange
27952796
// - logTracePeerChange in poll.go.
2796-
func (s *State) UpdateNodeFromMapRequest(id types.NodeID, req tailcfg.MapRequest) (change.Change, error) {
2797+
func (s *State) UpdateNodeFromMapRequest(id types.NodeID, req tailcfg.MapRequest) (change.Change, error) { //nolint:gocyclo // central map-request reconciliation; the sequential branch flow reads clearer as one function than split across helpers
27972798
log.Trace().
27982799
Caller().
27992800
Uint64(zf.NodeID, id.Uint64()).

hscontrol/types/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func (rn *AuthRequest) FinishAuth(verdict AuthVerdict) {
237237
}
238238

239239
rn.finished <- verdict
240+
240241
close(rn.finished)
241242
}
242243

hscontrol/util/dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func GenerateIPv6DNSRootDomain(ipPrefix netip.Prefix) []dnsname.FQDN {
164164
// but the inputs are not so long as to cause problems,
165165
// and from what I can see, the generateMagicDNSRootDomains
166166
// function is called only once over the lifetime of a server process.
167-
prefixConstantParts := []string{}
167+
prefixConstantParts := make([]string, 0, maskBits/nibbleLen)
168168
for i := range maskBits / nibbleLen {
169169
prefixConstantParts = append(prefixConstantParts, string(nibbleStr[i]))
170170
}

0 commit comments

Comments
 (0)