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() }