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

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
}

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