|
@@ -664,7 +664,10 @@ func runSeeders(isUsersEmpty bool) error {
|
|
|
if err := seedWireguardPeersToClients(); err != nil {
|
|
if err := seedWireguardPeersToClients(); err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
- return nil
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Idempotent, not seeder-gated: bad values can re-enter via a restored
|
|
|
|
|
+ // backup, so re-check on every start.
|
|
|
|
|
+ return normalizeSettingPaths()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// resetIpLimitsWithoutFail2ban zeroes every client's IP limit on hosts where
|
|
// resetIpLimitsWithoutFail2ban zeroes every client's IP limit on hosts where
|
|
@@ -769,6 +772,37 @@ func clearLegacyProxySettings() error {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// normalizeSettingPaths repairs URI-path settings persisted before the
|
|
|
|
|
+// leading/trailing-slash rules existed (or restored from an old backup),
|
|
|
|
|
+// mirroring entity.AllSetting.CheckValid. CheckValid self-heals these on save,
|
|
|
|
|
+// but the frontend rejects the whole Settings form on the bad stored value
|
|
|
|
|
+// before a save can ever reach it (#5726), so the stored rows themselves must
|
|
|
|
|
+// be fixed. Idempotent; runs on every start.
|
|
|
|
|
+func normalizeSettingPaths() error {
|
|
|
|
|
+ pathKeys := []string{"webBasePath", "subPath", "subJsonPath", "subClashPath"}
|
|
|
|
|
+ var rows []model.Setting
|
|
|
|
|
+ if err := db.Where("key IN ?", pathKeys).Find(&rows).Error; err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, row := range rows {
|
|
|
|
|
+ fixed := row.Value
|
|
|
|
|
+ if !strings.HasPrefix(fixed, "/") {
|
|
|
|
|
+ fixed = "/" + fixed
|
|
|
|
|
+ }
|
|
|
|
|
+ if !strings.HasSuffix(fixed, "/") {
|
|
|
|
|
+ fixed += "/"
|
|
|
|
|
+ }
|
|
|
|
|
+ if fixed == row.Value {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ if err := db.Model(&model.Setting{}).Where("id = ?", row.Id).
|
|
|
|
|
+ Update("value", fixed).Error; err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func normalizeInboundClientTgId() error {
|
|
func normalizeInboundClientTgId() error {
|
|
|
var inbounds []model.Inbound
|
|
var inbounds []model.Inbound
|
|
|
if err := db.Find(&inbounds).Error; err != nil {
|
|
if err := db.Find(&inbounds).Error; err != nil {
|