Documentation
¶
Overview ¶
Package services implements Roost's emulated network services (HTTP, HTTPS, DNS, SSH, dashboard) over a shared device.State.
Index ¶
- Variables
- func NewDNSHandler(st *device.State, answerIP string) dns.Handler
- func NewDashboard(st *device.State, indexHTML []byte) http.Handler
- func NewHandler(st *device.State, service string) http.Handler
- func SelectCertificate(certDir, domain string) (tls.Certificate, string, error)
- func StartDNS(st *device.State, addr, answerIP string) (*dns.Server, error)
- func StartSSH(st *device.State, addr, user, pass, hostKeyPath string, shellProto Shell) error
- type Shell
Constants ¶
This section is empty.
Variables ¶
var Version = "0.1.0"
Version is the roost release, surfaced by the `version`/`ver` commands and the CLI. Override at build time with:
go build -ldflags "-X github.com/stevenssparks/roost/services.Version=1.2.3"
Functions ¶
func NewDNSHandler ¶
NewDNSHandler answers every A/ANY query for any name with answerIP (TTL 30) and records the lookup, mirroring the board's wildcard DNS funnel.
func NewDashboard ¶
NewDashboard serves the live console. indexHTML is the embedded dashboard page (passed in so this package stays free of embed wiring).
func NewHandler ¶
NewHandler builds the shared router used by both HTTP and HTTPS. service is "HTTP" or "HTTPS" and tags every logged hit.
func SelectCertificate ¶
func SelectCertificate(certDir, domain string) (tls.Certificate, string, error)
SelectCertificate returns the image's real cert if certDir holds a valid fullchain.pem + privkey.pem (source "real"); otherwise a freshly generated self-signed cert for domain (source "self-signed"). It only errors if generating the fallback itself fails. An empty certDir always falls back.
func StartDNS ¶
StartDNS starts a UDP DNS server on addr and returns once it is bound. The caller keeps the server for shutdown.
func StartSSH ¶
StartSSH runs the gliderlabs SSH server (blocking; run it in a goroutine). shellProto carries the image identity (prompt/ssid/title/hostname/extended); each session gets a copy bound to st. The session is driven as a raw interactive terminal so it works with a real `ssh` client (PTY, CR line endings, local echo).
Types ¶
type Shell ¶
type Shell struct {
St *device.State
Extended bool
Prompt string
SSID string
Title string
Hostname string
User string
Motd string // optional login message-of-the-day (from the image manifest)
DNSAnswer string // the IP the DNS service funnels every name to
// contains filtered or unexported fields
}
Shell is the device mini-shell. Its identity (prompt, ssid, title, hostname, user) comes from the image manifest so the same binary can present as "friendlyportal#" or "roost#".
func (*Shell) Banner ¶
Banner is the login MOTD shown on SSH connect: a unix-style welcome with live system stats. Uses \n line endings; the SSH transport converts to \r\n on PTYs.
func (*Shell) Complete ¶
Complete returns a possibly-extended version of line for tab completion, plus a list of candidates to display when the completion is ambiguous with no further progress. The returned line always has the input as a prefix (tab only extends), so the SSH transport can just echo the added characters.