Documentation
¶
Overview ¶
Package serve runs 012 as an SSH server: each session gets its own spreadsheet over its own terminal, confined to one directory.
It is built for one person reaching their own files from elsewhere, not for sharing: public-key auth against an authorized_keys file only, on the loopback address unless told otherwise, with no port forwarding, no subsystems, and no commands: an exec request is only ever a file name to open. See docs/terminal/ssh.md.
Index ¶
Constants ¶
const ( DefaultListen = "127.0.0.1:2312" DefaultIdleTimeout = 30 * time.Minute DefaultMaxSessions = 8 )
Default values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
// Log gets a line per login, rejection and session, besides the
// telemetry events; nil discards them.
Log *slog.Logger
// JEV answers JEV functions, with a cache per session; nil turns them
// off.
JEV jev.Client
}
Deps are what a Server takes from its surroundings rather than its options.
type Options ¶
type Options struct {
// Dir is the served directory: sessions open, save, import and
// download only inside it.
Dir string
// Listen is the TCP address to listen on.
Listen string
// AuthorizedKeys is the file of public keys allowed to connect, in
// OpenSSH's authorized_keys format. It is read again on every login.
AuthorizedKeys string
// HostKey is the server's private key file, an ed25519 key generated
// there (0600, in a 0700 directory) when missing.
HostKey string
// IdleTimeout ends a session that has had no input for this long; 0
// never does.
IdleTimeout time.Duration
// MaxSessions is how many sessions may run at once; more are turned
// away.
MaxSessions int
}
Options are 012 serve's settings, one field per flag. Defaults gives their default values; cmd/012 parses flags into them.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves 012 sessions over SSH.
func New ¶
New checks o and prepares a server: the served directory, the host key (generated if missing) and the authorized keys must be usable.
func (*Server) Close ¶
Close stops the server and drops every connection at once. Sessions still keep their unsaved work, for up to closeWait.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the options' address and serves until Shutdown or Close.