mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6369] [MERGED] fix(mtproto): use hosts for public share links #6237
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#6237
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/6369
Author: @samssh
Created: 8/30/2026
Status: ✅ Merged
Merged: 9/8/2026
Merged by: @MHSanaei
Base:
main← Head:codex/fix-mtproto-host-share-links📝 Commits (7)
77a6195fix(mtproto): use hosts for public share links0c085adfix(mtproto): keep host share links lossless and consistent11c8469Merge branch 'main' into codex/fix-mtproto-host-share-links6066c3cMerge branch 'main' into codex/fix-mtproto-host-share-links7b7c834fix(mtproto): migrate legacy share address past unusable hosts604373dMerge branch 'main' into codex/fix-mtproto-host-share-links735aadefix(inbounds): wait for the hosts list before building mtproto links📊 Changes
21 files changed (+735 additions, -76 deletions)
View changed files
📝
docs/content/docs/en/reference/api/clients.mdx(+14 -14)📝
docs/public/openapi.json(+1 -1)📝
frontend/public/openapi.json(+1 -1)📝
frontend/src/lib/hosts/host-link.ts(+50 -1)📝
frontend/src/pages/api-docs/endpoints.ts(+1 -1)📝
frontend/src/pages/inbounds/InboundsPage.tsx(+42 -9)📝
frontend/src/pages/inbounds/form/InboundFormModal.tsx(+42 -31)📝
frontend/src/pages/inbounds/info/InboundInfoModal.tsx(+14 -2)📝
frontend/src/pages/inbounds/info/types.ts(+2 -0)📝
frontend/src/pages/inbounds/qr/QrCodeModal.tsx(+18 -4)📝
frontend/src/test/host-link.test.ts(+68 -1)📝
frontend/src/test/inbound-form-modal.test.tsx(+35 -0)📝
internal/database/db.go(+55 -0)📝
internal/database/host_migration_test.go(+165 -0)📝
internal/sub/links.go(+5 -0)📝
internal/sub/links_test.go(+21 -0)📝
internal/sub/service.go(+23 -11)📝
internal/sub/service_mtproto_test.go(+65 -0)📝
internal/web/service/inbound.go(+29 -0)📝
internal/web/service/inbound_import_external_proxy_test.go(+72 -0)...and 1 more files
📄 Description
Generate MTProto subscription, client, copy, QR, and export links from managed Hosts so reverse-proxied public ports are advertised correctly. Migrate the redundant legacy custom share address into a Host and keep old imports compatible.
Closes #5126.
Summary
Fix MTProto share-link generation to use managed Hosts, allowing a public host and port such as
proxy.example.com:443while MTG listens internally on another port.This also removes the redundant custom share-address option from MTProto inbounds and migrates legacy values to Hosts.
Why
MTProto links always used the inbound listener port, so reverse-proxied deployments exposed an internal port such as
4060instead of the public port443.Managed Hosts are already the canonical mechanism for advertising alternative endpoints. This change applies them consistently to MTProto subscription links, client links, Copy/QR output, and exports.
Closes #5126.
Refs #5534.
Type of change
Areas affected
How was this tested?
Added regression coverage for the following cases:
4060with a Host configured asproxy.example.com:443generates:server=proxy.example.comport=443Commands run:
Frontend result:
make test-gopassed all affected packages. One unrelated timing-sensitive test,TestEnsureHotReloadKeepsProcess, failed once during the full shuffled run and passed when rerun independently.Screenshots / recordings
Not included. The UI change only removes the redundant
Share address strategyandCustom share addresscontrols from the MTProto inbound form.Breaking changes
None.
Existing MTProto inbounds using a custom share address are migrated automatically:
No manual migration or API change is required.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.