Files
backend/global/global.go
NanamiAdmin 1432651a14 fix(watchdog): fix watchdog unable to send webhook and simplify the parsing of json config
- Change webhook config headers and body from map to string format
- Move command parsing logic to separate function in command.go
- Add debug logging for webhook operations
- Improve exception handling with proper JSON parsing
- Simplify config loading logic with default values
2026-04-28 20:48:54 +08:00

100 lines
1.9 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 string `json:"headers"`
Body 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 string `json:"headers"`
Body string `json:"body"`
}{
Method: "",
URL: "",
Headers: "Content-Type: application/json",
Body: "",
},
}