mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
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#5785
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/5107
Author: @MHSanaei
Created: 6/9/2026
Status: ✅ Merged
Merged: 6/9/2026
Merged by: @MHSanaei
Base:
main← Head:fix/mtproto-log-visibility📝 Commits (7)
549428dfix(logs): render journalctl output in the SysLog viewer216ab53feat(mtproto): surface mtg output and add status reporting981e9edfix(logs): parse all journalctl message shapes in SysLog viewer723933ffix(mtproto): reap orphaned mtg sidecars so a stale one can't break new clients421f18afix(logs): drop dead body initializer flagged by eslint no-useless-assignment3fffd4dfix(mtproto): drop remark fragment from tg://proxy export linkfc0365afix(x-ui.sh): remove unused check_mtproto_status helper📊 Changes
13 files changed (+397 additions, -71 deletions)
View changed files
📝
frontend/src/lib/xray/inbound-link.ts(+2 -5)📝
frontend/src/pages/index/LogModal.tsx(+1 -44)➕
frontend/src/pages/index/logParse.ts(+113 -0)➕
frontend/src/test/log-parse.test.ts(+80 -0)📝
install.sh(+5 -0)📝
mtproto/manager.go(+23 -4)➕
mtproto/orphans_linux.go(+79 -0)➕
mtproto/orphans_other.go(+9 -0)📝
mtproto/process.go(+46 -12)📝
mtproto/process_windows.go(+3 -3)📝
sub/subService.go(+2 -3)📝
update.sh(+5 -0)📝
x-ui.sh(+29 -0)📄 Description
Summary
Started from a report that mtproto works on Windows but not on a Linux server (traffic counted a few MB but Telegram never connected), and grew into fixing the root cause plus the log tooling that made it hard to diagnose. Also folds in a related mtproto export-link bug (#5105).
Root cause — orphaned
mtgsidecars (the real bug)mtproto inbounds run as standalone
mtgprocesses, one per inbound, outside Xray. On Linux x-ui does not kill itsmtgchildren when it dies (no kill-on-exit, unlike the Windows job object). After a crash /kill -9/ update / port change, a stalemtgkeeps holding the inbound port with an old secret, so new clients fail the FakeTLS handshake and get silently domain-fronted to the FakeTLS domain instead of proxied to Telegram — a few MB of traffic, never connects. It worked on Windows precisely because Windows does kill the children.Fix: on the first reconcile at startup — before x-ui starts any of its own
mtg— scan/procandSIGKILLany process whose executable is ourmtg-<goos>-<goarch>binary. x-ui is the sole owner ofmtg, so anything alive then is an orphan. Runs once per process (sweptguard), survives the binary-deleted-during-update case via/proc/<pid>/cmdline, and is a no-op on Windows/other platforms.update.sh/install.shalso clear straymtgafter stopping x-ui, anchored to themtg-linux-<arch> runinvocation so the pattern cannot match unrelated command lines.MTProto export link — drop the remark fragment (fixes #5105)
The mtproto export link appended the remark as a URL fragment (
tg://proxy?server=...&port=...&secret=...#remark). Telegram Desktop rejects a proxy deep link with a trailing fragment as "This proxy link is invalid", breaking one-click import, and a remark is meaningless for proxy links across clients. Removed in both the panel link (genMtprotoLink) and the subscription service.Log tooling fixes (made the orphan diagnosable)
journalctlreturns four different message shapes (go-loggingLEVEL - msg, Go std-log with embedded date, telego[ts] LEVEL msg, systemd). Rewrote it into a pure, tested module that handles all four. Added a unit test from real captured lines.inbound3on0.0.0.0:8443(afmt.Sprintspacing bug) fixed; affected mtproto log calls switched to the formatted variants.x-ui statusnow reports each mtproto inbound'smtgprocess state.Commits
549428d3fix(logs): render journalctl output in the SysLog viewer216ab53ffeat(mtproto): surface mtg output and add status reporting981e9ed9fix(logs): parse all journalctl message shapes in SysLog viewer723933f4fix(mtproto): reap orphaned mtg sidecars421f18a3fix(logs): drop dead initializer flagged by eslint3fffd4d4fix(mtproto): drop remark fragment from tg://proxy export link (#5105)Testing
mtgstarted/bound, FakeTLS handshake + all four Telegram DCs reachable, valid share link generated.go build(linux + windows),go vet,go test ./mtproto/... ./sub/...pass; frontendtsc,eslint, and 462 vitest tests pass; both shell scriptsbash -nclean.Known follow-up (not in this PR)
The startup sweep matches on binary basename. On a host running two x-ui instances that share the binary name, instance A's sweep could kill instance B's live
mtg. A follow-up can add a per-instance config-path ownership check before killing. Single-instance deployments (the norm) are unaffected.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.