Documentation
¶
Overview ¶
Package tsdns provides DNS resolution through the Tailscale local API.
This works around tailscale/tailscale#5840 where tsnet.Server.Dial falls back to the system resolver for non-tailnet names, breaking split DNS resolution.
Index ¶
- func FetchDNSRoutes(ctx context.Context, watchIPNBus WatchIPNBusFunc) (map[string][]string, error)
- func ForwardQuery(ctx context.Context, dial DialFunc, resolver, fqdn, qtype string) ([]byte, error)
- func LookupHost(ctx context.Context, query QueryFunc, host string) ([]string, error)
- func NewDialer(tsDial func(ctx context.Context, network, addr string) (net.Conn, error), ...) func(ctx context.Context, network, addr string) (net.Conn, error)
- func NewLookupFunc(query QueryFunc) func(ctx context.Context, host string) ([]string, error)
- type DialFunc
- type IPNBusWatcher
- type QueryFunc
- type WatchIPNBusFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchDNSRoutes ¶ added in v0.4.8
FetchDNSRoutes reads DNS routes from the Tailscale network map via the IPN bus. It returns a simplified map of domain suffix → resolver address list.
func ForwardQuery ¶ added in v0.4.8
ForwardQuery builds a DNS query for fqdn/qtype, sends it to resolver via dial (which routes through Tailscale's userspace network), and returns the raw DNS response bytes.
func LookupHost ¶
LookupHost resolves a hostname to IP addresses using the provided Tailscale DNS query function. The query function should call local.Client.QueryDNS (or equivalent) which goes through the full Tailscale DNS stack including MagicDNS and split DNS.
func NewDialer ¶
func NewDialer(tsDial func(ctx context.Context, network, addr string) (net.Conn, error), query QueryFunc) func(ctx context.Context, network, addr string) (net.Conn, error)
NewDialer creates a dialer that resolves hostnames through Tailscale's DNS stack before dialing via the provided Tailscale dialer. This ensures split DNS domains are resolved correctly.
Types ¶
type DialFunc ¶ added in v0.4.8
DialFunc dials a network connection, matching tsnet.Server.Dial's signature.
type IPNBusWatcher ¶ added in v0.4.8
IPNBusWatcher abstracts the watcher returned by WatchIPNBus so that FetchDNSRoutes can be tested without a real Tailscale client.
type QueryFunc ¶
QueryFunc matches the signature of local.Client.QueryDNS.
func NewRoutedQueryFunc ¶ added in v0.4.8
NewRoutedQueryFunc returns a QueryFunc that routes DNS queries matching configured route suffixes through dial (Tailscale userspace network) and falls back to fallback (typically lc.QueryDNS) for everything else.
type WatchIPNBusFunc ¶ added in v0.4.8
type WatchIPNBusFunc func(ctx context.Context, mask ipn.NotifyWatchOpt) (IPNBusWatcher, error)
WatchIPNBusFunc matches the signature of tailscale.com/client/local.Client.WatchIPNBus.