mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-04 09:27:15 +00:00
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:
@@ -309,12 +309,17 @@ func getEnv(key, fallback string) string {
|
||||
|
||||
func (s *SettingService) ResetSettings() error {
|
||||
db := database.GetDB()
|
||||
err := db.Where("1 = 1").Delete(model.Setting{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return db.Model(model.User{}).
|
||||
Where("1 = 1").Error
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Where("1 = 1").Delete(model.Setting{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
paths := []model.Setting{
|
||||
{Key: "subPath", Value: "/" + random.NumLower(16) + "/"},
|
||||
{Key: "subJsonPath", Value: "/" + random.NumLower(16) + "/"},
|
||||
{Key: "subClashPath", Value: "/" + random.NumLower(16) + "/"},
|
||||
}
|
||||
return tx.Create(&paths).Error
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SettingService) getSetting(key string) (*model.Setting, error) {
|
||||
|
||||
Reference in New Issue
Block a user