-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
47 lines (37 loc) · 855 Bytes
/
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
package main
// Author: Valentin Kuznetsov <vkuznet [AT] gmain [DOT] com>
import (
"flag"
"fmt"
"log"
"os"
"runtime"
"time"
)
// version of the code
var gitVersion string
// Info function returns version string of the server
func info() string {
goVersion := runtime.Version()
tstamp := time.Now().Format("2006-02-01")
return fmt.Sprintf("2fa-server git=%s go=%s date=%s", gitVersion, goVersion, tstamp)
}
func main() {
var config string
flag.StringVar(&config, "config", "", "config file")
var version bool
flag.BoolVar(&version, "version", false, "Show version")
flag.Parse()
if version {
fmt.Println(info())
os.Exit(0)
}
// read configuration
parseConfig(config)
log.Printf("Server configuration %+v", Config)
if Config.Verbose > 0 {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
// start HTTP server
server()
}