* 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

54
main.go Normal file
View File

@@ -0,0 +1,54 @@
package main
import (
"log"
"os"
"os/signal"
"syscall"
ldap "github.com/vjeantet/ldapserver"
cfg "git.laidback.moe/YakumoLabs/efsldap/config"
"git.laidback.moe/YakumoLabs/efsldap/handler"
flag "github.com/spf13/pflag"
)
var (
configPath string
)
func main() {
flag.StringVarP(&configPath, "config", "c", "", "Path to configuration file")
flag.Parse()
if configPath != "" {
cfg.ConfigPath = configPath
cfg.ConfInit()
} else {
log.Fatal("Unable to load configuration file")
}
server := ldap.NewServer()
routes := ldap.NewRouteMux()
routes.Bind(handler.Bind)
routes.Extended(handler.WhoAmI).
RequestName(ldap.NoticeOfWhoAmI).Label("Ext - WhoAmI")
routes.Search(handler.Search).Label("Search - Generic")
server.Handle(routes)
log.Print("Starting EFSLDAP server...")
go func(){
err := server.ListenAndServe("127.0.0.1:389")
if err != nil{
log.Fatal(err)
}
}()
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
<-ch
close(ch)
server.Stop()
}