Commit Graph

4 Commits

Author SHA1 Message Date
Hamed 38452eacf5 fix(database): guard inbound migrations against active PostgreSQL writes (#7321)
Prevent inbound data migration from waiting behind concurrent PostgreSQL node/client writes: acquire the complete write-table set with EXCLUSIVE NOWAIT before any DML, use ACCESS EXCLUSIVE only for tables requiring legacy DDL, and surface SQLSTATE 55P03 as retryable contention. Plain SELECT remains compatible with the normal lock set.

Commit inbound normalization, orphan traffic cleanup and Vision flow repair together; propagate failures to CLI and restore callers and record transaction duration. Keep the reopened database pool private during host-settings restoration and inbound migration, with bounded retries of lock acquisition.

Remove duplicate post-start migration and fail installation/update before service startup when migration fails. Preserve the stopped/disabled service unit so systemd and OpenRC updates can be retried; replace the unit only after successful migration.

Verified reviewed head 56e0372a09: all 12 CI jobs passed, including PostgreSQL contention/reader/private-pool regressions and Go/race. Detached test merge against main d6afe0ef3c was conflict-free and git diff --check passed. Integrated local targeted tests passed for private pool, telemetry migration, SQLite rollback, and shared descendant selection (all eight subcases); PostgreSQL-specific tests skipped locally and verified in PR CI. Full integrated CI and live service-manager testing were not rerun.

This is a scoped fix, not an atomic whole-database restore or proof of resolution of the historical 41-second SQL tail. Persistent external writers or post-import migration errors can still leave an already committed import requiring recovery; broader schema/restore maintenance coordination and writer occupancy investigation remain open.

Review: https://github.com/MHSanaei/3x-ui/pull/7321#issuecomment-7364094359
Refs #7305 (keep open).
2026-12-03 04:48:16 +03:30
Hamed 428dfe7709 fix(iplimit): persist Fail2ban enforcement consent (#7239)
Removing IP Limit from the x-ui menu saved nothing, so the next update, reinstall or panel self-update installed Fail2ban again and re-enabled the host-wide 3x-ipl jail.

The choice is now written to the panel's env file and every later install and update reads it first. A fresh native install asks before enabling enforcement (Enter declines) and an unattended one enables it only with XUI_ENABLE_FAIL2BAN=true; a stored choice wins over the process environment. Hosts that already have the jail configured and nothing stored are left as they are. The menu restarts the panel so it runs with the same value, and OpenRC exports it to the service.

Removal and reload touch only the managed jail, and the package is uninstalled only when 3x-ipl is the sole jail, so a distro-enabled sshd jail keeps Fail2ban installed. The journal backend override for Debian 12+ and Ubuntu 22.04+ now targets the stock sshd jail and leaves operator backend and log settings alone.

Fixes #7222
2026-11-28 18:13:26 +03:30
Hamed 728c2fb94f fix(install): handle yes responses and validate panel ports (#6992)
The panel-port prompt accepted only y/Y, so yes picked a random port; a custom port was never validated (empty, non-numeric, out-of-range, busy, or leading-zero octal), is_port_in_use never detected a listener, and the installer printed success even when applying the settings failed. Answers are now case-insensitive, custom ports are normalized and checked, the port check is fixed, and the install aborts unless the CLI reports every setting applied. A bash suite runs in shell-lint.
2026-11-03 15:52:14 +01:00
Hamed 09799ff734 fix(scripts): preserve custom webBasePath during updates (#6964)
install.sh and update.sh stripped the leading slash and regenerated webBasePath whenever the rest was shorter than four characters, so valid short paths such as /a/ or /ab/ were replaced by a random one on every update or reinstall. Only an empty or root path is initialized now, and both scripts read one settings snapshot and leave the settings alone when that read fails or is malformed. Fixes #6961.
2026-11-02 15:35:20 +01:00