Help us shape the future of Go! Take the 2026 Go Developer Survey

transport

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package transport provides the byte-stream bindings AWP runs over (SPEC.md section 4): tailcat, embedded as a library, plus plain TCP and Unix sockets for Fly 6PN, local use and tests.

Index

Constants

View Source
const (
	KindTailcat = "tailcat"
	KindTCP     = "tcp"
	KindUnix    = "unix"
)

Kinds of address.

View Source
const TailcatPort = 1

TailcatPort is the port awp listens on inside the tailcat tunnel. It is the port tailcat's own pipe mode uses, so `tailcat <addr>` connects a terminal straight to an awp peer: you can type NDJSON at it.

Variables

This section is empty.

Functions

func Listen

func Listen(a Addr) (net.Listener, error)

Listen opens a listener for a TCP or Unix address. A stale Unix socket file is removed first.

Types

type Addr

type Addr struct {
	Kind   string
	Target string // tailcat address, host:port or socket path
}

Addr is a parsed awp address.

func Parse

func Parse(s string) (Addr, error)

Parse accepts:

tc...                 a bare tailcat address, as `tailcat` prints it
tailcat:tc...
tcp:host:port         or tcp://host:port
unix:/path            or unix:///path

func (Addr) String

func (a Addr) String() string

String returns the canonical form: "tailcat:tc...", "tcp:host:port" or "unix:/path".

type TailcatListener

type TailcatListener struct {
	net.Listener
	// contains filtered or unexported fields
}

TailcatListener is an awp listener inside a tailcat tunnel.

func ListenTailcat

func ListenTailcat(ctx context.Context, keyFile string, logf logger.Logf) (*TailcatListener, error)

ListenTailcat starts a tailcat server whose key, pre-shared key and DERP region persist in keyFile, so the address stays the same across restarts (a sandbox waking from sleep comes back at the address its peers know). The first run picks the nearest region and writes the file.

func (*TailcatListener) Address

func (l *TailcatListener) Address() string

Address returns the listener's shareable tailcat address.

func (*TailcatListener) Close

func (l *TailcatListener) Close() error

Close stops the listener and the tailcat server.

type Transport

type Transport struct {
	// Logf receives tailcat's diagnostics. Nil discards them.
	Logf logger.Logf

	// AllowPublicTCP permits plain TCP to public addresses. By default
	// awp refuses, as section 4.2 asks: plain TCP has no encryption, so
	// it is only for loopback and private networks such as Fly's 6PN.
	AllowPublicTCP bool
	// contains filtered or unexported fields
}

Transport dials awp addresses. It keeps one tailcat client per tailcat address, since each client is a whole userspace WireGuard node.

func (*Transport) Close

func (t *Transport) Close()

Close shuts down all tailcat clients.

func (*Transport) Dial

func (t *Transport) Dial(ctx context.Context, a Addr) (net.Conn, error)

Dial opens a byte stream to a.

func (*Transport) Reset

func (t *Transport) Reset(a Addr)

Reset drops the cached tailcat client for a, so the next dial starts from a fresh WireGuard node. Used after repeated failures, and when the peer at that address is no longer wanted.

Jump to

Keyboard shortcuts

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