host

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocatorSettingsKey = "daemon.locatorSettings"
	WireguardConfigKey = "daemon.wireguard"
)
View Source
const (
	ComputeMeasurementDuration = 1 * time.Second
)
View Source
const (
	DefaultFileMode = 0600
)

Variables

This section is empty.

Functions

func AddWireguardInterface added in v0.0.25

func AddWireguardInterface(ctx context.Context, logger chassis.Logger, def *v1.AddWireguardInterface) error

func AddWireguardPeer added in v0.0.28

func AddWireguardPeer(ctx context.Context, logger chassis.Logger, peer *v1.WireguardPeer) error

func BootConfigFile added in v0.0.25

func BootConfigFile() string

func ChangeDaemonVersion added in v0.0.24

func ChangeDaemonVersion(ctx context.Context, logger chassis.Logger, def *v1.ChangeDaemonVersionCommand) error

TODO-RC2: There's a bit of a race condition with this right now. If you call GetOSVersionDiff and then call this method you'll accidentally upgrade the entire OS with any changes that were pulled in from the `nix-channel --update` that was run during GetOSVersionDiff. This can be avoided by running `nix-channel --rollback` but will require some stateful logic which checks if a rollback is really needed. It's out of scope for RC1 but should be revisited later.

func ChunkPath added in v0.0.24

func ChunkPath() string

func ConfigFile added in v0.0.24

func ConfigFile() string

func DaemonLogs added in v0.0.33

func DaemonLogs(ctx context.Context, logger chassis.Logger, sinceSeconds uint32) ([]*v1.Log, error)

func DaemonNixFile added in v0.0.24

func DaemonNixFile() string

func DataPath added in v0.0.28

func DataPath() string

func DraftManifestFile added in v0.0.24

func DraftManifestFile() string

func FilePath added in v0.0.24

func FilePath(paths ...string) string

FilePath cleans the given path and makes it a local path by prefixing a "./tmp/" if the draft env is "test".

func GetDaemonVersion added in v0.0.24

func GetDaemonVersion(logger chassis.Logger) (*v1.CurrentDaemonVersion, error)

func GetNixOSVersion added in v0.0.30

func GetNixOSVersion(ctx context.Context, logger chassis.Logger) (string, error)

func GetOSVersionDiff added in v0.0.24

func GetOSVersionDiff(ctx context.Context, logger chassis.Logger) (string, error)

func LineByLineReplace added in v0.0.24

func LineByLineReplace(filename string, replacers []Replacer) error

LineByLineReplace will process all lines in the given file running all Replacers against each line.

NOTE: the Replacers will be run in the order they appear in the slice

func MigrationsFile added in v0.0.24

func MigrationsFile() string

func NetworkingConfigFile added in v0.0.25

func NetworkingConfigFile() string

func NixosConfigFile added in v0.0.24

func NixosConfigFile() string

func NixosConfigsPath added in v0.0.25

func NixosConfigsPath() string

func NixosVarsFile added in v0.0.25

func NixosVarsFile() string

func OperatorManifestFile added in v0.0.24

func OperatorManifestFile() string

func RebuildAndSwitchOS added in v0.0.24

func RebuildAndSwitchOS(ctx context.Context, logger chassis.Logger) error

NOTE: must call this after calling GetOSVersionDiff if you want to perform a channel update.

func RemoveWireguardInterface added in v0.0.25

func RemoveWireguardInterface(ctx context.Context, logger chassis.Logger, def *v1.RemoveWireguardInterface) error

func SaveSettings added in v0.0.24

func SaveSettings(ctx context.Context, logger chassis.Logger, def *v1.SaveSettingsCommand) error

func SecurityConfigFile added in v0.0.25

func SecurityConfigFile() string

func ServerManifestFile added in v0.0.24

func ServerManifestFile() string

func ServicesConfigFile added in v0.0.25

func ServicesConfigFile() string

func SetSystemImage added in v0.0.24

func SetSystemImage(ctx context.Context, logger chassis.Logger, def *v1.SetSystemImageCommand) error

