peerhosts

package
v0.14.3-dev Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package peerhosts caches the list of paired outpost hostnames as returned by cloudbox's /api/v1/ssh/hosts endpoint. It is consumed by the SSH server's `direct-tcpip` allowlist so `ssh -J peerA peerB` works between paired hosts without widening trust to arbitrary destinations.

The registry refreshes on a TTL (default 5 min). On cloudbox-side failure it serves the last good snapshot rather than denying — the trust model still rests on (1) the inner SSH handshake's OS-password gate and (2) the loopback-only fallback when no snapshot is available at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServerAddr  string
	ServerPort  int
	Protocol    string
	Token       string
	TTL         time.Duration
	HTTPTimeout time.Duration
}

Config is the dial information the registry uses to query cloudbox. Token is the per-user access_token cloudbox issued at register time (fc.AccessToken). An empty Token disables the registry — it will answer false to every IsPeer query, which keeps the loopback-only posture for unpaired outposts.

type Registry

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

Registry holds a cached set of peer hostnames. Safe for concurrent use. Zero-value Registry is a no-op (IsPeer always false) so callers that don't yet have an AccessToken can pass nil or the zero value safely.

func New

func New(cfg Config) *Registry

New returns a Registry configured for cfg. An empty cfg.Token yields a no-op registry (IsPeer always false) — useful for unpaired outposts.

func (*Registry) IsPeer

func (r *Registry) IsPeer(ctx context.Context, host string) bool

IsPeer reports whether host is a paired outpost in this account. Refreshes the cached list when older than TTL; on refresh failure keeps serving the last good snapshot. Returns false when no snapshot has ever loaded successfully (initial cloudbox outage) — the caller's loopback-only fallback covers that case.

func (*Registry) Refresh

func (r *Registry) Refresh(ctx context.Context) error

Refresh forces a cache refresh. Returned error is for callers that want to surface cloudbox-side trouble (e.g. an admin probe); the normal IsPeer caller doesn't care.

Jump to

Keyboard shortcuts

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