profile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UDM profile for UniFi Dream Machine
	UDM = Profile{
		Name:          "udm",
		DataDir:       "/data/.dddns",
		ConfigPerm:    constants.ConfigFilePerm,
		SecurePerm:    constants.SecureConfigPerm,
		DirPerm:       constants.ConfigDirPerm,
		UseHardwareID: true,
		DeviceIDPath:  "/proc/ubnthal/system.info",
	}

	// Linux standard profile
	Linux = Profile{
		Name:          "linux",
		DataDir:       "$HOME/.dddns",
		ConfigPerm:    constants.ConfigFilePerm,
		SecurePerm:    constants.SecureConfigPerm,
		DirPerm:       constants.ConfigDirPerm,
		UseHardwareID: true,
		DeviceIDPath:  "/sys/class/net/eth0/address",
	}

	// MacOS profile
	MacOS = Profile{
		Name:          "macos",
		DataDir:       "$HOME/.dddns",
		ConfigPerm:    constants.ConfigFilePerm,
		SecurePerm:    constants.SecureConfigPerm,
		DirPerm:       constants.ConfigDirPerm,
		UseHardwareID: true,
		DeviceIDPath:  "system_profiler",
	}

	// Docker container profile
	Docker = Profile{
		Name:          "docker",
		DataDir:       "/config",
		ConfigPerm:    constants.ConfigFilePerm,
		SecurePerm:    constants.SecureConfigPerm,
		DirPerm:       constants.CacheDirPerm,
		UseHardwareID: true,
		DeviceIDPath:  "/proc/self/cgroup",
	}

	// Windows profile (AMD64 and ARM64)
	Windows = Profile{
		Name:          "windows",
		DataDir:       "$APPDATA/dddns",
		ConfigPerm:    0600,
		SecurePerm:    0400,
		DirPerm:       0700,
		UseHardwareID: true,
		DeviceIDPath:  "wmic",
	}
)

Functions

This section is empty.

Types

type Profile

type Profile struct {
	Name          string
	DataDir       string // Where to store config and cache
	ConfigPerm    os.FileMode
	SecurePerm    os.FileMode
	DirPerm       os.FileMode
	UseHardwareID bool   // Use device-specific encryption
	DeviceIDPath  string // Path to hardware identifier
}

Profile defines deployment-specific configuration

func Detect

func Detect() *Profile

Detect identifies the deployment environment and returns the matching Profile. It is cheap (a few os.Stat calls + runtime.GOOS) — callers that need the profile repeatedly should cache the returned pointer locally instead of re-invoking.

func (*Profile) GetCachePath

func (p *Profile) GetCachePath() (string, error)

GetCachePath returns the full cache file path.

func (*Profile) GetConfigPath

func (p *Profile) GetConfigPath() (string, error)

GetConfigPath returns the full config file path.

func (*Profile) GetDataDir

func (p *Profile) GetDataDir() (string, error)

GetDataDir returns the expanded data directory path. It fails loudly when $HOME/$APPDATA cannot be resolved — silently returning "/.dddns" would cause dddns to try to write under the filesystem root.

func (*Profile) GetSecurePath

func (p *Profile) GetSecurePath() (string, error)

GetSecurePath returns the full secure config path.

Jump to

Keyboard shortcuts

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