alireza0:3x-ui 删除主机绑定会错误清空客户端其他入站

alireza0 在 3x-ui PR #6920 说明:客户端同时绑定入站 A、B 而只在 A 绑定主机时,删除该主机会让客户端在所有入站上进入关闭状态,连 B 的订阅链接也被清空;他建议在绑定记录中保存入站 ID,将失效状态限定到受保护的入站,或在删除前提示受影响客户端。

作者原文

Re-checked the head after the latest commits. The earlier review findings hold up:

  • Editing an address keeps the row id. Disabling the same-inbound leftover pairing turns TestUpdateHostGroup_AddressEditKeepsHostId red.
  • A deleted-only binding fails closed. Making len(rows) == 0 return hostBindingNone turns the deleted-only subtest red.

One remaining gap: deleting a client's only bound host blanks that client on every inbound, not just the one the binding was for. When every bound id is gone, clientHostBinding returns hostBindingClosed for every inbound it is asked about, because once the rows are deleted it can no longer tell which inbound they belonged to.

Repro: a client is attached to inbounds A and B and bound only to a host on A. The subscription has B's link. Delete that host with DELETE on hosts and B's link is gone too. Inbound B never had anything to hide, and the panel gives the operator no sign that deleting a host rule just emptied some clients' subscriptions.

Since this isn't merged yet, the cheapest fix is to scope the fail-closed state to the inbound it protects, by storing each binding with its inbound id alongside the host id. A dangling binding then closes only that inbound and leaves the client's other inbounds alone. If that's too much for this PR, asking for confirmation when deleting a host group that clients are bound to, and listing those clients, would at least make the outage visible.