2.3 KiB
2.3 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| server/serve-loop | Implement server accept loop, graceful shutdown, and ServeOptions config | pending |
|
moderate | medium | component | implementation |
Description
Implement the server's main accept loop and configuration. This ties together the transport acceptor, server handler, rate limiting, and logging into a coherent server process.
ServeOptions is the programmatic configuration struct (ADR-011) for the server. The accept loop:
- Binds a
TransportAcceptorbased on transport mode - Accepts incoming connections (respecting rate limits)
- Creates a
ServerHandlerper connection - Passes the stream to
russh::server::run_stream() - Handles graceful shutdown on SIGTERM/SIGINT
Acceptance Criteria
crates/wraith-core/src/server/mod.rsre-exports all server componentsServeOptionsstruct with fields matching server.md CLI interface:key,authorized_keys,cert_authority,transport_mode,listen_addr,tls_cert,tls_key,acme_domain,stealth,proxy,iroh_relay,max_connections_per_ip,max_auth_attemptsServer::new(opts: ServeOptions) -> Result<Server>— creates server with bound acceptor, auth config, rate limiterServer::run()— enters accept loop, for each connection: check rate limit → create handler →run_stream()- Stealth mode integration: if enabled, protocol detection before
run_stream() - Graceful shutdown:
Server::shutdown()method and signal handler (SIGTERM/SIGINT)- Stop accepting new connections
- Send SSH disconnect to active sessions
- Wait for drain timeout (~2 seconds per session)
- Forcibly terminate remaining connections
- iroh mode: prints endpoint ID on startup
ServeOptions::keyandServeOptions::authorized_keysacceptKeySource(file or in-memory)- Integration test: start server, client connects via mock transport, session works, shutdown completes
References
- docs/architecture/server.md — full server spec including graceful shutdown
- docs/architecture/decisions/011-no-ssh-config-programmatic-api.md — ServeOptions programmatic struct
Notes
To be filled by implementation agent
Summary
To be filled on completion