-
Notifications
You must be signed in to change notification settings - Fork 1
/
netgate.go
64 lines (49 loc) · 1.24 KB
/
netgate.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
package main
import (
"flag"
"fmt"
"os"
"runtime"
"time"
_ "github.com/mrhaoxx/OpenNG/auth"
"github.com/mrhaoxx/OpenNG/log"
"github.com/mrhaoxx/OpenNG/ui"
)
var configfile = flag.String("config", "config.yaml", "the config file to load")
var printversion = flag.Bool("version", false, "print version and exit")
var helpmessage = flag.Bool("help", false, "print help message")
func main() {
fmt.Fprintf(os.Stderr, "NetGATE - A Inbound Gateway\n")
flag.Parse()
if *helpmessage {
flag.PrintDefaults()
return
}
fmt.Fprintf(os.Stderr, `
_ _ _ ____ _ _____ _____
| \ | | ___| |_ / ___| / \|_ _| ____|
| \| |/ _ \ __| | _ / _ \ | | | _|
| |\ | __/ |_| |_| |/ ___ \| | | |___
|_| \_|\___|\__|\____/_/ \_\_| |_____|
%s %s
%s %s %s %s
config: %s
`,
gitver, buildstamp, runtime.Version(), runtime.GOOS, runtime.GOARCH, runtime.Compiler, *configfile)
if *printversion {
return
}
r, err := os.ReadFile(*configfile)
if err != nil {
fmt.Println(err.Error())
return
}
ui.ConfigFile = *configfile
_start := time.Now()
if err := ui.LoadCfg(r); err != nil {
log.Println(err)
os.Exit(-1)
}
fmt.Fprintf(os.Stderr, "configuration from %s loaded in %s\n", *configfile, time.Since(_start).String())
select {}
}