working commit

This commit is contained in:
2026-03-17 14:56:35 +02:00
parent 97904e0529
commit 52789ef4d1
26 changed files with 1334 additions and 52 deletions
+22 -13
View File
@@ -34,18 +34,20 @@ type Storage struct {
}
type Config struct {
Service Service `json:"service" yaml:"service"`
Database Database `json:"database" yaml:"database"`
Storage Storage `json:"storage" yaml:"storage"`
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
Logpath string `json:"logpath" yaml:"logpath"`
Runpath string `json:"runpath" yaml:"runpath"`
Version string `json:"version" yaml:"version"`
Certpath string `json:"certpath,omitempty" yaml:"certpath,omitempty"`
Keypath string `json:"keypath,omitempty" yaml:"keypath,omitempty"`
X509Cert string `json:"-" yaml:"-"`
X509Key string `json:"-" yaml:"-"`
Datadir string `json:"datadir" yaml:datadir`
Service Service `json:"service" yaml:"service"`
Database Database `json:"database" yaml:"database"`
Storage Storage `json:"storage" yaml:"storage"`
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
Logpath string `json:"logpath" yaml:"logpath"`
Runpath string `json:"runpath" yaml:"runpath"`
Version string `json:"version" yaml:"version"`
Certpath string `json:"certpath,omitempty" yaml:"certpath,omitempty"`
Keypath string `json:"keypath,omitempty" yaml:"keypath,omitempty"`
X509Cert string `json:"-" yaml:"-"`
X509Key string `json:"-" yaml:"-"`
Datadir string `json:"datadir" yaml:datadir`
Hostname string `json:"hostname" yaml:hostname`
Hostnames []string `json:"hostnames" yaml:hostnames`
}
func NewConfig() *Config {
@@ -79,6 +81,7 @@ func NewConfig() *Config {
Datadir: datadir,
//Certpath: certpath,
//Keypath: keypath,
Hostnames: make([]string, 0),
}
}
@@ -138,7 +141,13 @@ func (conf *Config) ReadX509Cert() error {
}
*/
if conf.X509Cert == "" || conf.X509Key == "" {
certBytes, keyBytes, err := auxx509.CreateSelfSignedCert("localhost")
if conf.Hostname == "" {
conf.Hostname, err = os.Hostname()
if err != nil {
return err
}
}
certBytes, keyBytes, err := auxx509.CreateSelfSignedCert(conf.Hostname, conf.Hostnames...)
if err != nil {
return err
}