mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-07 13:44:24 +00:00
fix: add node settings to defaultValueMap and settingGroups
Node settings (nodeRole, nodeId, syncInterval, trafficFlushInterval) now have defaults in the settings system. On fresh install, they are automatically created in x-ui.json under the 'node' group. The settingGroupAliases now look in 'node' first, then 'other' for backward compatibility.
This commit is contained in:
parent
d5bf2858ce
commit
d733ff2af1
3 changed files with 32 additions and 17 deletions
|
|
@ -142,20 +142,16 @@ func GetLogFolder() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var settingGroupAliases = map[string][]string{
|
var settingGroupAliases = map[string][]string{
|
||||||
"dbType": {"databaseConnection", "other"},
|
"dbType": {"databaseConnection", "other"},
|
||||||
"dbHost": {"databaseConnection", "other"},
|
"dbHost": {"databaseConnection", "other"},
|
||||||
"dbPort": {"databaseConnection", "other"},
|
"dbPort": {"databaseConnection", "other"},
|
||||||
"dbUser": {"databaseConnection", "other"},
|
"dbUser": {"databaseConnection", "other"},
|
||||||
"dbPassword": {"databaseConnection", "other"},
|
"dbPassword": {"databaseConnection", "other"},
|
||||||
"dbName": {"databaseConnection", "other"},
|
"dbName": {"databaseConnection", "other"},
|
||||||
"nodeRole": {"other"},
|
"nodeRole": {"node", "other"},
|
||||||
"nodeId": {"other"},
|
"nodeId": {"node", "other"},
|
||||||
"syncInterval": {
|
"syncInterval": {"node", "other"},
|
||||||
"other",
|
"trafficFlushInterval": {"node", "other"},
|
||||||
},
|
|
||||||
"trafficFlushInterval": {
|
|
||||||
"other",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readGroupedString(settings map[string]any, key string) string {
|
func readGroupedString(settings map[string]any, key string) string {
|
||||||
|
|
@ -214,10 +210,10 @@ func settingsLayoutMeta() map[string]any {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureDefaultNodeSettings(settings map[string]any) {
|
func ensureDefaultNodeSettings(settings map[string]any) {
|
||||||
group, ok := settings["other"].(map[string]any)
|
group, ok := settings["node"].(map[string]any)
|
||||||
if !ok {
|
if !ok {
|
||||||
group = make(map[string]any)
|
group = make(map[string]any)
|
||||||
settings["other"] = group
|
settings["node"] = group
|
||||||
}
|
}
|
||||||
|
|
||||||
defaults := map[string]string{
|
defaults := map[string]string{
|
||||||
|
|
@ -228,6 +224,13 @@ func ensureDefaultNodeSettings(settings map[string]any) {
|
||||||
}
|
}
|
||||||
for key, value := range defaults {
|
for key, value := range defaults {
|
||||||
if existing, exists := group[key]; !exists || existing == nil {
|
if existing, exists := group[key]; !exists || existing == nil {
|
||||||
|
// Also check "other" group for backward compatibility
|
||||||
|
if otherGroup, ok := settings["other"].(map[string]any); ok {
|
||||||
|
if val, ok := otherGroup[key].(string); ok && val != "" {
|
||||||
|
group[key] = val
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
group[key] = value
|
group[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
v1.6.2
|
v1.6.3
|
||||||
|
|
@ -140,6 +140,12 @@ rules:
|
||||||
"dbUser": "",
|
"dbUser": "",
|
||||||
"dbPassword": "",
|
"dbPassword": "",
|
||||||
"dbName": "3xui",
|
"dbName": "3xui",
|
||||||
|
|
||||||
|
// Node settings
|
||||||
|
"nodeRole": "master",
|
||||||
|
"nodeId": "",
|
||||||
|
"syncInterval": "30",
|
||||||
|
"trafficFlushInterval": "10",
|
||||||
}
|
}
|
||||||
|
|
||||||
// settingGroups defines the nested JSON structure for on-disk settings.
|
// settingGroups defines the nested JSON structure for on-disk settings.
|
||||||
|
|
@ -251,6 +257,12 @@ var settingGroups = map[string]map[string]string{
|
||||||
"dbPassword": "dbPassword",
|
"dbPassword": "dbPassword",
|
||||||
"dbName": "dbName",
|
"dbName": "dbName",
|
||||||
},
|
},
|
||||||
|
"node": {
|
||||||
|
"nodeRole": "nodeRole",
|
||||||
|
"nodeId": "nodeId",
|
||||||
|
"syncInterval": "syncInterval",
|
||||||
|
"trafficFlushInterval": "trafficFlushInterval",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var legacySettingGroups = map[string]map[string]string{
|
var legacySettingGroups = map[string]map[string]string{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue