mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
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:
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user