mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 13:14:11 +00:00
feat: add backup config fields to entity and setting service
This commit is contained in:
parent
3891bb9212
commit
92b297251a
2 changed files with 23 additions and 0 deletions
|
|
@ -121,6 +121,12 @@ type AllSetting struct {
|
|||
// Registration settings
|
||||
TurnstileSiteKey string `json:"turnstileSiteKey" form:"turnstileSiteKey"`
|
||||
TurnstileSecretKey string `json:"-" form:"-"` // server-side only, never sent to frontend
|
||||
|
||||
// Backup settings
|
||||
BackupEnabled bool `json:"backupEnabled" form:"backupEnabled"`
|
||||
BackupFrequency string `json:"backupFrequency" form:"backupFrequency"`
|
||||
BackupHour int `json:"backupHour" form:"backupHour"`
|
||||
BackupMaxCount int `json:"backupMaxCount" form:"backupMaxCount"`
|
||||
}
|
||||
|
||||
// CheckValid validates all settings in the AllSetting struct, checking IP addresses, ports, SSL certificates, and other configuration values.
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ var defaultValueMap = map[string]string{
|
|||
"nodeId": "",
|
||||
"syncInterval": "30",
|
||||
"trafficFlushInterval": "10",
|
||||
|
||||
// Backup settings
|
||||
"backupEnabled": "false",
|
||||
"backupFrequency": "daily",
|
||||
"backupHour": "3",
|
||||
"backupMaxCount": "10",
|
||||
}
|
||||
|
||||
// settingGroups defines the nested JSON structure for on-disk settings.
|
||||
|
|
@ -247,6 +253,12 @@ var settingGroups = map[string]map[string]string{
|
|||
"syncInterval": "syncInterval",
|
||||
"trafficFlushInterval": "trafficFlushInterval",
|
||||
},
|
||||
"backup": {
|
||||
"enabled": "backupEnabled",
|
||||
"frequency": "backupFrequency",
|
||||
"hour": "backupHour",
|
||||
"maxCount": "backupMaxCount",
|
||||
},
|
||||
}
|
||||
|
||||
var legacySettingGroups = map[string]map[string]string{
|
||||
|
|
@ -1138,6 +1150,11 @@ func (s *SettingService) SetTurnstileSecretKey(value string) error {
|
|||
return s.setString("turnstileSecretKey", value)
|
||||
}
|
||||
|
||||
func (s *SettingService) GetBackupEnabled() (bool, error) { return s.getBool("backupEnabled") }
|
||||
func (s *SettingService) GetBackupFrequency() (string, error) { return s.getString("backupFrequency") }
|
||||
func (s *SettingService) GetBackupHour() (int, error) { return s.getInt("backupHour") }
|
||||
func (s *SettingService) GetBackupMaxCount() (int, error) { return s.getInt("backupMaxCount") }
|
||||
|
||||
func (s *SettingService) UpdateAllSetting(allSetting *entity.AllSetting, presentKeys map[string]struct{}) error {
|
||||
if err := allSetting.CheckValid(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in a new issue