attach

package
v0.2.64 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MPL-2.0 Imports: 11 Imported by: ? 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 attach is the chassis head a machine dials with `txco attach` (chassis/attached): three public HTTP routes.

POST /v1/attach/code     what a one-use code is for, without spending it
POST /v1/attach/enroll   spend the code and enroll the key that signed
GET  /v1/attach          the link, a WebSocket carrying yamux streams

OFF by default: `attach` must appear in `--personalities`. It is then served ONE of two ways:

  • ON THE WEB HEAD, with no port of its own, when --attach-public-url names a host and --attach-listen-addrs is empty. The web head hands every request for exactly that hostname to this head (MountHost, as the ipp head is mounted) and no stack ever sees one. This is how a fleet runs it: one more hostname at the edge, nothing else.
  • ON A LISTENER OF ITS OWN, when --attach-listen-addrs is set. For a chassis that wants the head apart from its web head, and for `txco dev --attach`, where every stack shares the hostname localhost.

The routes authenticate their own callers (a code, then a key), so the head is meant to be reached from the internet, behind the same edge as every other host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchHost added in v0.2.64

func MatchHost(mounted string) func(host string) bool

MatchHost returns the predicate the web head runs on every request's Host header: exactly the mounted hostname, whatever port the header names. A pure comparison, no lookups.

Types

type Controller

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

Controller owns the attach listeners.

func NewController

func NewController(ctx context.Context, pu *processor.Unit, svc *attached.Service) *Controller

NewController constructs (but does not start) the head. svc is nil on a chassis that serves no attached workspaces; the head then stays off.

func (*Controller) Addrs

func (c *Controller) Addrs() []string

Addrs returns the addresses the listeners are bound to (":0" resolved).

func (*Controller) Handler added in v0.2.64

func (c *Controller) Handler() http.Handler

Handler is the head's three routes, for the web head to mount or for a listener of its own to serve.

func (*Controller) MountHost added in v0.2.64

func (c *Controller) MountHost() string

MountHost is the hostname the web head should hand to this head, or "" when the head is off or has a listener of its own. It is the host of --attach-public-url, without a port: the name machines dial.

func (*Controller) Start

func (c *Controller) Start()

Start binds the head's own listeners, when it has any. Mounted on the web head there is nothing to bind: the web head is already serving it.

func (*Controller) Stop

func (c *Controller) Stop()

Stop closes the listeners and every link. A machine told `shutdown` dials again, to whichever node answers.

Jump to

Keyboard shortcuts

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