tailnet

package
v0.2.30 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tailnet adapts the stock tsnet.Server. It is the only package that imports Tailscale, so upstream types never reach the public API.

Index

Constants

This section is empty.

Variables

View Source
var ErrHostDial = errors.New("tailnet: refusing a connection outside the private network")

Functions

This section is empty.

Types

type Peer

type Peer struct {
	ID      string       // stable node ID assigned by the control server
	NodeKey string       // the node's public key as the control server holds it, "nodekey:<hex>"
	Name    string       // host name
	Addrs   []netip.Addr // network addresses
}

Peer is a node identified by the control server.

type PeerStatus

type PeerStatus struct {
	Peer
	Online bool
	Direct string // current direct UDP endpoint; empty when relayed or idle
	Relay  string // home relay region code
}

PeerStatus is a peer as currently seen by this node.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func Start

func Start(ctx context.Context, dir, controlURL, hostname, authKey string, logf func(string, ...any)) (*Server, error)

Start runs a node and waits until it is connected. authKey is used only when dir holds no registered identity.

func (*Server) Close

func (s *Server) Close() error

func (*Server) Dial

func (s *Server) Dial(ctx context.Context, addr netip.AddrPort) (net.Conn, error)

Dial connects over the private network only. tsnet hands an address that is not a current peer at dial time to the host network instead; that connection is closed here and never returned.

func (*Server) Listen

func (s *Server) Listen(port uint16) (net.Listener, error)

func (*Server) Status

func (s *Server) Status(ctx context.Context) (Status, error)

func (*Server) WatchRemovals

func (s *Server) WatchRemovals(ctx context.Context, changed func()) (run func() error, err error)

WatchRemovals subscribes before returning, so no later removal is missed. The returned run calls changed whenever a peer leaves the network map or the backend state changes, until ctx ends or the watch fails.

func (*Server) WhoIs

func (s *Server) WhoIs(ctx context.Context, addr string) (Peer, error)

WhoIs returns the peer that currently owns addr ("ip" or "ip:port").

type Status

type Status struct {
	State string // backend state, such as "Running" or "NeedsLogin"
	Self  Peer
	Peers []PeerStatus
}

Status is this node's current view of the network.

Jump to

Keyboard shortcuts

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