wslboot

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func EnsureDaemon(ctx context.Context, cfg Config) error

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 Healthy

func Healthy(ctx context.Context, endpoint, token string) bool

Healthy reports whether a daemon answers (and authenticates) at endpoint.

func Launch

func Launch(cfg Config) error

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

func LoadDaemonFile(path string) (token, endpoint string, err error)

LoadDaemonFile reads the token and endpoint persisted at path. A missing file returns empty strings and a nil error.

func LoadOrCreateToken

func LoadOrCreateToken(path string) (string, error)

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

func SaveDaemonFile(path, token, endpoint string) error

SaveDaemonFile persists the daemon's token and endpoint to path (mode 0600) so every client run reaches the same daemon with the same secret.

func Stop

func Stop(distro, user string) error

Stop terminates the jerboad daemon running inside the WSL2 distro. distro empty targets the default distro; user (e.g. "root") selects the wsl user that can signal it. Returns ErrNoDaemon when nothing matched.

func WaitHealthy

func WaitHealthy(ctx context.Context, cfg Config) error

WaitHealthy polls cfg.Endpoint until the daemon answers or the timeout fires.

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.

Jump to

Keyboard shortcuts

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