-
Notifications
You must be signed in to change notification settings - Fork 1
/
pteropckt.go
58 lines (45 loc) · 1.73 KB
/
pteropckt.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
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/gamemann/Pterodactyl-Packet-Watch/config"
"github.com/gamemann/Pterodactyl-Packet-Watch/pterodactyl"
"github.com/gamemann/Pterodactyl-Packet-Watch/servers"
"github.com/gamemann/Pterodactyl-Packet-Watch/update"
)
func main() {
// Look for 'cfg' flag in command line arguments (default path: /etc/pteropckt/pteropcktconf).
configFile := flag.String("cfg", "/etc/pteropckt/pteropckt.conf", "The path to the Pterowatch config file.")
flag.Parse()
// Create config struct.
cfg := config.Config{}
// Set config defaults.
cfg.SetDefaults()
// Attempt to read config.
cfg.ReadConfig(*configFile)
// Level 1 debug.
if cfg.DebugLevel > 0 {
fmt.Printf("[D1] Found config with API URL => %s. Token => %s. App Token => %s. Auto Add Servers => %t. Debug level => %d. Reload time => %d.\n", cfg.APIURL, cfg.Token, cfg.AppToken, cfg.AddServers, cfg.DebugLevel, cfg.ReloadTime)
}
// Level 2 debug.
if cfg.DebugLevel > 1 {
fmt.Printf("[D2] Config default server values. Enable => %t. Threshold => %d. Count => %d. Interval => %d. Timeout => %d. Max Detects => %d. Cooldown => %d. Mentions => %s.\n", cfg.DefEnable, cfg.DefThreshold, cfg.DefCount, cfg.DefInterval, cfg.DefTimeout, cfg.DefMaxDetects, cfg.DefCooldown, cfg.DefMentions)
}
// Check if we want to automatically add servers.
if cfg.AddServers {
pterodactyl.AddServers(&cfg)
}
// Handle all servers (create timers, etc.).
servers.HandleServers(&cfg, false)
// Set config file for use later (e.g. updating/reloading).
cfg.ConfLoc = *configFile
// Initialize updater/reloader.
update.Init(&cfg)
// Signal.
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
<-sigc
}