Skip to content

feat(mtproto): add MTPROTO backend type and Mtproto proxy - #3

Open
T3ST3ST3R0N wants to merge 1 commit into
PasarGuard:mainfrom
T3ST3ST3R0N:feat/mtproto
Open

feat(mtproto): add MTPROTO backend type and Mtproto proxy#3
T3ST3ST3R0N wants to merge 1 commit into
PasarGuard:mainfrom
T3ST3ST3R0N:feat/mtproto

Conversation

@T3ST3ST3R0N

@T3ST3ST3R0N T3ST3ST3R0N commented Jun 29, 2026

Copy link
Copy Markdown

Syncs the bridge with the new MTProto backend in PasarGuard/node (PR #61).

Changes

  • proto: BackendType.MTPROTO, a Mtproto proxy message (secret, user_ad_tag, max_tcp_conns, max_unique_ips), and Proxy.mtproto
  • regenerated common/service.pb.go and common/service_grpc.pb.go
  • common/funcs.go: added CreateMtproto(secret, userAdTag, maxTcpConns, maxUniqueIps) and extended CreateProxies with the mtproto argument

Notes

Data quota and expiry are intentionally not part of the message. The panel owns quota and expiry enforcement (usage reporting plus user sync), the same as for the xray and wireguard backends, so the node never hands them to telemt.

CreateProxies gains a trailing mtproto *Mtproto argument, so callers must pass it (use nil when not configuring MTProto).

Summary by CodeRabbit

  • New Features

    • Added support for an additional proxy/backend option, including configuration fields for MTProto.
    • Proxies can now carry MTProto settings alongside existing connection types.
  • Tests

    • Updated test setup to include the new proxy configuration format.

Sync the service proto with PasarGuard/node: BackendType.MTPROTO, a Mtproto proxy message (secret, user_ad_tag, max_tcp_conns, max_unique_ips), and Proxy.mtproto. Regenerate the gRPC/protobuf code and add a CreateMtproto helper, extending CreateProxies with the mtproto argument. Quota and expiry are intentionally omitted; the panel owns them.

Ref: PasarGuard/node#61
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds MTProto as a new backend type: MTPROTO = 2 is added to the BackendType enum, a new Mtproto message is defined in service.proto, and Proxy gains a mtproto field. CreateMtproto factory function is added and CreateProxies is extended with an mtproto *Mtproto parameter. The test fixture is updated to pass nil for the new argument.

Changes

MTProto Backend Addition

Layer / File(s) Summary
Proto schema: Mtproto message and BackendType enum
common/service.proto
Adds MTPROTO = 2 to BackendType, introduces Mtproto message with secret, user_ad_tag, max_tcp_conns, max_unique_ips fields, and adds mtproto as field 7 on Proxy.
CreateMtproto constructor and CreateProxies signature
common/funcs.go
Adds CreateMtproto factory function and updates CreateProxies to accept and populate the new mtproto *Mtproto parameter on the returned Proxy.
Test fixture call site update
bridge_test.go
Passes nil as the new mtproto argument in the CreateProxies call for the user fixture.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 A new tunnel hops into the fray,
MTProto joins Wireguard today.
A nil slips in where the message will go,
Secret fields lined up in a row.
The rabbit nods — the proxy's complete! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding an MTPROTO backend type and Mtproto proxy support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@T3ST3ST3R0N

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
bridge_test.go (1)

69-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add one positive MTProto fixture path.

This update only preserves the pre-existing nil path, so the new CreateMtproto(...)/Proxy.Mtproto wiring still has no direct test coverage. A small test that passes a non-nil MTProto config and asserts it survives CreateProxies/CreateUser would catch future regressions cheaply.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bridge_test.go` at line 69, Add a positive MTProto test case alongside the
existing nil path in bridge_test.go so the new CreateMtproto and Proxy.Mtproto
wiring is actually exercised. Update the relevant bridge test around
CreateProxies and CreateUser to pass a non-nil MTProto config, then assert the
resulting proxy/user state preserves that configuration instead of only covering
the nil case. Use the existing CreateMtproto, CreateProxies, and CreateUser
symbols to anchor the new coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@bridge_test.go`:
- Line 69: Add a positive MTProto test case alongside the existing nil path in
bridge_test.go so the new CreateMtproto and Proxy.Mtproto wiring is actually
exercised. Update the relevant bridge test around CreateProxies and CreateUser
to pass a non-nil MTProto config, then assert the resulting proxy/user state
preserves that configuration instead of only covering the nil case. Use the
existing CreateMtproto, CreateProxies, and CreateUser symbols to anchor the new
coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 77b5f85e-b105-4c0a-be20-e9dd6d7f2fef

📥 Commits

Reviewing files that changed from the base of the PR and between d70a9eb and fbe88da.

⛔ Files ignored due to path filters (2)
  • common/service.pb.go is excluded by !**/*.pb.go
  • common/service_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (3)
  • bridge_test.go
  • common/funcs.go
  • common/service.proto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant