Documentation
¶
Overview ¶
Package wslboot bootstraps the jerboad daemon inside WSL2 from the Windows client. The daemon always runs on Linux; on Windows jerboa.exe is a thin client that health-checks a loopback TCP endpoint and, if nothing answers, launches jerboad inside a WSL2 distribution and waits for it to come up.
Index ¶
- Variables
- func EnsureDaemon(ctx context.Context, cfg Config) error
- func Healthy(ctx context.Context, endpoint, token string) bool
- func Launch(cfg Config) error
- func LoadDaemonFile(path string) (token, endpoint string, err error)
- func LoadOrCreateToken(path string) (string, error)
- func SaveDaemonFile(path, token, endpoint string) error
- func Stop(distro, user string) error
- func WaitHealthy(ctx context.Context, cfg Config) error
- type Config
Constants ¶
This section is empty.
Variables ¶
var ErrNoDaemon = errors.New("no running daemon found")
ErrNoDaemon reports that no running daemon was found to act on (e.g. by Stop).
Functions ¶
func EnsureDaemon ¶
EnsureDaemon returns nil once the daemon is reachable. If it is not already answering, the daemon is started inside WSL2 and EnsureDaemon waits for it.
func Launch ¶
Launch starts jerboad inside WSL2 detached, per cfg, without first checking whether one is already running. Exposed for `jerboa daemon start`; EnsureDaemon uses the same machinery for auto-boot.
func LoadDaemonFile ¶
LoadDaemonFile reads the token and endpoint persisted at path. A missing file returns empty strings and a nil error.
func LoadOrCreateToken ¶
LoadOrCreateToken returns the token stored at path, generating and persisting a new random token (file mode 0600) if the file does not exist yet. The client owns this secret and hands it to the daemon at launch.
func SaveDaemonFile ¶
SaveDaemonFile persists the daemon's token and endpoint to path (mode 0600) so every client run reaches the same daemon with the same secret.
Types ¶
type Config ¶
type Config struct {
// Endpoint is the address the client dials, e.g. tcp://127.0.0.1:7890.
Endpoint string
// ListenEndpoint is the --host value the daemon binds. Empty reuses Endpoint.
// Used to bind 0.0.0.0 inside a dedicated distro while the client dials
// loopback across the WSL2 boundary.
ListenEndpoint string
// Distro is the WSL2 distribution name. Empty uses the WSL default distro.
Distro string
// User is the Linux user to run jerboad as inside the distro (wsl -u). Empty
// uses the distro's default user. "root" runs privileged without host sudo.
User string
// Token is the shared secret passed to the daemon (via the environment, not
// argv) and used by the client handshake. Empty disables authentication.
Token string
// JerboadPath is the jerboad binary path inside WSL. Empty resolves "jerboad"
// on the distro's PATH.
JerboadPath string
// Hypervisor, when non-empty, is passed to jerboad as --hypervisor (e.g.
// "firecracker"). Empty leaves the daemon's own default.
Hypervisor string
// Sudo runs jerboad under sudo inside the distro. Required for hypervisors
// that need privileges (firecracker networking). The token is forwarded with
// sudo --preserve-env so it never appears on the command line.
Sudo bool
// HealthTimeout bounds how long to wait for a freshly launched daemon to
// answer. Zero defaults to 20s.
HealthTimeout time.Duration
}
Config describes how to reach and, if needed, launch the daemon.