net/netns: thread logf into control functions

So that darwin can log there without panicking during tests.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2021-11-18 12:18:02 -08:00
committed by Josh Bleecher Snyder
parent 85184a58ed
commit 758c37b83d
16 changed files with 64 additions and 33 deletions

View File

@ -12,6 +12,7 @@ import (
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
"tailscale.com/net/interfaces"
"tailscale.com/types/logger"
"tailscale.com/util/endian"
)
@ -26,9 +27,13 @@ func interfaceIndex(iface *winipcfg.IPAdapterAddresses) uint32 {
return iface.IfIndex
}
// control binds c to the Windows interface that holds a default
func control(logger.Logf) func(network, address string, c syscall.RawConn) error {
return controlC
}
// controlC binds c to the Windows interface that holds a default
// route, and is not the Tailscale WinTun interface.
func control(network, address string, c syscall.RawConn) error {
func controlC(network, address string, c syscall.RawConn) error {
if strings.HasPrefix(address, "127.") {
// Don't bind to an interface for localhost connections,
// otherwise we get: