tsdial
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package tsdial provides a Dialer type that can dial out of tailscaled.
Index¶
- type Dialer
- func (d *Dialer) Close() error
- func (d *Dialer) NetMon() *netmon.Monitor
- func (d *Dialer) PeerAPIHTTPClient() *http.Client
- func (d *Dialer) PeerAPITransport() *http.Transport
- func (d *Dialer) PeerDialControlFunc() func(network, address string, c syscall.RawConn) error
- func (d *Dialer) SetBus(bus *eventbus.Bus)
- func (d *Dialer) SetExitDNSDoH(doh string)
- func (d *Dialer) SetNetMap(nm *netmap.NetworkMap)
- func (d *Dialer) SetNetMon(netMon *netmon.Monitor)
- func (d *Dialer) SetRoutes(routes, localRoutes []netip.Prefix)
- func (d *Dialer) SetSystemDialerForTest(fn netx.DialFunc)
- func (d *Dialer) SetTUNName(name string)
- func (d *Dialer) SystemDial(ctx context.Context, network, addr string) (net.Conn, error)
- func (d *Dialer) TUNName() string
- func (d *Dialer) UserDial(ctx context.Context, network, addr string) (net.Conn, error)
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeDialer¶
type Dialer struct {Logflogger.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)// NetstackDialUDP dials the provided IPPort using netstack.// If nil, it's not used.NetstackDialUDP func(context.Context,netip.AddrPort) (net.Conn,error)// contains filtered or unexported fields}Dialer dials out of tailscaled, while taking care of details whilehandling the dozens of edge cases depending on the server mode(TUN, netstack), the OS network sandboxing style (macOS/iOSExtension, none), user-selected route acceptance prefs, etc.
Before use, SetNetMon should be called with a netmon.Monitor.
funcNewDialer¶added inv1.66.0
NewDialer returns a new Dialer that can dial out of tailscaled.Its exported fields should be set before use, if any.
funcNewFromFuncForDebug¶added inv1.90.0
NewFromFuncForDebug is like NewDialer but takes a netx.DialFuncand no netMon. It's meant exclusively for the "tailscale debug ts2021"debug command, and perhaps tests.
func (*Dialer)NetMon¶added inv1.66.0
NetMon returns the Dialer's network monitor.It returns nil if SetNetMon has not been called.
func (*Dialer)PeerAPIHTTPClient¶
PeerAPIHTTPClient returns an HTTP Client to call peers' peerapiendpoints. //The returned Client must not be mutated; it's owned by the Dialerand shared by callers.
func (*Dialer)PeerAPITransport¶
PeerAPITransport returns a Transport to call peers' peerapiendpoints.
The returned value must not be mutated; it's owned by the Dialerand shared by callers.
func (*Dialer)PeerDialControlFunc¶
PeerDialControlFunc returns a functionthat can assigned to net.Dialer.Control to set sockopts or whatnotto 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 orSystem Extension (the GUI variants).
func (*Dialer)SetExitDNSDoH¶
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 withouta '?' 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 namesin its DNS configuration.
func (*Dialer)SetNetMon¶added inv1.40.0
SetNetMon sets d's network monitor to netMon.It is a no-op to call SetNetMon with the same netMon as the current one.
func (*Dialer)SetRoutes¶added inv1.66.0
SetRoutes configures the dialer to dial the specified routes via Tailscale,and the specified localRoutes using the default interface.
func (*Dialer)SetSystemDialerForTest¶added inv1.84.0
SetSystemDialerForTest sets an alternate function to use for SystemDialinstead of netns.Dialer. This is intended for use with nettest.MemoryNetwork.
func (*Dialer)SetTUNName¶
SetTUNName sets the name of the tun device in use ("tailscale0", "utun6",etc). This is needed on some platforms to set sockopts to bindto the same interface index.
func (*Dialer)SystemDial¶added inv1.24.1
SystemDial connects to the provided network address without going overTailscale. It prefers going over the default interface and closes existingconnections if the default interface changes. It is used to connect toControl and (in the future, as of 2022-04-27) DERPs..