Finalized Client

This commit is contained in:
2026-02-24 12:43:13 +01:00
parent d737353f2d
commit 61b65bf81c
4 changed files with 181 additions and 34 deletions

31
util.go
View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"syscall"
@@ -14,8 +15,9 @@ import (
)
var (
ErrorPIDInUse = errors.New("daemon is already running")
ErrLockFailed = errors.New("failed to acquire a lock on the PID file")
ErrorPIDInUse = errors.New("daemon is already running")
ErrLockFailed = errors.New("failed to acquire a lock on the PID file")
ErrRepoNotInit = errors.New("repo not initialized")
)
type Domain struct {
@@ -242,3 +244,28 @@ func sanitizeDomainKey(s string) string {
r := strings.NewReplacer("/", "_", "\\", "_", " ", "_", ":", "_")
return r.Replace(s)
}
// getDomainCertsDir Can return BlankConfigEntry, ConfigNotFound, or other errors
func getDomainCertsDir(domain string) (string, error) {
domainConfig, exists := getDomainConfig(domain)
if !exists {
return "", ConfigNotFound
}
return getDomainCertsDirWConf(domain, domainConfig)
}
// getDomainCertsDir Can return BlankConfigEntry or other errors
func getDomainCertsDirWConf(domain string, domainConfig *ezconf.Configuration) (string, error) {
effectiveDataRoot, err := getEffectiveString(domainConfig, "Certificates.data_root")
if err != nil {
return "", err
}
return filepath.Join(effectiveDataRoot, "certificates", domain), nil
}
func getDomainCertsDirWOnlyConf(domainConfig *ezconf.Configuration) (string, error) {
domain := domainConfig.GetAsString("Domain.domain_name")
return getDomainCertsDirWConf(domain, domainConfig)
}