mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-06 07:37:38 +00:00
all: fix new lint warnings from bumping staticcheck
In prep for updating to new staticcheck required for Go 1.23. Updates #12912 Change-Id: If77892a023b79c6fa798f936fc80428fd4ce0673 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
4637ac732e
commit
0ff474ff37
@ -327,7 +327,7 @@ func (a *ServiceReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("failed to parse cluster IP: %v", err)
|
msg := fmt.Sprintf("failed to parse cluster IP: %v", err)
|
||||||
tsoperator.SetServiceCondition(svc, tsapi.ProxyReady, metav1.ConditionFalse, reasonProxyFailed, msg, a.clock, logger)
|
tsoperator.SetServiceCondition(svc, tsapi.ProxyReady, metav1.ConditionFalse, reasonProxyFailed, msg, a.clock, logger)
|
||||||
return fmt.Errorf(msg)
|
return errors.New(msg)
|
||||||
}
|
}
|
||||||
for _, ip := range tsIPs {
|
for _, ip := range tsIPs {
|
||||||
addr, err := netip.ParseAddr(ip)
|
addr, err := netip.ParseAddr(ip)
|
||||||
|
@ -135,7 +135,7 @@ func TestFilterFormatAndSortExitNodes(t *testing.T) {
|
|||||||
result := filterFormatAndSortExitNodes(ps, "")
|
result := filterFormatAndSortExitNodes(ps, "")
|
||||||
|
|
||||||
if res := cmp.Diff(result.Countries, want.Countries, cmpopts.IgnoreUnexported(key.NodePublic{})); res != "" {
|
if res := cmp.Diff(result.Countries, want.Countries, cmpopts.IgnoreUnexported(key.NodePublic{})); res != "" {
|
||||||
t.Fatalf(res)
|
t.Fatal(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ func TestFilterFormatAndSortExitNodes(t *testing.T) {
|
|||||||
result := filterFormatAndSortExitNodes(ps, "Pacific")
|
result := filterFormatAndSortExitNodes(ps, "Pacific")
|
||||||
|
|
||||||
if res := cmp.Diff(result.Countries, want.Countries, cmpopts.IgnoreUnexported(key.NodePublic{})); res != "" {
|
if res := cmp.Diff(result.Countries, want.Countries, cmpopts.IgnoreUnexported(key.NodePublic{})); res != "" {
|
||||||
t.Fatalf(res)
|
t.Fatal(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ func TestInsertCompare(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if debugInsert {
|
if debugInsert {
|
||||||
t.Logf(fast.debugSummary())
|
t.Log(fast.debugSummary())
|
||||||
}
|
}
|
||||||
|
|
||||||
seenVals4 := map[int]bool{}
|
seenVals4 := map[int]bool{}
|
||||||
|
@ -15,8 +15,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -50,9 +48,6 @@ ens18 0000000A 00000000 0001 0 0 0 0000FFFF
|
|||||||
func likelyHomeRouterIPLinux() (ret netip.Addr, myIP netip.Addr, ok bool) {
|
func likelyHomeRouterIPLinux() (ret netip.Addr, myIP netip.Addr, ok bool) {
|
||||||
if procNetRouteErr.Load() {
|
if procNetRouteErr.Load() {
|
||||||
// If we failed to read /proc/net/route previously, don't keep trying.
|
// If we failed to read /proc/net/route previously, don't keep trying.
|
||||||
if runtime.GOOS == "android" {
|
|
||||||
return likelyHomeRouterIPAndroid()
|
|
||||||
}
|
|
||||||
return ret, myIP, false
|
return ret, myIP, false
|
||||||
}
|
}
|
||||||
lineNum := 0
|
lineNum := 0
|
||||||
@ -94,9 +89,6 @@ func likelyHomeRouterIPLinux() (ret netip.Addr, myIP netip.Addr, ok bool) {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
procNetRouteErr.Store(true)
|
procNetRouteErr.Store(true)
|
||||||
if runtime.GOOS == "android" {
|
|
||||||
return likelyHomeRouterIPAndroid()
|
|
||||||
}
|
|
||||||
log.Printf("interfaces: failed to read /proc/net/route: %v", err)
|
log.Printf("interfaces: failed to read /proc/net/route: %v", err)
|
||||||
}
|
}
|
||||||
if ret.IsValid() {
|
if ret.IsValid() {
|
||||||
@ -137,41 +129,6 @@ func likelyHomeRouterIPLinux() (ret netip.Addr, myIP netip.Addr, ok bool) {
|
|||||||
return netip.Addr{}, netip.Addr{}, false
|
return netip.Addr{}, netip.Addr{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android apps don't have permission to read /proc/net/route, at
|
|
||||||
// least on Google devices and the Android emulator.
|
|
||||||
func likelyHomeRouterIPAndroid() (ret netip.Addr, _ netip.Addr, ok bool) {
|
|
||||||
cmd := exec.Command("/system/bin/ip", "route", "show", "table", "0")
|
|
||||||
out, err := cmd.StdoutPipe()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := cmd.Start(); err != nil {
|
|
||||||
log.Printf("interfaces: running /system/bin/ip: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Search for line like "default via 10.0.2.2 dev radio0 table 1016 proto static mtu 1500 "
|
|
||||||
lineread.Reader(out, func(line []byte) error {
|
|
||||||
const pfx = "default via "
|
|
||||||
if !mem.HasPrefix(mem.B(line), mem.S(pfx)) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
line = line[len(pfx):]
|
|
||||||
sp := bytes.IndexByte(line, ' ')
|
|
||||||
if sp == -1 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
ipb := line[:sp]
|
|
||||||
if ip, err := netip.ParseAddr(string(ipb)); err == nil && ip.Is4() {
|
|
||||||
ret = ip
|
|
||||||
log.Printf("interfaces: found Android default route %v", ip)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
cmd.Process.Kill()
|
|
||||||
cmd.Wait()
|
|
||||||
return ret, netip.Addr{}, ret.IsValid()
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultRoute() (d DefaultRouteDetails, err error) {
|
func defaultRoute() (d DefaultRouteDetails, err error) {
|
||||||
v, err := defaultRouteInterfaceProcNet()
|
v, err := defaultRouteInterfaceProcNet()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -7,7 +7,6 @@ package safesocket
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -18,9 +17,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func connect(ctx context.Context, path string) (net.Conn, error) {
|
func connect(ctx context.Context, path string) (net.Conn, error) {
|
||||||
if runtime.GOOS == "js" {
|
|
||||||
return nil, errors.New("safesocket.Connect not yet implemented on js/wasm")
|
|
||||||
}
|
|
||||||
var std net.Dialer
|
var std net.Dialer
|
||||||
return std.DialContext(ctx, "unix", path)
|
return std.DialContext(ctx, "unix", path)
|
||||||
}
|
}
|
||||||
|
@ -1731,6 +1731,7 @@ func envValFromList(env []string, wantKey string) (v string) {
|
|||||||
// envEq reports whether environment variable a == b for the current
|
// envEq reports whether environment variable a == b for the current
|
||||||
// operating system.
|
// operating system.
|
||||||
func envEq(a, b string) bool {
|
func envEq(a, b string) bool {
|
||||||
|
//lint:ignore SA4032 in case this func moves elsewhere, permit the GOOS check
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return strings.EqualFold(a, b)
|
return strings.EqualFold(a, b)
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ import (
|
|||||||
"github.com/tailscale/hujson"
|
"github.com/tailscale/hujson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// go:generate go run ./gen
|
|
||||||
|
|
||||||
type Distro struct {
|
type Distro struct {
|
||||||
Name string // amazon-linux
|
Name string // amazon-linux
|
||||||
URL string // URL to a qcow2 image
|
URL string // URL to a qcow2 image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user