This commit is contained in:
Lennart J. Kurzweg (Nx2)
2026-04-23 17:32:30 +02:00
parent f66f58f67f
commit f61e014d2a
5 changed files with 46 additions and 61 deletions

View File

@@ -1,8 +1,10 @@
package config
import (
"fmt"
"net/url"
"os"
"os/exec"
"slices"
"strings"
@@ -64,10 +66,11 @@ func (s ServerConfig) BasePath() string {
type SMTPConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
PasswordCmd string `yaml:"password_cmd"`
}
type Config struct {
@@ -79,6 +82,18 @@ type Config struct {
AddressBooks []AddressBook `yaml:"address_books"`
Aggregates []Aggregate `yaml:"aggregates"`
}
func ResolvePassword(password, passwordCmd string) (string, error) {
if passwordCmd != "" {
cmd := exec.Command("sh", "-c", passwordCmd)
out, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("failed to run password command: %v", err)
}
return strings.TrimSpace(string(out)), nil
}
return password, nil
}
func (c *Config) setDefaults() {
if c.Server.BindAddress == "" { c.Server.BindAddress = ":8080" }
if c.Server.Redaction == "" { c.Server.Redaction = "Busy" }