mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-29 06:27:14 +00:00
fix(tgbot): clear legacy panelProxy/tgBotProxy settings on upgrade
v3.3.1 removed the Panel Proxy URL field from the UI but left the stored panelProxy/tgBotProxy values in the DB. The Telegram bot still reads tgBotProxy directly, so a stale value masked the panelOutbound egress fallback. Add a one-off seeder to drop both rows. Closes #5266
This commit is contained in:
+19
-1
@@ -200,7 +200,7 @@ func runSeeders(isUsersEmpty bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if empty && isUsersEmpty {
|
if empty && isUsersEmpty {
|
||||||
seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "ApiTokensHash"}
|
seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "ApiTokensHash", "LegacyProxySettingsCleanup"}
|
||||||
for _, name := range seeders {
|
for _, name := range seeders {
|
||||||
if err := db.Create(&model.HistoryOfSeeders{SeederName: name}).Error; err != nil {
|
if err := db.Create(&model.HistoryOfSeeders{SeederName: name}).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -286,9 +286,27 @@ func runSeeders(isUsersEmpty bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !slices.Contains(seedersHistory, "LegacyProxySettingsCleanup") {
|
||||||
|
if err := clearLegacyProxySettings(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clearLegacyProxySettings drops the deprecated panelProxy/tgBotProxy rows so a
|
||||||
|
// stale tgBotProxy no longer masks the panelOutbound egress fallback.
|
||||||
|
func clearLegacyProxySettings() error {
|
||||||
|
return db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err := tx.Where("key IN ?", []string{"panelProxy", "tgBotProxy"}).
|
||||||
|
Delete(&model.Setting{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Create(&model.HistoryOfSeeders{SeederName: "LegacyProxySettingsCleanup"}).Error
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user