fix(inbound): convert legacy externalProxy to hosts on import

An inbound exported from a build that predated the hosts table carries
its external proxies inline in streamSettings.externalProxy. The startup
migration that converts those to host rows runs once and is gated off
afterwards, so it never sees a freshly imported inbound, leaving its
external proxies stranded in streamSettings (never surfaced as Hosts).

Extract the migration's per-inbound conversion into a shared
database.CreateHostsFromExternalProxy and run it inside the AddInbound
transaction. No-op for inbounds without externalProxy (everything the
current UI builds), so it only fires on such imports.
This commit is contained in:
MHSanaei
2026-06-27 13:50:06 +02:00
parent 876d55f274
commit 39eb5baf42
3 changed files with 149 additions and 20 deletions
+10
View File
@@ -705,6 +705,16 @@ func (s *InboundService) AddInbound(inbound *model.Inbound) (*model.Inbound, boo
return inbound, false, err
}
// Legacy import: an inbound exported from a build that predated the hosts
// table carries its external proxies inline in streamSettings.externalProxy.
// The startup migration that converts those to host rows runs once and is
// gated off afterwards, so it never sees a freshly imported inbound —
// reproduce it here. No-op for inbounds without externalProxy (everything the
// current UI builds), so this only fires on such imports.
if _, err = database.CreateHostsFromExternalProxy(tx, inbound.Id, inbound.StreamSettings); err != nil {
return inbound, false, err
}
// Before the deferred commit, so a node in "selected" sync mode cannot
// sweep the new central row in the gap before its tag is allowed.
if inbound.NodeID != nil {