all: cleanup unused code, part 1 (#10661)

Run `staticcheck` with `U1000` to find unused code. This cleans up about
a half of it. I'll do the other half separately to keep PRs manageable.

Updates #cleanup

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
Andrew Lytvynov
2023-12-20 16:50:30 -06:00
committed by GitHub
parent 3c333f6341
commit 1302bd1181
26 changed files with 81 additions and 274 deletions
-23
View File
@@ -74,18 +74,6 @@ var icmp4ReplyBuffer = []byte{
0x72, 0x65, 0x70, 0x6c, 0x79, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
}
var icmp4ReplyDecode = Parsed{
b: icmp4ReplyBuffer,
subofs: 20,
dataofs: 24,
length: len(icmp4ReplyBuffer),
IPVersion: 4,
IPProto: ICMPv4,
Src: mustIPPort("1.2.3.4:0"),
Dst: mustIPPort("5.6.7.8:0"),
}
// ICMPv6 Router Solicitation
var icmp6PacketBuffer = []byte{
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
@@ -257,17 +245,6 @@ var udp4ReplyBuffer = []byte{
0x72, 0x65, 0x70, 0x6c, 0x79, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
}
var udp4ReplyDecode = Parsed{
b: udp4ReplyBuffer,
subofs: 20,
dataofs: 28,
length: len(udp4ReplyBuffer),
IPProto: UDP,
Src: mustIPPort("1.2.3.4:567"),
Dst: mustIPPort("5.6.7.8:123"),
}
// First TCP fragment of a packet with leading 24 bytes of 'a's
var tcp4MediumFragmentBuffer = []byte{
// IP header up to checksum
-2
View File
@@ -50,9 +50,7 @@ type TestIGDOptions struct {
type igdCounters struct {
numUPnPDiscoRecv int32
numUPnPOtherUDPRecv int32
numUPnPHTTPRecv int32
numPMPRecv int32
numPMPDiscoRecv int32
numPCPRecv int32
numPCPDiscoRecv int32
numPCPMapRecv int32
+2 -2
View File
@@ -138,8 +138,8 @@ func mkWorld(t *testing.T) (ret *world) {
}
go httpProxy.Serve(ret.httpListener)
socksProxy := socks5.Server{}
go socksProxy.Serve(ret.socksListener)
ret.socksProxy = &socks5.Server{}
go ret.socksProxy.Serve(ret.socksListener)
ret.httpClient = &http.Client{
Transport: &http.Transport{
+1
View File
@@ -16,6 +16,7 @@ import (
var (
defaultRouteIPv4 = RouteDestination{Prefix: netip.PrefixFrom(netip.IPv4Unspecified(), 0)}
//lint:ignore U1000 used in routetable_bsd_test.go
defaultRouteIPv6 = RouteDestination{Prefix: netip.PrefixFrom(netip.IPv6Unspecified(), 0)}
)
-1
View File
@@ -37,7 +37,6 @@ func CGNATRange() netip.Prefix {
var (
cgnatRange oncePrefix
ulaRange oncePrefix
tsUlaRange oncePrefix
tsViaRange oncePrefix
ula4To6Range oncePrefix
+13 -1
View File
@@ -26,7 +26,7 @@ func peerDialControlFuncNetworkExtension(d *Dialer) func(network, address string
defer d.mu.Unlock()
index := -1
if x, ok := d.interfaceIndexLocked(d.tunName); ok {
if x, ok := interfaceIndexLocked(d); ok {
index = x
}
var lc net.ListenConfig
@@ -38,3 +38,15 @@ func peerDialControlFuncNetworkExtension(d *Dialer) func(network, address string
return lc.Control(network, address, c)
}
}
func interfaceIndexLocked(d *Dialer) (index int, ok bool) {
if d.netMon == nil {
return 0, false
}
st := d.netMon.InterfaceState()
iface, ok := st.Interface[d.tunName]
if !ok {
return 0, false
}
return iface.Index, true
}
-12
View File
@@ -196,18 +196,6 @@ func (d *Dialer) closeSysConn(id int) {
go c.Close() // ignore the error
}
func (d *Dialer) interfaceIndexLocked(ifName string) (index int, ok bool) {
if d.netMon == nil {
return 0, false
}
st := d.netMon.InterfaceState()
iface, ok := st.Interface[ifName]
if !ok {
return 0, false
}
return iface.Index, true
}
// peerDialControlFunc is non-nil on platforms that require a way to
// bind to dial out to other peers.
var peerDialControlFunc func(*Dialer) func(network, address string, c syscall.RawConn) error
-1
View File
@@ -258,7 +258,6 @@ func TestWriteAndInject(t *testing.T) {
chtun, tun := newChannelTUN(t.Logf, false)
defer tun.Close()
const size = 2 // all payloads have this size
written := []string{"w0", "w1"}
injected := []string{"i0", "i1"}