mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6761] [CLOSED] feat(mtproto): expose mtg-multi settings for MTProto inbounds #6444
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#6444
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/6761
Author: @AndreyOsipuk
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:feat/mtproto-secured-dcpool📝 Commits (10+)
e6bfe52feat(mtproto): secured (dd) clients and warm DC pool options93f885cfeat(sub): add dd links for secured MTProto inboundsb7ec51cfeat(frontend): secured and warm DC pool settings for MTProto inboundsb7a7bb1feat(mtproto): expose the remaining mtg-multi options for MTProto inbounds6c2b49bfeat(sub): add tg://webproxy links for MTProto inbounds in WEB mode38bf58efeat(frontend): advanced mtg settings for MTProto inboundsd0e4b95fix(mtproto): say which mtg-multi build serves secured and WEB linksc8cb2c2style(mtproto): keep comment blocks to two lines4e747c0Merge branch 'main' into feat/mtproto-secured-dcpool8049e30fix(mtproto): gate secured and WEB on a confirmed mtg-multi build, drop the DC list📊 Changes
33 files changed (+4182 additions, -50 deletions)
View changed files
📝
frontend/src/lib/xray/inbound-link.ts(+82 -23)📝
frontend/src/lib/xray/link-label.tsx(+5 -1)📝
frontend/src/pages/inbounds/form/protocols/mtproto.tsx(+356 -1)📝
frontend/src/schemas/forms/inbound-form.ts(+10 -3)📝
frontend/src/schemas/protocols/inbound/mtproto.ts(+163 -0)📝
frontend/src/test/link-label.test.ts(+7 -0)📝
frontend/src/test/mtproto-clients-link.test.ts(+54 -2)➕
frontend/src/test/mtproto-options.test.tsx(+345 -0)📝
go.mod(+1 -1)📝
internal/database/model/model.go(+23 -0)📝
internal/database/model/model_mtproto_test.go(+34 -0)📝
internal/mtproto/manager.go(+75 -9)📝
internal/mtproto/manager_test.go(+104 -1)➕
internal/mtproto/options.go(+722 -0)➕
internal/mtproto/options_test.go(+447 -0)📝
internal/sub/service.go(+23 -8)📝
internal/sub/service_mtproto_test.go(+127 -1)📝
internal/web/service/inbound.go(+6 -0)📝
internal/web/service/inbound_mtproto.go(+13 -0)📝
internal/web/service/inbound_mtproto_test.go(+64 -0)...and 13 more files
📄 Description
Summary
MTProto inbounds are served by an mtg-multi sidecar, but the panel only exposed a handful of its settings; everything else needed a hand-edited config that the panel then overwrote. This PR exposes the rest of mtg-multi's per-inbound settings in the inbound settings and form:
main;tg://webproxylinks), with the client's webproxy link in the subscription, client page and QR/info modals;mtgSecuredWebBuild(off by default), without which Secured and WEB are neither rendered nor linked, because the released mtg-multi does not serve them yet (see below);Nothing changes by default. A setting is written to the generated config only when it is set, so an inbound that sets none of them renders a byte-identical config (covered by the existing golden test) and its sidecar is not restarted on upgrade. Unset settings fall back to mtg's own defaults.
Settings
All new settings are optional, live under the inbound
settingsJSON and are grouped in collapsed "Advanced" sections of the form.mtgSecuredWebBuildsecured[secured] enabledmtgSecuredWebBuilddcPool.enabled,dcPool.size[dc-pool] enabled,sizeconcurrencyconcurrencytolerateTimeSkewnesstolerate-time-skewnessallowFallbackOnUnknownDcallow-fallback-on-unknown-dcautoUpdateauto-updatethrottleCheckInterval[throttle] check-intervalnetwork.dns[network] dnsudp://IP,tls://host,https://...network.proxies[network] proxiessocks5://URLs; rejected together with routing through Xraynetwork.tcpNotSentLowat[network] tcp-not-sent-lowat128kib)network.timeout.{tcp,http,idle,handshake}[network.timeout]network.keepAlive.{disabled,idle,interval,count}[network.keep-alive]defense.antiReplay.{enabled,maxSize,errorRate}[defense.anti-replay]defense.blocklist/defense.allowlist.{enabled,urls,updateEach,downloadConcurrency}[defense.blocklist]/[defense.allowlist]defense.doppelganger.{urls,repeatsPerRaid,raidEach,drs}[defense.doppelganger]defense.pendingHandshakes.{maxPerIp,dryRun}[defense.pending-handshakes]stats.prometheus.{enabled,bindTo,httpPath,metricPrefix}[stats.prometheus]bindToloopbackIP:port, required when enabledstats.statsd.{enabled,address,metricPrefix,tagFormat}[stats.statsd]IP:port,datadog/influxdb/graphiteweb.{bindTo,host,secretMode,decoyDir,trustedProxies,maxSessions,maxPending,diag}[web]bindToloopbackIP:port,hosta domain,dd/plain, absolute dir, CIDRs; a listener is refused on save withoutmtgSecuredWebBuildextraTomlNotes:
[network] proxies. The two cannot be combined, and the form hides the proxies field while routing is on.ad-tagis already set per client,usage-state-fileis a filesystem path (Extra TOML), anddomain-fronting-*/doh-ipare deprecated in favour of the keys the panel writes.Extra TOML
Free-form mtg config merged under the generated one. Keys the panel writes win, and tables are merged key by key.
[secrets],[secret-limits],[secret-ad-tags],secret,bind-to,api-bind-toandapi-tokenare rejected on save and dropped on render, because the panel manages clients and the sidecar's API through them. A block that adds nothing leaves the config byte-identical. Otherwise the non-client part of the config is re-encoded, and the client sections still follow with[secrets]last.WEB links
When an inbound serves the WEB mode (
mtgSecuredWebBuildon,web.bindToandweb.hostset), each client also getstg://webproxy?server=<web.host>&secret=<key>. The key is the client's FakeTLS key with addprefix (defaultddmode) or bare (plainmode). This matches what mtg-multi's WEB mode derives the capability from. The link appears in the subscription, the client page and the info/QR modals, where its remark is suffixed-weband its label reads WEB.Compatibility with mtg-multi builds
mtg-multi decodes its config with
go-tomlin non-strict mode, so a build ignores sections and keys it does not know. I checked this by generating a config with every setting above set (with and without an Extra TOML block). I then ranmtg-multi runon it frommhsanaei/mtg-multimainand from each feature branch (#5, #7, #8, #9). Every build started and kept serving; old builds silently ignore[secured],[dc-pool],[defense.pending-handshakes]and[web].The latest release, v1.15.0 (what
DockerInit.shand the release workflow install), has neither secured nor WEB mode. A dd ortg://webproxylink to it fails at handshake, and subscribers never see the form's hints. So the panel does not rely on the operator reading a hint:mtgSecuredWebBuildis an inbound switch, off by default, with which the operator confirms that the host runs a build with secured and WEB mode. The panel cannot ask mtg-multi what it supports: it has no version or capability output, no release has these modes yet, and on a multi-node setup the binary runs on another host.[secured]or[web]section is rendered (also not from Extra TOML, which drops them), and no dd ortg://webproxylink goes into the subscription, the client page or the panel's links/QR codes (Go and TS).AddInbound/UpdateInbound) and in the inbound form. An inbound stored before the switch still loads; it just serves no dd/WEB links until the switch is on.For the other settings on an older build:
dcPoolandpendingHandshakeshave no effect.The warm pool's DC list (
dcPool.dcs) was removed: no mtg-multi build or open PR parses it.Dependencies and merge order
mtgSecuredWebBuild.client-mss, needs MHSanaei/mtg-multi#10) is stacked on this PR. Merge order: #6761 first, then #6765.Tests
[network]is written once and unset settings change nothing;AddInboundandUpdateInbound;[secrets]last;ddandplainmodes and their absence for an invalid or incomplete WEB section;[secured]/[web]from the form or Extra TOML, no dd/webproxy links, and a save error for Secured, a WEB listener or Extra TOML[secured]/[web]; with it on all of them work;go vet ./...,go test ./...,golangci-lint run(0 issues),make gen(no diff); frontend on Node 26format:check,lint,typecheck,vitest(unit and components projects) andbuild.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.