modedetect

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modedetect suggests where this instance runs, from local facts only.

Index

Constants

View Source
const (
	ModeLaptop    = "laptop"
	ModeHomelab   = "homelab"
	ModeVPSSingle = "vps-single"
	ModeVPSMulti  = "vps-multi"
	ModeTeamK8s   = "team-k8s"
	ModeIaC       = "iac"
)

Modes mirrors UI_MODES in web/src/lib/uiMode.ts.

View Source
const (
	High   = "high"
	Medium = "medium"
	Low    = "low"
)

Confidence levels. Low never carries a mode.

View Source
const (
	ReasonManagedVM       = "managed_vm"
	ReasonLocalMode       = "local_mode"
	ReasonKubernetes      = "kubernetes"
	ReasonGitSync         = "git_sync"
	ReasonSeveralPublic   = "several_public"
	ReasonSeveralHome     = "several_home"
	ReasonOnePublic       = "one_public"
	ReasonOneCloud        = "one_cloud"
	ReasonOneHome         = "one_home"
	ReasonNotEnoughSignal = "unsure"
)

Reason codes, translated by the dashboard.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facts

type Facts struct {
	ManagedVM bool
	LocalMode bool
	// Agents is the number of joined servers besides the control plane host.
	Agents      int
	K8sClusters int
	GitSyncs    int
	// PublicIPv4 is true when an interface holds a public IPv4 address.
	PublicIPv4 bool
	// HomeLAN is true when every private IPv4 address is in 192.168.0.0/16.
	HomeLAN bool
	// CloudHost is true when the machine's own firmware names a cloud provider.
	CloudHost bool
}

Facts are what the server can see without asking anything outside itself.

func (*Facts) Firmware

func (f *Facts) Firmware(read func(string) ([]byte, error))

Firmware fills CloudHost from the DMI files, read with read (nil means os.ReadFile).

func (*Facts) Network

func (f *Facts) Network(ifaces []Interface)

Network fills the address facts. Only IPv4 counts: home machines often hold public IPv6.

type Interface

type Interface struct {
	Name  string
	Addrs []netip.Addr
}

Interface is one network interface name with its addresses.

func HostInterfaces

func HostInterfaces() []Interface

HostInterfaces reads the local interface table.

type Suggestion

type Suggestion struct {
	Mode       string
	Confidence string
	Code       string
	Reason     string
}

Suggestion is a mode guess. An empty Mode means nothing should be preselected.

func Detect

func Detect(f Facts) Suggestion

Detect ranks the facts: what the instance is, then how it is used, then its network.

Jump to

Keyboard shortcuts

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