forked from digininja/vuLnDAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (39 loc) · 1.17 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import "fmt"
import "os"
import "time"
import "flag"
import log "github.com/sirupsen/logrus"
import "github.com/digininja/vuLnDAP/server"
import "github.com/digininja/vuLnDAP/config"
var VulndapConnection = NewVulndap()
var clientLogger = log.WithFields(log.Fields{"Owner": "Client"})
var mainLogger = log.WithFields(log.Fields{"Owner": "Main"})
func main() {
mainLogger.Info("Main App Started")
clientLogger.Info("Client Started")
configFilePtr := flag.String("configl", "vulndap.cfg", "Alternative configuration file")
flag.Parse()
var cfg, err = config.NewConfig(*configFilePtr)
if err != nil {
mainLogger.Fatal(fmt.Sprintf("Configuration file error: %s", err.Error()))
}
if cfg.Debug {
cfg.Dump()
}
mainLogger.Info("Starting LDAP server")
go LDAPServer.StartLDAPServer(cfg)
if cfg.Debug {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
mainLogger.Debug("Sleeping for 500ms to give the server time to start up")
time.Sleep(500 * time.Millisecond)
mainLogger.Info("Binding to LDAP server")
VulndapConnection.connect(cfg)
defer VulndapConnection.close()
webserver := NewWebServer(cfg)
webserver.startWebApp()
os.Exit(1)
}