Initial Email-Forwarder scaffold
This commit is contained in:
commit
91e52aecd0
22 changed files with 1007 additions and 0 deletions
51
backend/01-config.go
Normal file
51
backend/01-config.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Cfg ist die globale App-Konfiguration (config.json). Enthaelt NUR
|
||||
// App-/Weiterleitungs-Einstellungen. Die Umzugs-Konten (Quelle->Ziel) leben
|
||||
// in der DB (Tabelle accounts) und werden im Browser gepflegt.
|
||||
var Cfg Config
|
||||
|
||||
type Config struct {
|
||||
Bind string `json:"bind"`
|
||||
Port string `json:"port"`
|
||||
AdminUser string `json:"admin_user"`
|
||||
AdminPass string `json:"admin_pass"`
|
||||
DBPath string `json:"db_path"`
|
||||
MboxRoot string `json:"mbox_root"`
|
||||
ForwardSMTP SMTPConfig `json:"forward_smtp"`
|
||||
}
|
||||
|
||||
// SMTPConfig ist NUR fuer das manuelle Weiterleiten einzelner Mails aus dem
|
||||
// Viewer. Der Umzug selbst nutzt NIEMALS SMTP, sondern IMAP APPEND.
|
||||
type SMTPConfig struct {
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
User string `json:"user"`
|
||||
Pass string `json:"pass"`
|
||||
From string `json:"from"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) error {
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(b, &Cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
if Cfg.Bind == "" {
|
||||
Cfg.Bind = "127.0.0.1"
|
||||
}
|
||||
if Cfg.Port == "" {
|
||||
Cfg.Port = "8087"
|
||||
}
|
||||
if Cfg.MboxRoot == "" {
|
||||
Cfg.MboxRoot = "./backup"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue