-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.go
100 lines (93 loc) · 3.17 KB
/
api.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package opnborg
import (
"sync"
"sync/atomic"
)
// global exported consts
const SemVer = "v0.1.31"
// global var
var (
tg []OPNGroup
sleep, borg, pkgmaster string
wazuhWebUI, unifiWebUI, prometheusWebUI string
grafanaWebUI, grafanaFreeBSD, grafanaUnpoller, grafanaHAProxy string
)
// OPNGroup Type
type OPNGroup struct {
Name string // group name
Img bool // group image available
ImgURL string // group image url
Member []string // group member
}
// OPNCall
type OPNCall struct {
Targets string // list of OPNSense Appliances, csv comma seperated
TGroups []OPNGroup // list of OPNSense Appliances Target Groups and Member
Key string // OPNSense Backup User API Key (required)
Secret string // OPNSense Backup User API Secret (required)
Path string // OPNSense Backup Files Target Path, default:'.'
TLSKeyPin string // TLS Connection Server Certificate KeyPIN
AppName string // Display and SysLog Application Name
Email string // Git Commiter eMail Address (default: git@opnborg)
Sleep int64 // number of seconds to sleep between polls
Daemon bool // daemonize (run in background), default: true
Debug bool // verbose debug logs, defaults to false
Git bool // create and commit all xml files & changes to local .git repo, default: true
extGIT bool // when available, use external git for verification
dirty atomic.Bool // git global (atomic) worktree state
Httpd struct {
Enable bool // enable internal web server
Server string // internal httpd server listen ip & port (string, default: 127.0.0.1:6464)
CAcert string // httpd server certificate (path to pem encoded x509 file - full certificate chain)
CAkey string // httpd server key (path to pem encoded tls server key file)
CAClient string // httpd client CA (path to pem endcoded x509 file - if set, it will enforce mTLS-only mode)
Color struct {
FG string // color theme background
BG string // color theme foreground
}
}
Unifi struct {
Enable bool
WebUI string
}
Wazuh struct {
Enable bool
WebUI string
}
Prometheus struct {
Enable bool
WebUI string
}
Grafana struct {
Enable bool
WebUI string
FreeBSD string
HAProxy string
Unpoller string
}
GrayLog struct {
Enable bool // enable use of graylog server
Server string // graylog server
}
RSysLog struct {
Enable bool // enable RFC5424 compliant remote syslog store server (default: false)
Server string // internal syslog listen ip and port [ example: 192.168.0.100:5140 ] (required)
}
Sync struct {
Enable bool // enable Master Server
validConf bool // internal state (skip if master conf is invalid/unreachable)
Master string // Master Server Name
PKG struct {
Enable bool // enable packages sync
Packages []string // list of Packages to sync
}
}
}
// global
var hive []string
var hiveMutex sync.Mutex
var update = make(chan bool, 1)
// Start Application Server
func Start(config *OPNCall) error {
return srv(config)
}