tailnet
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¶
Index¶
- Constants
- Variables
- func CoordinatorHTTPDebug(agentSocketsMap map[uuid.UUID]Queue, ...) func(w http.ResponseWriter, _ *http.Request)
- func IP() netip.Addr
- func IPFromUUID(uid uuid.UUID) netip.Addr
- func Logger(logger slog.Logger) tslogger.Logf
- func NewDERPMap(ctx context.Context, region *tailcfg.DERPRegion, stunAddrs []string, ...) (*tailcfg.DERPMap, error)
- func ServeCoordinator(conn net.Conn, updateNodes func(node []*Node) error) (func(node *Node), <-chan error)
- func WithWebsocketSupport(s *derp.Server, base http.Handler) (http.Handler, func())
- type Conn
- func (c *Conn) Addresses() []netip.Prefix
- func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool
- func (c *Conn) BlockEndpoints() bool
- func (c *Conn) Close() error
- func (c *Conn) Closed() <-chan struct{}
- func (c *Conn) DERPMap() *tailcfg.DERPMap
- func (c *Conn) DialContextTCP(ctx context.Context, ipp netip.AddrPort) (*gonet.TCPConn, error)
- func (c *Conn) DialContextUDP(ctx context.Context, ipp netip.AddrPort) (*gonet.UDPConn, error)
- func (c *Conn) Listen(network, addr string) (net.Listener, error)
- func (c *Conn) MagicsockServeHTTPDebug(w http.ResponseWriter, r *http.Request)
- func (c *Conn) Node() *Node
- func (c *Conn) NodeAddresses(publicKey key.NodePublic) ([]netip.Prefix, bool)
- func (c *Conn) Ping(ctx context.Context, ip netip.Addr) (time.Duration, bool, *ipnstate.PingResult, error)
- func (c *Conn) SetAddresses(ips []netip.Prefix) error
- func (c *Conn) SetBlockEndpoints(blockEndpoints bool)
- func (c *Conn) SetConnStatsCallback(maxPeriod time.Duration, maxConns int, dump func(start, end time.Time, ...))
- func (c *Conn) SetDERPMap(derpMap *tailcfg.DERPMap)
- func (c *Conn) SetDERPRegionDialer(dialer func(ctx context.Context, region *tailcfg.DERPRegion) net.Conn)
- func (c *Conn) SetNodeCallback(callback func(node *Node))
- func (c *Conn) Status() *ipnstate.Status
- func (c *Conn) UpdateNodes(nodes []*Node, replacePeers bool) error
- type Coordinator
- type MultiAgent
- func (m *MultiAgent) AgentIsLegacy(agentID uuid.UUID) bool
- func (m *MultiAgent) Close() error
- func (m *MultiAgent) CoordinatorClose() error
- func (m *MultiAgent) Enqueue(nodes []*Node) error
- func (m *MultiAgent) Init() *MultiAgent
- func (m *MultiAgent) IsClosed() bool
- func (m *MultiAgent) Name() string
- func (m *MultiAgent) NextUpdate(ctx context.Context) ([]*Node, bool)
- func (m *MultiAgent) Overwrites() int64
- func (m *MultiAgent) Stats() (start int64, lastWrite int64)
- func (m *MultiAgent) SubscribeAgent(agentID uuid.UUID) error
- func (m *MultiAgent) UniqueID() uuid.UUID
- func (m *MultiAgent) UnsubscribeAgent(agentID uuid.UUID) error
- func (m *MultiAgent) UpdateSelf(node *Node) error
- type MultiAgentConn
- type Node
- type Options
- type Queue
- type TrackedConn
- func (t *TrackedConn) Close() error
- func (t *TrackedConn) CoordinatorClose() error
- func (t *TrackedConn) Enqueue(n []*Node) (err error)
- func (t *TrackedConn) Name() string
- func (t *TrackedConn) Overwrites() int64
- func (t *TrackedConn) SendUpdates()
- func (t *TrackedConn) Stats() (start, lastWrite int64)
- func (t *TrackedConn) UniqueID() uuid.UUID
Constants¶
const (WorkspaceAgentSSHPort = 1WorkspaceAgentReconnectingPTYPort = 2WorkspaceAgentSpeedtestPort = 3)
const LoggerName = "coord"
const WriteTimeout =time.Second * 5
WriteTimeout is the amount of time we wait to write a node update to a connection before we declare it hung.It is exported so that tests can use it.
Variables¶
var ErrMultiAgentClosed =xerrors.New("multiagent is closed")
var ErrWouldBlock =xerrors.New("would block")
Functions¶
funcCoordinatorHTTPDebug¶added inv0.15.3
funcIPFromUUID¶added inv0.26.2
IP generates a new IP from a UUID.
funcNewDERPMap¶
func NewDERPMap(ctxcontext.Context, region *tailcfg.DERPRegion, stunAddrs []string, remoteURL, localPathstring, disableSTUNbool) (*tailcfg.DERPMap,error)
NewDERPMap constructs a DERPMap from a set of STUN addresses and optionally a remoteURL to fetch a mapping from e.g.https://controlplane.tailscale.com/derpmap/default.
funcServeCoordinator¶
func ServeCoordinator(connnet.Conn, updateNodes func(node []*Node)error) (func(node *Node), <-chanerror)
ServeCoordinator matches the RW structure of a coordinator to exchange node messages.
funcWithWebsocketSupport¶added inv0.18.1
WithWebsocketSupport returns an http.Handler that upgradesconnections to the "derp" subprotocol to WebSockets andpasses them to the DERP server.Taken from:https://github.com/tailscale/tailscale/blob/e3211ff88ba85435f70984cf67d9b353f3d650d8/cmd/derper/websocket.go#L21
Types¶
typeConn¶
type Conn struct {// contains filtered or unexported fields}
Conn is an actively listening Wireguard connection.
funcNewConn¶
NewConn constructs a new Wireguard server that will accept connections from the addresses provided.
func (*Conn)AwaitReachable¶added inv0.12.7
AwaitReachable pings the provided IP continually until theaddress is reachable. It's the callers responsibility to providea timeout, otherwise this function will block forever.
func (*Conn)BlockEndpoints¶added inv0.25.0
BlockEndpoints returns whether or not P2P is blocked.
func (*Conn)Closed¶
func (c *Conn) Closed() <-chan struct{}
Closed is a channel that ends when the connection hasbeen closed.
func (*Conn)DialContextTCP¶
func (*Conn)DialContextUDP¶
func (*Conn)MagicsockServeHTTPDebug¶added inv0.23.1
func (c *Conn) MagicsockServeHTTPDebug(whttp.ResponseWriter, r *http.Request)
func (*Conn)NodeAddresses¶added inv0.18.1
NodeAddresses returns the addresses of a node from the NetworkMap.
func (*Conn)Ping¶
func (c *Conn) Ping(ctxcontext.Context, ipnetip.Addr) (time.Duration,bool, *ipnstate.PingResult,error)
Ping sends a Disco ping to the Wireguard engine.The bool returned is true if the ping was performed P2P.
func (*Conn)SetBlockEndpoints¶added inv0.25.0
SetBlockEndpoints sets whether or not to block P2P endpoints. This settingwill only apply to new peers.
func (*Conn)SetConnStatsCallback¶added inv0.17.2
func (c *Conn) SetConnStatsCallback(maxPeriodtime.Duration, maxConnsint, dump func(start, endtime.Time, virtual, physical map[netlogtype.Connection]netlogtype.Counts))
SetConnStatsCallback sets a callback to be called after maxPeriod ormaxConns, whichever comes first. Multiple calls overwrites the callback.
func (*Conn)SetDERPMap¶
SetDERPMap updates the DERPMap of a connection.
func (*Conn)SetDERPRegionDialer¶added inv0.20.0
func (c *Conn) SetDERPRegionDialer(dialer func(ctxcontext.Context, region *tailcfg.DERPRegion)net.Conn)
SetDERPRegionDialer updates the dialer to use for connecting to DERP regions.
func (*Conn)SetNodeCallback¶
typeCoordinator¶
type Coordinator interface {// ServeHTTPDebug serves a debug webpage that shows the internal state of// the coordinator.ServeHTTPDebug(whttp.ResponseWriter, r *http.Request)// Node returns an in-memory node by ID.Node(iduuid.UUID) *Node// ServeClient accepts a WebSocket connection that wants to connect to an agent// with the specified ID.ServeClient(connnet.Conn, iduuid.UUID, agentuuid.UUID)error// ServeAgent accepts a WebSocket connection to an agent that listens to// incoming connections and publishes node updates.// Name is just used for debug information. It can be left blank.ServeAgent(connnet.Conn, iduuid.UUID, namestring)error// Close closes the coordinator.Close()errorServeMultiAgent(iduuid.UUID)MultiAgentConn}
Coordinator exchanges nodes with agents to establish connections.┌──────────────────┐ ┌────────────────────┐ ┌───────────────────┐ ┌──────────────────┐│tailnet.Coordinate├──►│tailnet.AcceptClient│◄─►│tailnet.AcceptAgent│◄──┤tailnet.Coordinate│└──────────────────┘ └────────────────────┘ └───────────────────┘ └──────────────────┘Coordinators have different guarantees for HA support.
funcNewCoordinator¶
func NewCoordinator(loggerslog.Logger)Coordinator
NewCoordinator constructs a new in-memory connection coordinator. Thiscoordinator is incompatible with multiple Coder replicas as all node data isin-memory.
typeMultiAgent¶added inv0.26.2
type MultiAgent struct {IDuuid.UUIDAgentIsLegacyFunc func(agentIDuuid.UUID)boolOnSubscribe func(enqQueue, agentuuid.UUID) (*Node,error)OnUnsubscribe func(enqQueue, agentuuid.UUID)errorOnNodeUpdate func(iduuid.UUID, node *Node)errorOnRemove func(iduuid.UUID)// contains filtered or unexported fields}
func (*MultiAgent)AgentIsLegacy¶added inv0.26.2
func (m *MultiAgent) AgentIsLegacy(agentIDuuid.UUID)bool
func (*MultiAgent)Close¶added inv0.26.2
func (m *MultiAgent) Close()error
func (*MultiAgent)CoordinatorClose¶added inv0.26.2
func (m *MultiAgent) CoordinatorClose()error
func (*MultiAgent)Enqueue¶added inv0.26.2
func (m *MultiAgent) Enqueue(nodes []*Node)error
func (*MultiAgent)Init¶added inv0.26.2
func (m *MultiAgent) Init() *MultiAgent
func (*MultiAgent)IsClosed¶added inv0.26.2
func (m *MultiAgent) IsClosed()bool
func (*MultiAgent)Name¶added inv0.26.2
func (m *MultiAgent) Name()string
func (*MultiAgent)NextUpdate¶added inv0.26.2
func (m *MultiAgent) NextUpdate(ctxcontext.Context) ([]*Node,bool)
func (*MultiAgent)Overwrites¶added inv0.26.2
func (m *MultiAgent) Overwrites()int64
func (*MultiAgent)Stats¶added inv0.26.2
func (m *MultiAgent) Stats() (startint64, lastWriteint64)
func (*MultiAgent)SubscribeAgent¶added inv0.26.2
func (m *MultiAgent) SubscribeAgent(agentIDuuid.UUID)error
func (*MultiAgent)UniqueID¶added inv0.26.2
func (m *MultiAgent) UniqueID()uuid.UUID
func (*MultiAgent)UnsubscribeAgent¶added inv0.26.2
func (m *MultiAgent) UnsubscribeAgent(agentIDuuid.UUID)error
func (*MultiAgent)UpdateSelf¶added inv0.26.2
func (m *MultiAgent) UpdateSelf(node *Node)error
typeMultiAgentConn¶added inv0.26.2
typeNode¶
type Node struct {// ID is used to identify the connection.IDtailcfg.NodeID `json:"id"`// AsOf is the time the node was created.AsOftime.Time `json:"as_of"`// Key is the Wireguard public key of the node.Keykey.NodePublic `json:"key"`// DiscoKey is used for discovery messages over DERP to establish// peer-to-peer connections.DiscoKeykey.DiscoPublic `json:"disco"`// PreferredDERP is the DERP server that peered connections should meet at// to establish.PreferredDERPint `json:"preferred_derp"`// DERPLatency is the latency in seconds to each DERP server.DERPLatency map[string]float64 `json:"derp_latency"`// DERPForcedWebsocket contains a mapping of DERP regions to// error messages that caused the connection to be forced to// use WebSockets. We don't use WebSockets by default because// they are less performant.DERPForcedWebsocket map[int]string `json:"derp_forced_websockets"`// Addresses are the IP address ranges this connection exposes.Addresses []netip.Prefix `json:"addresses"`// AllowedIPs specify what addresses can dial the connection. We allow all// by default.AllowedIPs []netip.Prefix `json:"allowed_ips"`// Endpoints are ip:port combinations that can be used to establish// peer-to-peer connections.Endpoints []string `json:"endpoints"`}
Node represents a node in the network.
typeTrackedConn¶added inv0.15.3
type TrackedConn struct {// contains filtered or unexported fields}
funcNewTrackedConn¶added inv0.23.1
func (*TrackedConn)Close¶added inv0.23.1
func (t *TrackedConn) Close()error
Close the connection and cancel the context for reading node updates from the queue
func (*TrackedConn)CoordinatorClose¶added inv0.26.2
func (t *TrackedConn) CoordinatorClose()error
func (*TrackedConn)Enqueue¶added inv0.23.1
func (t *TrackedConn) Enqueue(n []*Node) (errerror)
func (*TrackedConn)Name¶added inv0.15.3
func (t *TrackedConn) Name()string
func (*TrackedConn)Overwrites¶added inv0.15.3
func (t *TrackedConn) Overwrites()int64
func (*TrackedConn)SendUpdates¶added inv0.23.1
func (t *TrackedConn) SendUpdates()
SendUpdates reads node updates and writes them to the connection. Ends when writes hit an error or context iscanceled.
func (*TrackedConn)Stats¶added inv0.26.2
func (t *TrackedConn) Stats() (start, lastWriteint64)
func (*TrackedConn)UniqueID¶added inv0.26.2
func (t *TrackedConn) UniqueID()uuid.UUID
Directories¶
Path | Synopsis |
---|---|
Package tailnettest is a generated GoMock package. | Package tailnettest is a generated GoMock package. |