tsdial

package
v0.0.0-...-113f59a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package tsdial provides a Dialer type that can dial out of tailscaled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer struct {
	Logf logger.Logf
	// UseNetstackForIP if non-nil is whether NetstackDialTCP (if
	// it's non-nil) should be used to dial the provided IP.
	UseNetstackForIP func(netip.Addr) bool

	// NetstackDialTCP dials the provided IPPort using netstack.
	// If nil, it's not used.
	NetstackDialTCP func(context.Context, netip.AddrPort) (net.Conn, error)
	// contains filtered or unexported fields
}

Dialer dials out of tailscaled, while taking care of details while handling the dozens of edge cases depending on the server mode (TUN, netstack), the OS network sandboxing style (macOS/iOS Extension, none), user-selected route acceptance prefs, etc.

func (*Dialer) Close

func (d *Dialer) Close() error

func (*Dialer) PeerAPIHTTPClient

func (d *Dialer) PeerAPIHTTPClient() *http.Client

PeerAPIHTTPClient returns an HTTP Client to call peers' peerapi endpoints. // The returned Client must not be mutated; it's owned by the Dialer and shared by callers.

func (*Dialer) PeerAPITransport

func (d *Dialer) PeerAPITransport() *http.Transport

PeerAPITransport returns a Transport to call peers' peerapi endpoints.

The returned value must not be mutated; it's owned by the Dialer and shared by callers.

func (*Dialer) PeerDialControlFunc

func (d *Dialer) PeerDialControlFunc() func(network, address string, c syscall.RawConn) error

PeerDialControlFunc returns a function that can assigned to net.Dialer.Control to set sockopts or whatnot to make a dial escape the current platform's network sandbox.

On many platforms the returned func will be nil.

Notably, this is non-nil on iOS and macOS when run as a Network or System Extension (the GUI variants).

func (*Dialer) SetExitDNSDoH

func (d *Dialer) SetExitDNSDoH(doh string)

SetExitDNSDoH sets (or clears) the exit node DNS DoH server base URL to use. The doh URL should contain the scheme, authority, and path, but without a '?' and/or query parameters.

For example, "http://100.68.82.120:47830/dns-query".

func (*Dialer) SetNetMap

func (d *Dialer) SetNetMap(nm *netmap.NetworkMap)

SetNetMap sets the current network map and notably, the DNS names in its DNS configuration.

func (*Dialer) SetNetMon

func (d *Dialer) SetNetMon(netMon *netmon.Monitor)

func (*Dialer) SetTUNName

func (d *Dialer) SetTUNName(name string)

SetTUNName sets the name of the tun device in use ("tailscale0", "utun6", etc). This is needed on some platforms to set sockopts to bind to the same interface index.

func (*Dialer) SystemDial

func (d *Dialer) SystemDial(ctx context.Context, network, addr string) (net.Conn, error)

SystemDial connects to the provided network address without going over Tailscale. It prefers going over the default interface and closes existing connections if the default interface changes. It is used to connect to Control and (in the future, as of 2022-04-27) DERPs..

func (*Dialer) TUNName

func (d *Dialer) TUNName() string

TUNName returns the name of the tun device in use, if any. Example format ("tailscale0", "utun6").

func (*Dialer) UserDial

func (d *Dialer) UserDial(ctx context.Context, network, addr string) (net.Conn, error)

UserDial connects to the provided network address as if a user were initiating the dial. (e.g. from a SOCKS or HTTP outbound proxy)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL