Documentation
¶
Index ¶
- Constants
- func AddChannel(ctx context.Context, logger chassis.Logger, channel string, name string) error
- func BootConfigFile() string
- func ChangeDaemonVersion(ctx context.Context, logger chassis.Logger, def *v1.ChangeDaemonVersionCommand) error
- func ChunkPath() string
- func ConfigFile() string
- func DaemonLogs(ctx context.Context, logger chassis.Logger, sinceSeconds uint32) ([]*v1.Log, error)
- func DaemonNixFile() string
- func DataPath() string
- func DraftManifestFile() string
- func FilePath(paths ...string) string
- func GatewayAPIManifestFile() string
- func GetDaemonVersion(logger chassis.Logger) (*v1.CurrentDaemonVersion, error)
- func GetNixOSVersion(ctx context.Context, logger chassis.Logger) (string, error)
- func GetOSVersionDiff(ctx context.Context, logger chassis.Logger) (string, error)
- func IstioManifestFile() string
- func KubeClient() *kubernetes.Clientset
- func KubeConfigFile() string
- func LineByLineReplace(filename string, replacers []Replacer) error
- func MigrationsFile() string
- func NetworkingConfigFile() string
- func NixConfigFile() string
- func NixosConfigFile() string
- func NixosConfigsPath() string
- func NixosVarsFile() string
- func OperatorManifestFile() string
- func RebuildAndSwitchOS(ctx context.Context, logger chassis.Logger) error
- func RebuildUpgradeBoot(ctx context.Context, logger chassis.Logger) error
- func SaveSettings(ctx context.Context, logger chassis.Logger, def *v1.SaveSettingsCommand) error
- func SecurityConfigFile() string
- func ServerManifestFile() string
- func ServicesConfigFile() string
- func SetSystemImage(ctx context.Context, logger chassis.Logger, def *v1.SetSystemImageCommand) error
- func SystemStats(mounts []string) (*v1.SystemStats, error)
- func TimeConfigFile() string
- func UpdateChannel(ctx context.Context, logger chassis.Logger) error
- func UsersConfigFile() string
- func WireguardKeyPath() string
- func WriteJsonFile(path string, config any, perm fs.FileMode) error
- type BootConfig
- type BootConfigBCache
- type BootConfigLoader
- type BootConfigLoaderSystemdBoot
- type DNSPublisher
- type LocatorController
- type Migrator
- type NetworkingConfig
- type NetworkingConfigFirewall
- type NetworkingConfigNAT
- type NetworkingConfigNetworkManager
- type NetworkingConfigWireguard
- type NetworkingConfigWireless
- type NixConfig
- type NixConfigGC
- type Replacer
- type STUNController
- type SecureTunnelingController
- type SecurityConfig
- type SecurityConfigSudo
- type ServicesConfig
- type ServicesConfigAvahi
- type ServicesConfigAvahiPublish
- type ServicesConfigK3s
- type ServicesConfigOpenSSH
- type ServicesConfigResolved
- type TimeConfig
- type User
- type UserOpenSSH
- type UserOpenSSHAuthorizedKeys
- type UsersConfig
- type WireGuardConfig
- type WireguardController
- type WireguardInterface
- type WireguardPeer
Constants ¶
const (
ComputeMeasurementDuration = 1 * time.Second
)
const (
DefaultFileMode = 0600
)
const (
SecureTunnelingNotEnabledError = "secure tunneling not enabled"
)
const (
// TODO: change to snake_case
SecureTunnelingSettingsKey = "daemon.secureTunnelingSettings"
)
Variables ¶
This section is empty.
Functions ¶
func AddChannel ¶ added in v0.0.37
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 ConfigFile ¶ added in v0.0.24
func ConfigFile() string
func DaemonLogs ¶ added in v0.0.33
func DaemonNixFile ¶ added in v0.0.24
func DaemonNixFile() string
func DraftManifestFile ¶ added in v0.0.24
func DraftManifestFile() string
func FilePath ¶ added in v0.0.24
FilePath cleans the given path and makes it a local path by prefixing a "./tmp/" if the draft env is "test".
func GatewayAPIManifestFile ¶ added in v0.0.38
func GatewayAPIManifestFile() string
func GetDaemonVersion ¶ added in v0.0.24
func GetDaemonVersion(logger chassis.Logger) (*v1.CurrentDaemonVersion, error)
func GetNixOSVersion ¶ added in v0.0.30
func GetOSVersionDiff ¶ added in v0.0.24
func IstioManifestFile ¶ added in v0.0.38
func IstioManifestFile() string
func KubeClient ¶ added in v0.0.38
func KubeClient() *kubernetes.Clientset
func KubeConfigFile ¶ added in v0.0.38
func KubeConfigFile() string
func LineByLineReplace ¶ added in v0.0.24
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 NixConfigFile ¶ added in v0.0.35
func NixConfigFile() 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
NOTE: must call this after calling GetOSVersionDiff if you want to perform a channel update.
func RebuildUpgradeBoot ¶ added in v0.0.37
NOTE: should reboot after successfully executing this.
func SaveSettings ¶ added in v0.0.24
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 SystemStats ¶ added in v0.0.10
func SystemStats(mounts []string) (*v1.SystemStats, error)
func TimeConfigFile ¶ added in v0.0.25
func TimeConfigFile() string
func UpdateChannel ¶ added in v0.0.37
func UsersConfigFile ¶ added in v0.0.25
func UsersConfigFile() string
func WireguardKeyPath ¶ added in v0.0.25
func WireguardKeyPath() string
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 {
Connect(ctx context.Context, wgInterface *sv1.WireguardInterface, locatorAddress string) error
Close(wgInterface *sv1.WireguardInterface, locatorAddress string)
}
func NewLocatorController ¶ added in v0.0.28
func NewLocatorController(logger chassis.Logger, stunController STUNController) LocatorController
type Migrator ¶ added in v0.0.24
type Migrator interface {
Migrate()
}
func NewMigrator ¶ added in v0.0.24
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 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 NixConfig ¶ added in v0.0.35
type NixConfig struct {
GC NixConfigGC `json:"gc"`
}
type NixConfigGC ¶ added in v0.0.35
type Replacer ¶ added in v0.0.24
Replacer take in a line in a file and outputs the replacement line (which could be the same if no change is needed)
type STUNController ¶ added in v0.0.35
type STUNController interface {
// Bind creates a persistent connection to the given STUN server from the given port. All data received on this port will
// be multiplexed between the STUN client and the upstream service listening on the given host port (e.g. Wireguard).
Bind(port int, server string) error
// Address returns the current STUN address for the given port (if there is one).
Address(port int) (stun.XORMappedAddress, error)
// Connect initializes a short period of connection attempts to the given STUN address of a peer from the
// given port. This opens a hole in the NAT for inbound connection attempts from the peer.
Connect(port int, address net.Addr)
// Cancel destructs an existing STUN binding on the given port.
Cancel(port int) error
}
func NewSTUNController ¶ added in v0.0.35
func NewSTUNController(logger chassis.Logger) STUNController
type SecureTunnelingController ¶ added in v0.0.35
type SecureTunnelingController interface {
// Load is intended to be called at start up and will read secure tunneling configured resources and start
// them (e.g. Wireguard interfaces and their respective STUN servers and Locator connections).
Load()
// AddInterface will add a Wireguard interface to the host.
AddInterface(ctx context.Context, wireguardInterface *v1.WireguardInterface) (publicKey string, err error)
// RemoveInterface will remove a Wireguard interface from the host and also remove any dependent
// resources (STUN bindings and Locator connections).
RemoveInterface(ctx context.Context, wgInterfaceName string) error
// AddPeer will add a Wireguard peer to the given interface.
AddPeer(ctx context.Context, wgInterfaceName string, peer *v1.WireguardPeer) (addresses []string, dnsServers []string, err error)
// AddLocator will add a Locator conneciton to the given interface.
AddLocator(ctx context.Context, wgInterfaceName string, locatorAddress string) error
// RemoveLocator will remove a Locator connection from the given interface.
RemoveLocator(ctx context.Context, wgInterfaceName string, locatorAddress string) error
// BindSTUNServer will add (or replace) a STUN bunding to the given Wireguard interface.
BindSTUNServer(ctx context.Context, wgInterfaceName string, stunServer string) error
}
func NewSecureTunnelingController ¶ added in v0.0.35
func NewSecureTunnelingController(logger chassis.Logger) SecureTunnelingController
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 ServicesConfigK3s ¶ added in v0.0.25
type ServicesConfigOpenSSH ¶ added in v0.0.25
type ServicesConfigOpenSSH struct {
Enable bool `json:"enable"`
}
type ServicesConfigResolved ¶ added in v0.0.25
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 WireGuardConfig ¶ added in v0.0.28
type WireguardController ¶ added in v0.0.35
type WireguardController interface {
AddInterface(ctx context.Context, logger chassis.Logger, wgInterface *v1.WireguardInterface) (publicKey string, err error)
RemoveInterface(ctx context.Context, logger chassis.Logger, wgInterfaceName string) error
AddPeer(ctx context.Context, logger chassis.Logger, wgInterfaceName string, peer *v1.WireguardPeer) (addresses []string, err error)
}
func NewWireguardController ¶ added in v0.0.35
func NewWireguardController() WireguardController
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"`
}