mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6227] [MERGED] feat(server): keep this machine's own settings when importing a database #6189
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6189
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6227
Author: @n0ctal
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-keep-host-settings-on-import📝 Commits (4)
301d274feat(server): keep this machine's own settings when importing a database55ce879fix(server): drop imported host settings this machine never had, and cover Postgresc6f7266chore: drop the accidentally committed dist build stub8ca7a6dMerge branch 'main' into upstream-keep-host-settings-on-import📊 Changes
17 files changed (+248 additions, -20 deletions)
View changed files
📝
frontend/src/pages/index/BackupModal.tsx(+13 -1)📝
internal/web/controller/server.go(+5 -1)➕
internal/web/service/import_host_settings_test.go(+99 -0)📝
internal/web/service/server.go(+92 -5)📝
internal/web/translation/ar-EG.json(+3 -1)📝
internal/web/translation/en-US.json(+3 -1)📝
internal/web/translation/es-ES.json(+3 -1)📝
internal/web/translation/fa-IR.json(+3 -1)📝
internal/web/translation/id-ID.json(+3 -1)📝
internal/web/translation/ja-JP.json(+3 -1)📝
internal/web/translation/pt-BR.json(+3 -1)📝
internal/web/translation/ru-RU.json(+3 -1)📝
internal/web/translation/tr-TR.json(+3 -1)📝
internal/web/translation/uk-UA.json(+3 -1)📝
internal/web/translation/vi-VN.json(+3 -1)📝
internal/web/translation/zh-CN.json(+3 -1)📝
internal/web/translation/zh-TW.json(+3 -1)📄 Description
Closes #5004.
Summary
Import replaces the whole database, so the uploaded file's listen addresses, ports, base path, certificate paths and node identity land on the destination machine. Moving a configuration to a new host leaves the panel answering on an address it does not own and presenting certificates it does not have — the reporter's "the panel broke due to ssl config errors".
This keeps the destination's own host-bound settings and takes everything else from the file.
Why not filter on export
That was the shape the issue asked for, and it is the weaker half of the fix.
getDbstreams the SQLite file byte-for-byte, so filtering means building and shipping a modified copy — and it only helps exports taken after the change. Every backup already sitting on someone's disk still breaks on restore.Doing it on import fixes those too, and removes the failure mode where the box was simply not ticked.
What counts as host-bound
The first two rows are the reachability the reporter lost.
secretandpanelGuididentify the panel itself. The mTLS material is the identity this panel presents to its nodes — importing another machine's would leave two panels claiming the same identity, which is worse than an unreachable port because it fails silently.Everything else — inbounds, clients, users, templates, all remaining settings — still comes from the imported file, which is what the feature is for.
Interface
A checkbox in the backup dialog, defaulting to keeping this machine's values. Clearing it restores today's behaviour for anyone deliberately cloning a host. The controller treats a missing field as "keep", so an API caller that has not been updated gets the safe path.
Validation
TestImportKeepsHostBoundSettingsseeds this machine's values, overwrites them the way an import does, restores, and asserts each host-bound key holds the local value while an ordinary setting (remarkTemplate) still holds the imported one — so the test fails both if preservation stops working and if it starts swallowing settings it should not.Mutation-checked: making
restoreHostBoundSettingsa no-op turns it red withsetting subURI = "from-imported-file" after import, want this machine's "https://this-host.example/sub/".go build ./...,go vet,golangci-lintclean; 36 Go packages green; frontend typecheck, eslint and the 936-test unit suite green.Risk
Low, and the sharp edge is named: someone who wants the source machine's certificates and ports must now clear the checkbox. That trade is deliberate — the silent-breakage direction is the one that costs an evening of debugging on a machine you have just migrated to.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.