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 ¶
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 ¶
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.