tunnel

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 13 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 tunnel manages process-local SSH forwards independently of MCP calls.

Index

Constants

View Source
const (
	DefaultTTL      = time.Hour
	MaxTTL          = 24 * time.Hour
	MaxActive       = 16
	MaxRecords      = 1024
	ConnectionLimit = 64
	Retention       = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New

func New(ctx context.Context, run Runner, observe Observer) *Manager

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, s Spec, operationID string) (Status, error)

Create waits only for startup. After ready commits, cancellation of the creating call cannot stop the tunnel. Lost responses can be recovered by ID.

func (*Manager) List

func (m *Manager) List(nodeID, state string) []Status

func (*Manager) Retry

func (m *Manager) Retry(s Spec) (Status, bool, error)

Retry returns the existing state without repeating authorization or network side effects. A subsequent Create performs the same check atomically.

func (*Manager) Shutdown

func (m *Manager) Shutdown(ctx context.Context) error

Shutdown cancels all tasks before joining any one, so a blackholed jump cannot keep another tunnel alive while its cleanup is awaited.

func (*Manager) Status

func (m *Manager) Status(id string) (Status, error)

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context, id string) (Status, error)

type Observer

type Observer func(Status, string, error) error

type Runner

type Runner func(ctx context.Context, spec Spec, ready func(string) bool, report func(error)) error

Runner owns and joins all network resources before returning. It must obey ctx during both startup and serving. ready commits startup only when it returns true; report records recoverable connection-level failures.

type Spec

type Spec struct {
	RequestID  string `json:"requestID"`
	NodeID     string `json:"nodeID"`
	Mode       string `json:"mode"`
	ListenHost string `json:"listenHost"`
	ListenPort int    `json:"listenPort"`
	TargetHost string `json:"targetHost"`
	TargetPort int    `json:"targetPort"`
	TTLSeconds int    `json:"ttlSeconds"`
}

Spec is an immutable, normalized request. A request ID is unique for the lifetime of its retained record, including after the tunnel has stopped.

func Normalize

func Normalize(s Spec) (Spec, error)

Normalize validates before authorization or any network activity. Listen hosts are literals so exposure classification cannot be changed by DNS.

func (Spec) ListenAddress

func (s Spec) ListenAddress() string

func (Spec) TargetAddress

func (s Spec) TargetAddress() string

type Status

type Status struct {
	Spec
	TunnelID            string    `json:"tunnelID"`
	OperationID         string    `json:"operationID"`
	State               string    `json:"state"`
	ListenAddress       string    `json:"listenAddress,omitempty"`
	ListenScope         string    `json:"listenScope"`
	TargetScope         string    `json:"targetScope"`
	CreatedAt           time.Time `json:"createdAt"`
	ExpiresAt           time.Time `json:"expiresAt,omitempty"`
	FinishedAt          time.Time `json:"finishedAt,omitempty"`
	Error               string    `json:"error,omitempty"`
	LastConnectionError string    `json:"lastConnectionError,omitempty"`
	AuditError          string    `json:"auditError,omitempty"`
	RemoteRelease       string    `json:"remoteRelease,omitempty"`
}

Status is a value snapshot; callers never receive mutable task internals.

Jump to

Keyboard shortcuts

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