Files
mirror-3x-ui/internal
Sanaei 8849518f50 fix(inbounds): refuse an inbound on a socket the panel itself listens on
The panel binds its web and subscription sockets before Xray starts, so
a local inbound on either leaves Xray unable to listen at all. Nothing
compared an inbound with those two sockets. Restoring a backup with this
machine's settings kept could therefore import a tunnel on the panel's
own port: the database was swapped first, and the failure only showed
when Xray would not start.

The rule is now stated once and every writer goes through it:

- A restore reads the backup's inbounds and the settings that will be in
  force afterwards (this machine's for kept keys, the backup's for the
  rest, XUI_PORT over both) and is refused before Xray is stopped or the
  database touched. All three paths do this: a SQLite file, a SQLite
  file imported into PostgreSQL, and a pg_dump archive, whose two tables
  pg_restore prints as a data script without a connection. Only enabled
  rows refuse a restore, so a backup holding a disabled leftover stays
  usable; enabling that row later is refused by the port check.
- Adding, editing and enabling an inbound run the same check.
- Saving panel settings, and x-ui setting -port / -listenIP, refuse to
  move a panel socket onto an inbound. A collision that already exists
  does not block later saves. The x-ui menu no longer reports a refused
  port or listen address as set.

One existing test put its inbound on 2053, the default panel port, for
no reason of its own; it now uses 2083.

Not covered: x-ui setting -reset and a changed XUI_PORT can still put
the panel on an inbound's port.

The PostgreSQL paths were run against PostgreSQL 18 with its pg_dump and
pg_restore; CI skips those tests. make node-e2e passes.

Closes #7115
2026-11-29 15:00:26 +03:30
..
2026-10-25 20:08:14 +01:00