-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
66 lines (46 loc) · 1.7 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"github.com/Abbas-gheydi/radotp/pkgs/confs"
"github.com/Abbas-gheydi/radotp/pkgs/monitoring"
"github.com/Abbas-gheydi/radotp/pkgs/rad"
"github.com/Abbas-gheydi/radotp/pkgs/storage"
"github.com/Abbas-gheydi/radotp/pkgs/web"
)
var cfg confs.Configurations
func art() {
fmt.Print(`
_/_/_/ _/_/ _/_/_/ _/_/ _/_/_/_/_/ _/_/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/_/ _/_/_/_/ _/ _/ _/ _/ _/ _/_/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/_/_/ _/_/ _/ _/
`)
}
func loadConfigs() {
//load configs from file
cfg.Load()
//radius configs
rad.RadiusConfigs = cfg.Radius
//web configs
web.ListenAddr = cfg.Web.Listen
web.QrIssuer = cfg.Web.Isuuer
//ldap configs
rad.Auth_Provider = cfg.Ldap
//database configs
storage.Dsn = fmt.Sprintf("host=%v user=%v password=%v dbname=%v port=%v sslmode=%v TimeZone=%v", cfg.Database.Server, cfg.Database.Username, cfg.Database.Password, cfg.Database.Dbname, cfg.Database.Port, cfg.Database.Sslmode, cfg.Database.Timezone)
//monitoring
monitoring.Listen = cfg.Metrics.Listen
rad.EnableMetrics = cfg.Metrics.EnablePrometheusExporter
}
func main() {
loadConfigs()
art()
//databse configuraion
storage.Initialize()
if cfg.Metrics.EnablePrometheusExporter {
go monitoring.Start()
}
go web.Start()
rad.StartRadius()
}