sshhost

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr            string        // ":2222"
	HostKeyPath     string        // path to ed25519 host key (auto-created if missing)
	APIBase         string        // override https://api.kyc.rip
	APIKey          string        // optional X-API-Key
	MaxSessions     int           // global cap (default 200)
	MaxPerIP        int           // per-source-IP cap (default 3)
	IdleTimeout     time.Duration // session idle timeout (default 90s)
	HandshakeWindow time.Duration // hard cap on time-to-PTY (default 8s)
	Banner          string        // pre-PTY banner text
}

Config controls listener and runtime caps.

func (*Config) Defaults

func (c *Config) Defaults()

Defaults applies sensible POC defaults to zero-valued fields.

type HealthSnapshot

type HealthSnapshot struct {
	OK           bool   `json:"ok"`
	Version      string `json:"version,omitempty"`
	UptimeSec    int64  `json:"uptime_sec"`
	Active       int64  `json:"active_sessions"`
	TotalConns   int64  `json:"total_conns"`
	RejectedPty  int64  `json:"rejected_pty_or_exec"`
	RejectedCaps int64  `json:"rejected_caps"`
	Fingerprint  string `json:"host_key_fingerprint,omitempty"`
}

HealthSnapshot is the JSON shape returned by the /healthz and /metrics endpoints. Stable enough to point monitoring at.

type Server

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

Server wraps a gliderlabs/ssh server with hard caps.

func New

func New(cfg Config, logger *log.Logger) (*Server, error)

func (*Server) Fingerprint

func (s *Server) Fingerprint() string

Fingerprint returns the SHA256 fingerprint of the host key.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe blocks until ctx is cancelled.

func (*Server) ServeHealth

func (s *Server) ServeHealth(ctx context.Context, addr string) error

ServeHealth runs an HTTP listener with /healthz and /metrics. Intended for loopback only (e.g. 127.0.0.1:9090). Returns when ctx is cancelled or ListenAndServe fails. Logs but does not panic.

func (*Server) Snapshot

func (s *Server) Snapshot() HealthSnapshot

Snapshot returns the current health state. Safe to call concurrently.

Jump to

Keyboard shortcuts

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