func SystemStats added in v0.0.10

func SystemStats(mounts []string) (*v1.SystemStats, error)

func TimeConfigFile added in v0.0.25

func TimeConfigFile() string

func UsersConfigFile added in v0.0.25

func UsersConfigFile() string

func WireguardKeyPath added in v0.0.25

func WireguardKeyPath() string

func WriteJsonFile added in v0.0.25

func WriteJsonFile(path string, config any, perm fs.FileMode) error

Types

type BootConfig added in v0.0.25

type BootConfig struct {
	Loader BootConfigLoader `json:"loader"`
	BCache BootConfigBCache `json:"bcache"`
}

type BootConfigBCache added in v0.0.25

type BootConfigBCache struct {
	Enable bool `json:"enable"`
}

type BootConfigLoader added in v0.0.25

type BootConfigLoader struct {
	SystemdBoot BootConfigLoaderSystemdBoot `json:"systemd-boot"`
}

type BootConfigLoaderSystemdBoot added in v0.0.25

type BootConfigLoaderSystemdBoot struct {
	Enable bool `json:"enable"`
}

type DNSPublisher added in v0.0.16

type DNSPublisher interface {
	AddHost(ctx context.Context, hostname string)
	RemoveHost(hostname string) error
	Start()
}

func NewDNSPublisher added in v0.0.16

func NewDNSPublisher(logger chassis.Logger) DNSPublisher

type LocatorController added in v0.0.28

type LocatorController interface {
	// Load will load all saved Locators from the config and create background connections to them.
	// Meant to be called at daemon startup.
	Load()
	// AddLocator will start a background connection to the given Locator and will serve up connection
	// information to locate requests from that Locator for all Wireguard interfaces. The Locator connection
	// can be killed by calling RemoveLocator or RemoveAll.
	AddLocator(ctx context.Context, locatorAddress string) (locator *dv1.Locator, err error)
	// RemoveLocator will remove a background Locator connection that was started through Load or
	// AddLocator and will delete it from the config.
	RemoveLocator(ctx context.Context, locatorAddress string) error
	// Disable will remove all background Locator connections and delete them from the config.
	Disable(ctx context.Context) error
}

func NewLocatorController added in v0.0.28

func NewLocatorController(logger chassis.Logger, stun STUNClient) LocatorController

type Migrator added in v0.0.24

type Migrator interface {
	Migrate()
}

func NewMigrator added in v0.0.24

func NewMigrator(logger chassis.Logger) Migrator

type NetworkingConfig added in v0.0.25

type NetworkingConfig struct {
	Hostname       string                         `json:"hostName"`
	Domain         string                         `json:"domain"`
	NetworkManager NetworkingConfigNetworkManager `json:"networkmanager"`
	Wireless       NetworkingConfigWireless       `json:"wireless"`
	Firewall       NetworkingConfigFirewall       `json:"firewall"`
	NAT            NetworkingConfigNAT            `json:"nat"`
	Wireguard      NetworkingConfigWireguard      `json:"wireguard"`
}

type NetworkingConfigFirewall added in v0.0.25

type NetworkingConfigFirewall struct {
	Enable bool `json:"enable"`
}

type NetworkingConfigNAT added in v0.0.25

type NetworkingConfigNAT struct {
	Enable             bool     `json:"enable"`
	ExternalInterface  string   `json:"externalInterface,omitempty"`
	InternalInterfaces []string `json:"internalInterfaces,omitempty"`
}

type NetworkingConfigNetworkManager added in v0.0.25

type NetworkingConfigNetworkManager struct {
	Enable bool `json:"enable"`
}

type NetworkingConfigWireguard added in v0.0.25

type NetworkingConfigWireguard struct {
	Interfaces map[string]WireguardInterface `json:"interfaces,omitempty"`
}

type NetworkingConfigWireless added in v0.0.25

type NetworkingConfigWireless struct {
	Enable bool `json:"enable"`
}

type Replacer added in v0.0.24

