guest

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package guest holds the files and helpers that run inside the managed VM: the egress firewall baseline, the isolation self-check and the provisioning script.

Index

Constants

View Source
const (
	StatusPath      = "/var/lib/levelrail/isolation-status.json"
	EgressRulesPath = "/etc/levelrail/lr-egress.nft"
	CheckScriptPath = "/usr/local/sbin/lr-isolation-check"
	IsolationUnit   = "lr-isolation.service"
	CheckUnit       = "lr-isolation-check.service"
)

Guest paths the host side (status reads, S2 and S4) relies on.

View Source
const (

	// One constant for the firewall and the control plane unit so they cannot drift:
	// a /15 beside the bridge and the daemon pool, about 500 app networks.
	DefaultAppNetworkPool = "172.30.0.0/15"
)

Defaults block: the only place guest network numbers live.

Variables

This section is empty.

Functions

func EgressRules

func EgressRules(o Options) (string, error)

EgressRules renders the nftables baseline.

func ProvisionScript

func ProvisionScript(o Options, sc Sidecar) (string, error)

ProvisionScript returns one root shell script: files first, then the firewall, then Docker (so Docker can only start behind the baseline), then the sidecar.

func UserData

func UserData(o Options, sc Sidecar) (string, error)

UserData renders the same baseline as cloud-init user-data, for images that boot without Lima (marketplace images, the WSL slice).

Types

type Check

type Check struct {
	Name   string `json:"name"`
	Result string `json:"result"`
	Detail string `json:"detail"`
}

Check is one line of the guest self-check result.

type File

type File struct {
	Path    string
	Mode    string
	Content string
}

File is one guest file to write.

func Files

func Files(o Options, sc Sidecar) ([]File, error)

Files returns every guest file in write order, sidecar unit last.

type Options

type Options struct {
	HostGateway     string   // Lima host address as seen from the guest, always dropped.
	DNSServers      []string // Resolvers that may be reached on port 53 despite the drops.
	DockerPool      string   // The only 172.16/12 slice containers may talk to.
	DockerBridge    string   // docker0 address, inside DockerPool.
	DockerPoolBase  string   // User network pool, inside DockerPool.
	AppNetworkPool  string   // Control plane per-app network block, inside DockerPool and clear of the bridge and pool base.
	PublishIP       string   // Default bind address for published ports.
	LANProbe        string   // Address the self-check expects to be unreachable.
	ProbeTimeoutSec int
	ExpectedShares  int // Read-only host mounts the self-check should find.
}

Options tunes the guest baseline. Zero value is invalid, use DefaultOptions.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the ADR baseline.

func (Options) Validate

func (o Options) Validate() error

Validate rejects values that could break out of the rendered files.

type Sidecar

type Sidecar struct {
	BinaryPath  string // Absolute guest path the unit's ExecStart uses.
	UnitName    string // File name under /etc/systemd/system, ends in .service.
	UnitContent string
}

Sidecar is the control plane slot. S2 and S4 supply the binary and unit; when UnitContent is empty the step is skipped.

func (Sidecar) Validate

func (s Sidecar) Validate() error

Validate checks the sidecar slot.

type Status

type Status struct {
	Result    string  `json:"result"`
	BootID    string  `json:"boot_id"`
	CheckedAt string  `json:"checked_at"`
	Checks    []Check `json:"checks"`
}

Status is the parsed self-check file.

func ParseStatus

func ParseStatus(raw []byte, bootID string) (Status, error)

ParseStatus parses the file read from StatusPath and requires it to belong to the current boot (bootID is /proc/sys/kernel/random/boot_id read over limactl). It only catches stale files: root inside the guest can write any status.

func (Status) Passed

func (s Status) Passed() bool

Passed is true only when every check passed.

Jump to

Keyboard shortcuts

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