utils

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicsName = "basics.json"

	DefaultTimeZone = "Europe/Berlin"
	DefaultCompany  = "My Company"
	DefaultRegTTL   = 3600
	DefaultDMARC    = "v=DMARC1; p=quarantine; pct=100; adkim=s; aspf=s"
)
View Source
const (
	DHParamsName = "dhparams.pem"
)
View Source
const (
	SecretsName = "secrets.json"
)

Variables

This section is empty.

Functions

func CreatePassword

func CreatePassword(length int) (string, error)

func EnsureBaseDir

func EnsureBaseDir() error

EnsureBaseDir ensures that the current working directory is located within the gd-tools base directory defined by GD_TOOLS_BASE.

This is used as a safety mechanism to prevent accidental execution outside the managed infrastructure tree.

func EnsureBaseOrHostDir added in v0.3.0

func EnsureBaseOrHostDir() error

EnsureBaseOrHostDir allows execution either from the gd-tools base directory (or any of its subdirectories) or from a host directory.

This is useful for commands like 'list' that can operate globally or on a single host.

func EnsureHostDir added in v0.3.0

func EnsureHostDir() error

EnsureHostDir ensures that the current working directory represents a gd-tools host directory.

A host directory is identified by the presence of a config.json file.

func FetchPassword

func FetchPassword(length int, domain, user string) (string, error)

func GenerateBcrypt

func GenerateBcrypt(password string) (string, error)

func GenerateDHParams

func GenerateDHParams(bits int) ([]byte, error)

GenerateDHParams generates dhparams.pem (2048+ bits) via openssl

func GeneratePBKDF2

func GeneratePBKDF2(password string) (string, error)

func GenerateSecret

func GenerateSecret(key, mode string) (string, error)

func GetRSAKeyPair

func GetRSAKeyPair(fqdn string) ([]byte, []byte, error)

func GetSysAdmin

func GetSysAdmin() string

func GetTimeZone

func GetTimeZone() string

Types

type Basics

type Basics struct {
	Company  string `json:"company"`
	SysAdmin string `json:"sys_admin"`
	TimeZone string `json:"time_zone"`
	Language string `json:"language"`
	Region   string `json:"region"`
	RegTTL   int    `json:"reg_ttl"`
	HelpURL  string `json:"help_url"`
	DMARC    string `json:"dmarc"`
}

func GetBasics

func GetBasics() (*Basics, error)

func ReadBasics

func ReadBasics() (*Basics, error)

func (*Basics) Locale

func (basics *Basics) Locale() string

func (*Basics) Save

func (basics *Basics) Save() error

type Secret

type Secret struct {
	Domain string `json:"domain"`
	User   string `json:"user"`
	Input  string `json:"input"`
	Output string `json:"output"`
}

type SecretList

type SecretList struct {
	Secrets []Secret `json:"entries"`
}

func LoadSecrets

func LoadSecrets() (*SecretList, error)

func (*SecretList) Get

func (list *SecretList) Get(domain, user string) *Secret

func (*SecretList) Save

func (list *SecretList) Save() error

func (*SecretList) Set

func (list *SecretList) Set(domain, user, input, output string) error

func (*SecretList) SetMailUser

func (list *SecretList) SetMailUser(address, password string) (string, string, error)

Jump to

Keyboard shortcuts

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