fix(sub): randomize fresh panel subscription paths (#6375)

* fix(sub): randomize fresh panel subscription paths

Seed distinct cryptographically random paths for base64, JSON, and Clash subscriptions when a panel database is first created. Persist them so restarts keep published URLs stable while upgrades preserve existing settings.

Generated-by: OpenCode:gpt-5.6-sol

* fix(sub): regenerate paths on settings reset

Keep subscription paths unpredictable after a factory reset, close the test database on failure, and update the builder, OpenAPI, and localized docs to describe panel-specific paths instead of obsolete fixed defaults.

Generated-by: OpenCode:gpt-5.6-sol
This commit is contained in:
ilyusha
2026-09-03 17:34:37 +03:00
committed by GitHub
parent ded2aa150c
commit f9898e0b24
20 changed files with 285 additions and 158 deletions
+21
View File
@@ -1169,6 +1169,22 @@ func initUser() error {
return nil
}
func seedRandomSubscriptionPaths() error {
settings := []model.Setting{
{Key: "subPath", Value: "/" + random.NumLower(16) + "/"},
{Key: "subJsonPath", Value: "/" + random.NumLower(16) + "/"},
{Key: "subClashPath", Value: "/" + random.NumLower(16) + "/"},
}
return db.Transaction(func(tx *gorm.DB) error {
for i := range settings {
if err := tx.Where("key = ?", settings[i].Key).FirstOrCreate(&settings[i]).Error; err != nil {
return err
}
}
return nil
})
}
func runSeeders(isUsersEmpty bool) error {
empty, err := isTableEmpty("history_of_seeders")
if err != nil {
@@ -2138,6 +2154,11 @@ func InitDB(dbPath string) error {
if err != nil {
return err
}
if isUsersEmpty {
if err := seedRandomSubscriptionPaths(); err != nil {
return err
}
}
if err := initUser(); err != nil {
return err