@ -21,10 +21,12 @@ import (
"tailscale.com/net/netknob"
"tailscale.com/net/netmon"
"tailscale.com/net/netns"
"tailscale.com/net/tsaddr"
"tailscale.com/types/logger"
"tailscale.com/types/netmap"
"tailscale.com/util/clientmetric"
"tailscale.com/util/mak"
"tailscale.com/version"
)
// Dialer dials out of tailscaled, while taking care of details while
@ -337,6 +339,14 @@ func (d *Dialer) UserDial(ctx context.Context, network, addr string) (net.Conn,
}
return d . NetstackDialTCP ( ctx , ipp )
}
// Workaround for macOS for now: dial Tailscale IPs with peer dialer.
// TODO(bradfitz): fix dialing subnet routers, public IPs via exit nodes,
// etc. This is a temporary partial for macOS. We need to plumb ART tables &
// prefs & host routing table updates around in more places. We just don't
// know from the limited context here how to dial properly.
if version . IsMacGUIVariant ( ) && tsaddr . IsTailscaleIP ( ipp . Addr ( ) ) {
return d . getPeerDialer ( ) . DialContext ( ctx , network , ipp . String ( ) )
}
// TODO(bradfitz): netns, etc
var stdDialer net . Dialer
return stdDialer . DialContext ( ctx , network , ipp . String ( ) )
@ -365,14 +375,14 @@ func (d *Dialer) dialPeerAPI(ctx context.Context, network, addr string) (net.Con
return d . getPeerDialer ( ) . DialContext ( ctx , network , addr )
}
// getPeerDialer returns the *net.Dialer to use to dial peers to use
// PeerAPI.
// getPeerDialer returns the *net.Dialer to use to dial peers (e.g. for peerapi,
// or "tailscale nc")
//
// This is not used in netstack mode.
//
// The primary function of this is to work on macOS & iOS's in the
// Network/System Extension so it can mark the dialer as staying
// within the network namespace/sandbox.
// Network/System Extension so it can mark the dialer as staying within the
// network namespace/sandbox.
func ( d * Dialer ) getPeerDialer ( ) * net . Dialer {
d . peerDialerOnce . Do ( func ( ) {
d . peerDialer = & net . Dialer {