- Add GET /settings/get and POST /settings/set endpoints for managing system settings - Implement config file persistence for settings changes - Update config schema to include notification and webhook settings - Add API documentation for new endpoints - Move config path variables to global package for consistency
104 lines
2.0 KiB
Go
104 lines
2.0 KiB
Go
package global
|
|
|
|
import (
|
|
"database/sql"
|
|
)
|
|
|
|
var ConfigPath *string
|
|
var DBPath_data *string
|
|
var DBPath_log *string
|
|
|
|
type SoftwareInfo struct {
|
|
Name string
|
|
Version string
|
|
Developer string
|
|
BuildVer int16
|
|
Description string
|
|
BuildType string
|
|
}
|
|
|
|
var Software = SoftwareInfo{
|
|
Name: "Super-frpc",
|
|
Version: "0.0.1",
|
|
Developer: "Madobi Nanami",
|
|
BuildVer: 1,
|
|
BuildType: "debug",
|
|
}
|
|
|
|
type StatusFlags struct {
|
|
Debug bool
|
|
Online bool
|
|
WatchdogConnected bool
|
|
}
|
|
|
|
var (
|
|
ConfigDB *sql.DB
|
|
FrpcDB *sql.DB
|
|
LogsDB *sql.DB
|
|
)
|
|
|
|
var Is = StatusFlags{
|
|
Debug: false,
|
|
Online: false,
|
|
WatchdogConnected: false,
|
|
}
|
|
|
|
type Config struct {
|
|
ListenAddr string `json:"listenAddr"`
|
|
ListenPort string `json:"listenPort"`
|
|
FrpcPath string `json:"frpcPath"`
|
|
InstancePath string `json:"instancePath"`
|
|
Debug bool `json:"debug"`
|
|
Watchdog struct {
|
|
Enabled bool `json:"enabled"`
|
|
Port int `json:"port"`
|
|
} `json:"watchdog"`
|
|
Notification struct {
|
|
Enabled bool `json:"enabled"`
|
|
Method string `json:"method"`
|
|
} `json:"notification"`
|
|
Webhook struct {
|
|
Method string `json:"method"`
|
|
URL string `json:"url"`
|
|
Headers map[string]string `json:"headers"`
|
|
Body map[string]string `json:"body"`
|
|
} `json:"webhook"`
|
|
}
|
|
|
|
var CurrentConfig = Config{
|
|
ListenAddr: "0.0.0.0",
|
|
ListenPort: "7000",
|
|
FrpcPath: "",
|
|
InstancePath: "",
|
|
Debug: false,
|
|
Watchdog: struct {
|
|
Enabled bool `json:"enabled"`
|
|
Port int `json:"port"`
|
|
}{
|
|
Enabled: false,
|
|
Port: 0,
|
|
},
|
|
Notification: struct {
|
|
Enabled bool `json:"enabled"`
|
|
Method string `json:"method"`
|
|
}{
|
|
Enabled: false,
|
|
Method: "webhook",
|
|
},
|
|
Webhook: struct {
|
|
Method string `json:"method"`
|
|
URL string `json:"url"`
|
|
Headers map[string]string `json:"headers"`
|
|
Body map[string]string `json:"body"`
|
|
}{
|
|
Method: "",
|
|
URL: "",
|
|
Headers: map[string]string{
|
|
"Content-Type": "",
|
|
},
|
|
Body: map[string]string{
|
|
"text": "",
|
|
},
|
|
},
|
|
}
|