Skip to content

Commit

Permalink
Add and fix noctx linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kradalby committed Nov 14, 2021
1 parent 1969802 commit d0ef850
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ linters:
- stylecheck
- wrapcheck
- paralleltest
- noctx
- nlreturn
- ifshort
- gomnd
Expand Down
12 changes: 11 additions & 1 deletion derp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package headscale

import (
"context"
"encoding/json"
"io"
"io/ioutil"
Expand Down Expand Up @@ -30,10 +31,19 @@ func loadDERPMapFromPath(path string) (*tailcfg.DERPMap, error) {
}

func loadDERPMapFromURL(addr url.URL) (*tailcfg.DERPMap, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

req, err := http.NewRequestWithContext(ctx, "GET", addr.String(), nil)
if err != nil {
return nil, err
}

client := http.Client{
Timeout: 10 * time.Second,
}
resp, err := client.Get(addr.String())

resp, err := client.Do(req)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d0ef850

Please sign in to comment.