[GH-ISSUE #5515] [Feature]: More MtProto Users (Secret) #3849

Closed
opened 2026-10-31 20:35:23 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @CodeRoK7 on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5515

Hello.
Add the ability to create multiple Secret keys within a single section, so that multiple Secret users can be served on a single port and configuration, rather than just one as is currently the case.

Describe the solution you'd like

!

Alternatives you've considered

!

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

No response

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @CodeRoK7 on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5515 ### Is your feature request related to a problem? Hello. Add the ability to create multiple Secret keys within a single section, so that multiple Secret users can be served on a single port and configuration, rather than just one as is currently the case. ### Describe the solution you'd like ! ### Alternatives you've considered ! ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? _No response_ ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 23, 2026):

The current architecture makes this non-trivial to implement, and the core blocker is the underlying mtg binary itself.

How MTProto inbounds work today

3x-ui does not run MTProto through Xray-core. Instead, it spawns one mtg (github.com/9seconds/mtg v2) sidecar process per MTProto inbound — one process per port — and generates a TOML config for each one (internal/mtproto/manager.go, renderConfig). That generated config contains a single scalar secret field:

secret = "<one-hex-string>"
bind-to = "0.0.0.0:<port>"

The panel's Instance struct (internal/mtproto/manager.go:21) likewise holds exactly one Secret string. There is no array or list of secrets anywhere in the current data model, config generation, or database schema.

Why multiple secrets per port is not straightforward

The mtg v2 TOML format accepts a single secret value per process; it has no configuration key for a list of secrets. Supporting multiple secrets on a single port would require one of:

  1. Upstream support in mtg: mtg itself would need to add a secrets = [...] configuration option. That is an upstream feature request at github.com/9seconds/mtg, not something 3x-ui can address on its own.
  2. A multiplexer in front of multiple mtg processes: run one mtg per secret (each on a different loopback port) and front them all with something like HAProxy that dispatches by secret prefix. This is architecturally complex and introduces a new runtime dependency.

Current workaround

The existing approach to serve multiple secrets is to create multiple MTProto inbounds. Each gets a separate port and a separate mtg process with its own secret. Clients are simply given the appropriate per-port link. This is less elegant than a single shared port but is fully functional with the current stack.

If this feature is important to you, the most actionable path is to open or upvote an issue at the mtg repository (github.com/9seconds/mtg) requesting multi-secret support in the TOML config. If mtg adds it, the panel-side changes (Instance, renderConfig, the database settings JSON, and the UI form) would be the follow-on work.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4782846473 --> @github-actions[bot] commented on GitHub (Jun 23, 2026): The current architecture makes this non-trivial to implement, and the core blocker is the underlying `mtg` binary itself. **How MTProto inbounds work today** 3x-ui does not run MTProto through Xray-core. Instead, it spawns one `mtg` (github.com/9seconds/mtg v2) sidecar process per MTProto inbound — one process per port — and generates a TOML config for each one (`internal/mtproto/manager.go`, `renderConfig`). That generated config contains a single scalar secret field: ```toml secret = "<one-hex-string>" bind-to = "0.0.0.0:<port>" ``` The panel's `Instance` struct (`internal/mtproto/manager.go:21`) likewise holds exactly one `Secret string`. There is no array or list of secrets anywhere in the current data model, config generation, or database schema. **Why multiple secrets per port is not straightforward** The mtg v2 TOML format accepts a single `secret` value per process; it has no configuration key for a list of secrets. Supporting multiple secrets on a single port would require one of: 1. **Upstream support in mtg**: mtg itself would need to add a `secrets = [...]` configuration option. That is an upstream feature request at github.com/9seconds/mtg, not something 3x-ui can address on its own. 2. **A multiplexer in front of multiple mtg processes**: run one mtg per secret (each on a different loopback port) and front them all with something like HAProxy that dispatches by secret prefix. This is architecturally complex and introduces a new runtime dependency. **Current workaround** The existing approach to serve multiple secrets is to create multiple MTProto inbounds. Each gets a separate port and a separate `mtg` process with its own secret. Clients are simply given the appropriate per-port link. This is less elegant than a single shared port but is fully functional with the current stack. If this feature is important to you, the most actionable path is to open or upvote an issue at the mtg repository (github.com/9seconds/mtg) requesting multi-secret support in the TOML config. If mtg adds it, the panel-side changes (`Instance`, `renderConfig`, the database settings JSON, and the UI form) would be the follow-on work. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@CodeRoK7 commented on GitHub (Jun 23, 2026):

Here it is https://github.com/nolaxe/install-MTProxy. it is implemented, one port, many secrets and no problems. It is convenient than creating a bunch of separate ports with mtproto sections.

<!-- gh-comment-id:4782922452 --> @CodeRoK7 commented on GitHub (Jun 23, 2026): Here it is https://github.com/nolaxe/install-MTProxy. it is implemented, one port, many secrets and no problems. It is convenient than creating a bunch of separate ports with mtproto sections.
Author
Owner

@CodeRoK7 commented on GitHub (Jun 24, 2026):

in the end, it looks like this, meaning that all the added users have the same IP and port for connecting, but different SECRET

Main user link
Docker: tg://proxy?server=IP&port=4433&secret=SECRET1
 Additional users
mytelefone tg://proxy?server=IP&port=4433&secret=SECRET1
myjob tg://proxy?server=IP&port=4433&secret=SECRET2
olyatelefone tg://proxy?server=IP&port=4433&secret=SECRET3
 ... all links saved to proxy_link.txt
Metrics: IP:9091/metrics
<!-- gh-comment-id:4785253478 --> @CodeRoK7 commented on GitHub (Jun 24, 2026): in the end, it looks like this, meaning that all the added users have the same IP and port for connecting, but different SECRET ``` Main user link Docker: tg://proxy?server=IP&port=4433&secret=SECRET1 Additional users mytelefone tg://proxy?server=IP&port=4433&secret=SECRET1 myjob tg://proxy?server=IP&port=4433&secret=SECRET2 olyatelefone tg://proxy?server=IP&port=4433&secret=SECRET3 ... all links saved to proxy_link.txt Metrics: IP:9091/metrics ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3849
No description provided.