* Rename fsldap to efsldap

* Use gopkg.in/ini.v1 over github.com/joho/godotenv
* Fix typos

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2026-01-07 16:37:02 -03:00
parent 0677061406
commit e4d9b92061
13 changed files with 147 additions and 69 deletions

43
config/config.go Normal file
View File

@@ -0,0 +1,43 @@
package config
import (
"errors"
"log"
"os"
"gopkg.in/ini.v1"
)
var Config struct {
LDAPBase string
LDAPUID string
SMTPDomain string
SMTPHost string
SMTPPort string
}
var (
ConfigPath string
)
func ConfInit() {
if _, err := os.Stat(ConfigPath); errors.Is(err, os.ErrNotExist) {
log.Fatal(err)
}
Parse(ConfigPath)
}
func Parse(fn string) error {
cfg, err := ini.Load(fn)
if err != nil {
return err
}
Config.LDAPBase = cfg.Section("").Key("ldap_base").String()
Config.LDAPUID = cfg.Section("").Key("ldap_uid").String()
Config.SMTPDomain = cfg.Section("").Key("smtp_domain").String()
Config.SMTPHost = cfg.Section("").Key("smtp_host").String()
Config.SMTPPort = cfg.Section("").Key("smtp_port").String()
return nil
}