tsaddr

package
v1.72.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 65

Documentation

Overview

Package tsaddr handles Tailscale-specific IPs and ranges.

Index

Constants

View Source
const (
	TailscaleServiceIPString   = "100.100.100.100"
	TailscaleServiceIPv6String = "fd7a:115c:a1e0::53"
)

Variables

This section is empty.

Functions

func AllIPv4 added in v1.24.0

func AllIPv4() netip.Prefix

AllIPv4 returns 0.0.0.0/0.

func AllIPv6 added in v1.24.0

func AllIPv6() netip.Prefix

AllIPv6 returns ::/0.

func CGNATRange

func CGNATRange() netip.Prefix

CGNATRange returns the Carrier Grade NAT address range that is the superset range that Tailscale assigns out of. See https://tailscale.com/s/cgnat Note that Tailscale does not assign out of the ChromeOSVMRange.

func ChromeOSVMRange

func ChromeOSVMRange() netip.Prefix

ChromeOSVMRange returns the subset of the CGNAT IPv4 range used by ChromeOS to interconnect the host OS to containers and VMs. We avoid allocating Tailscale IPs from it, to avoid conflicts.

func ContainsExitRoutes added in v1.24.0

func ContainsExitRoutes(rr views.Slice[netip.Prefix]) bool

ContainsExitRoutes reports whether rr contains both the IPv4 and IPv6 /0 route.

func ContainsNonExitSubnetRoutes added in v1.50.0

func ContainsNonExitSubnetRoutes(rr views.Slice[netip.Prefix]) bool

ContainsNonExitSubnetRoutes reports whether v contains Subnet Routes other than ExitNode Routes.

func ExitRoutes added in v1.24.0

func ExitRoutes() []netip.Prefix

ExitRoutes returns a slice containing AllIPv4 and AllIPv6.

func FilterPrefixesCopy added in v1.24.0

func FilterPrefixesCopy(in views.Slice[netip.Prefix], f func(netip.Prefix) bool) []netip.Prefix

FilterPrefixes returns a new slice, not aliasing in, containing elements of in that match f.

func IsTailscaleIP

func IsTailscaleIP(ip netip.Addr) bool

IsTailscaleIP reports whether ip is an IP address in a range that Tailscale assigns from.

func IsViaPrefix added in v1.24.0

func IsViaPrefix(p netip.Prefix) bool

IsViaPrefix reports whether p is a CIDR in the Tailscale "via" range. See TailscaleViaRange.

func MapVia added in v1.24.0

func MapVia(siteID uint32, v4 netip.Prefix) (via netip.Prefix, err error)

MapVia returns an IPv6 "via" route for an IPv4 CIDR in a given siteID.

func PrefixIs4 added in v1.16.0

func PrefixIs4(p netip.Prefix) bool

PrefixIs4 reports whether p is an IPv4 prefix.

func PrefixIs6 added in v1.16.0

func PrefixIs6(p netip.Prefix) bool

PrefixIs6 reports whether p is an IPv6 prefix.

func PrefixesContainsIP added in v1.20.0

func PrefixesContainsIP(ipp []netip.Prefix, ip netip.Addr) bool

PrefixesContainsIP reports whether any prefix in ipp contains ip.

func SortPrefixes added in v1.34.0

func SortPrefixes(p []netip.Prefix)

SortPrefixes sorts the prefixes in place.

func Tailscale4To6 added in v1.2.0

func Tailscale4To6(ipv4 netip.Addr) netip.Addr

Tailscale4To6 returns a Tailscale IPv6 address that maps 1:1 to the given Tailscale IPv4 address. Returns a zero IP if ipv4 isn't a Tailscale IPv4 address.

func Tailscale4To6Placeholder added in v1.6.0

func Tailscale4To6Placeholder() netip.Addr

Tailscale4To6Placeholder returns an IP address that can be used as a source IP when one is required, but a netmap didn't provide any. This address never gets allocated by the 4-to-6 algorithm in control.

Currently used to work around a Windows limitation when programming IPv6 routes in corner cases.

func Tailscale4To6Range added in v1.2.0

func Tailscale4To6Range() netip.Prefix

Tailscale4To6Range returns the subset of TailscaleULARange used for auto-translated Tailscale ipv4 addresses.

func Tailscale6to4 added in v1.24.0

func Tailscale6to4(ipv6 netip.Addr) (netip.Addr, bool)

Tailscale6to4 returns the IPv4 address corresponding to the given tailscale IPv6 address within the 4To6 range. The IPv4 address and true are returned if the given address was in the correct range, false if not.

func TailscaleEphemeral6Range added in v1.8.0

func TailscaleEphemeral6Range() netip.Prefix

TailscaleEphemeral6Range returns the subset of TailscaleULARange used for ephemeral IPv6-only Tailscale nodes.

func TailscaleServiceIP added in v1.0.1

func TailscaleServiceIP() netip.Addr

TailscaleServiceIP returns the IPv4 listen address of services provided by Tailscale itself such as the MagicDNS proxy.

For IPv6, use TailscaleServiceIPv6.

func TailscaleServiceIPv6 added in v1.20.0

func TailscaleServiceIPv6() netip.Addr

TailscaleServiceIPv6 returns the IPv6 listen address of the services provided by Tailscale itself such as the MagicDNS proxy.

For IPv4, use TailscaleServiceIP.

func TailscaleULARange added in v1.2.0

func TailscaleULARange() netip.Prefix

TailscaleULARange returns the IPv6 Unique Local Address range that is the superset range that Tailscale assigns out of.

func TailscaleViaRange added in v1.24.0

func TailscaleViaRange() netip.Prefix

TailscaleViaRange returns the IPv6 Unique Local Address subset range TailscaleULARange that's used for IPv4 tunneling via IPv6.

func UnmapVia added in v1.24.0

func UnmapVia(ip netip.Addr) netip.Addr

UnmapVia returns the IPv4 address that corresponds to the provided Tailscale "via" IPv4-in-IPv6 address.

If ip is not a via address, it returns ip unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

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