type Replacer func(line string) string

Replacer take in a line in a file and outputs the replacement line (which could be the same if no change is needed)

type STUNClient added in v0.0.28

type STUNClient interface {
	// Bind restarts the STUN client using the given STUN server
	Bind(server string) (stun.XORMappedAddress, error)
	// Connect initializes a short period of connection attempts to the given STUN address of a peer.
	// This opens a hole in the NAT for inbound connection attempts from the peer.
	Connect(address net.Addr)
}

func NewSTUNClient added in v0.0.28

func NewSTUNClient(logger chassis.Logger) STUNClient

type SecurityConfig added in v0.0.25

type SecurityConfig struct {
	Sudo SecurityConfigSudo `json:"sudo"`
}

type SecurityConfigSudo added in v0.0.25

type SecurityConfigSudo struct {
	WheelNeedsPassword bool `json:"wheelNeedsPassword"`
}

type ServicesConfig added in v0.0.25

type ServicesConfig struct {
	Resolved ServicesConfigResolved `json:"resolved"`
	K3s      ServicesConfigK3s      `json:"k3s"`
	OpenSSH  ServicesConfigOpenSSH  `json:"openssh"`
	Avahi    ServicesConfigAvahi    `json:"avahi"`
}

type ServicesConfigAvahi added in v0.0.25

type ServicesConfigAvahi struct {
	Enable   bool                       `json:"enable"`
	IPv4     bool                       `json:"ipv4"`
	IPv6     bool                       `json:"ipv6"`
	NSSmDNS4 bool                       `json:"nssmdns4"`
	Publish  ServicesConfigAvahiPublish `json:"publish"`
}

type ServicesConfigAvahiPublish added in v0.0.25

type ServicesConfigAvahiPublish struct {
	Enable       bool `json:"enable"`
	Domain       bool `json:"domain"`
	Addresses    bool `json:"addresses"`
	UserServices bool `json:"userServices"`
}

type ServicesConfigK3s added in v0.0.25

type ServicesConfigK3s struct {
	Enable     bool   `json:"enable"`
	Role       string `json:"role"`
	ExtraFlags string `json:"extraFlags"`
}

type ServicesConfigOpenSSH added in v0.0.25

type ServicesConfigOpenSSH struct {
	Enable bool `json:"enable"`
}

type ServicesConfigResolved added in v0.0.25

type ServicesConfigResolved struct {
	Enable  bool     `json:"enable"`
	Domains []string `json:"domains"`
}

type TimeConfig added in v0.0.25

type TimeConfig struct {
	TimeZone string `json:"timeZone"`
}

type User added in v0.0.25

type User struct {
	IsNormalUser bool        `json:"isNormalUser"`
	ExtraGroups  []string    `json:"extraGroups"`
	OpenSSH      UserOpenSSH `json:"openssh"`
}

type UserOpenSSH added in v0.0.25

type UserOpenSSH struct {
	AuthorizedKeys UserOpenSSHAuthorizedKeys `json:"authorizedKeys"`
}

type UserOpenSSHAuthorizedKeys added in v0.0.25

type UserOpenSSHAuthorizedKeys struct {
	Keys []string `json:"keys"`
}

type UsersConfig added in v0.0.25

type UsersConfig struct {
	Users map[string]User `json:"users"`
}

type WireGuardConfig added in v0.0.28

type WireGuardConfig struct {
	Id         string
	PrivateKey wgtypes.Key
	PublicKey  wgtypes.Key
	Peers      []wgtypes.Key
}

type WireguardInterface added in v0.0.25

type WireguardInterface struct {
	IPs            []string        `json:"ips"`
	ListenPort     uint32          `json:"listenPort"`
	PrivateKeyFile string          `json:"privateKeyFile"`
	Peers          []WireguardPeer `json:"peers"`
}

type WireguardPeer added in v0.0.25

type WireguardPeer struct {
	PublicKey  string   `json:"publicKey"`
	AllowedIPs []string `json:"allowedIPs"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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