[GH-ISSUE #6437] [Feature]: Support Mieru protocol for port-hopping and anti-probing resilience #4359

Open
opened 2026-10-31 20:39:06 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Iaslav24 on GitHub (Sep 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6437

In regions with aggressive DPI filtering (such as Russia, China, and Iran), traditional TLS/Reality setups and single-port UDP connections are increasingly facing port-based throttling, IP bans, and active probing. Censors easily detect and throttle persistent high-bandwidth connections tied to a single listening port.

Describe the solution you'd like

Integrate the Mieru protocol (github.com/enigmasa/mieru) as a supported inbound, similar to how userspace AmneziaWG was recently introduced.

Desired implementation:

  1. Inbound Settings:
    • Protocol option: mieru
    • Port or Port Range support for port-hopping (e.g. 40000-40050)
    • Transport selection: TCP or UDP
    • User authentication: Username & Password
    • Multiplexing configuration
  2. Traffic handling:
    • Embed Mieru via Go userspace service/handler.
    • Forward decrypted traffic internally to local routing/outbounds.
  3. Subscription/Export:
    • Generate exportable connection parameters / QR codes compatible with Mieru clients.

Repository reference: https://github.com/enigmasa/mieru

Alternatives you've considered

Tried using VLESS-Reality, AmneziaWG, and standard Shadowsocks. While Reality works well for general browsing, aggressive ISP filters frequently throttle high-bandwidth single-port connections. AmneziaWG helps with header obfuscation, but without dynamic port-hopping, censors can still flag and throttle persistent UDP flows to a single destination port. Mieru addresses both active probing and port-based throttling simultaneously.

Concrete use case

Managing a private server for users in heavily censored regions (Russia, Iran, China). During DPI throttling waves, continuous traffic on a single static port (even VLESS-Reality on 443 or AWG) frequently gets throttled to unusable speeds (<1 Mbps) or dropped. Mieru's port-hopping and active-probing resistance allow users to maintain a persistent, reliable connection by dynamically rotating ports without needing to change server endpoints manually.

Mockups, screenshots, or examples

Example inbound JSON structure:

{
  "protocol": "mieru",
  "port": "40000-40050",
  "settings": {
    "users": [
      {
        "username": "user1",
        "password": "StrongPassword123"
      }
    ],
    "transport": "UDP",
    "multiplexing": 1
  }
}

### Which parts of the panel would this affect?

Backend (API endpoints, login, settings), Subscription (share links / Clash / JSON), Statistics / traffic counters, Frontend (UI / panel pages)

### Are you willing to help?

- [ ] I'd like to implement this feature myself and open a PR.
- [x] 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.
Originally created by @Iaslav24 on GitHub (Sep 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6437 ### Is your feature request related to a problem? In regions with aggressive DPI filtering (such as Russia, China, and Iran), traditional TLS/Reality setups and single-port UDP connections are increasingly facing port-based throttling, IP bans, and active probing. Censors easily detect and throttle persistent high-bandwidth connections tied to a single listening port. ### Describe the solution you'd like Integrate the Mieru protocol (`github.com/enigmasa/mieru`) as a supported inbound, similar to how userspace AmneziaWG was recently introduced. Desired implementation: 1. Inbound Settings: - Protocol option: `mieru` - Port or Port Range support for port-hopping (e.g. `40000-40050`) - Transport selection: `TCP` or `UDP` - User authentication: Username & Password - Multiplexing configuration 2. Traffic handling: - Embed Mieru via Go userspace service/handler. - Forward decrypted traffic internally to local routing/outbounds. 3. Subscription/Export: - Generate exportable connection parameters / QR codes compatible with Mieru clients. Repository reference: https://github.com/enigmasa/mieru ### Alternatives you've considered Tried using VLESS-Reality, AmneziaWG, and standard Shadowsocks. While Reality works well for general browsing, aggressive ISP filters frequently throttle high-bandwidth single-port connections. AmneziaWG helps with header obfuscation, but without dynamic port-hopping, censors can still flag and throttle persistent UDP flows to a single destination port. Mieru addresses both active probing and port-based throttling simultaneously. ### Concrete use case Managing a private server for users in heavily censored regions (Russia, Iran, China). During DPI throttling waves, continuous traffic on a single static port (even VLESS-Reality on 443 or AWG) frequently gets throttled to unusable speeds (<1 Mbps) or dropped. Mieru's port-hopping and active-probing resistance allow users to maintain a persistent, reliable connection by dynamically rotating ports without needing to change server endpoints manually. ### Mockups, screenshots, or examples Example inbound JSON structure: ```json { "protocol": "mieru", "port": "40000-40050", "settings": { "users": [ { "username": "user1", "password": "StrongPassword123" } ], "transport": "UDP", "multiplexing": 1 } } ### Which parts of the panel would this affect? Backend (API endpoints, login, settings), Subscription (share links / Clash / JSON), Statistics / traffic counters, Frontend (UI / panel pages) ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] 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 (Sep 9, 2026):

Thanks — this is a legitimate feature request, and nothing in the panel supports Mieru today (no mieru string exists anywhere in the repository). It is worth saying up front that this cannot be a small addition, and that the port-hopping half of what you are after already has a partial answer in the panel today.

Why Mieru is not a drop-in

The panel's protocol set is fixed in one place, internal/database/model/model.go:24-36, and enforced on the inbound:

// internal/database/model/model.go:65
Protocol Protocol `json:"protocol" form:"protocol" validate:"required,oneof=vmess vless trojan shadowsocks wireguard hysteria http mixed tunnel tun mtproto amneziawg" example:"vless"`

Everything in that list except mtproto and amneziawg is a native Xray-core inbound — the panel builds the account objects straight from Xray-core's own proto types (internal/xray/api.go:614, case "hysteria": → hysteriaAccount.Account). Mieru is not one of those: no mieru module appears in go.sum, so the pinned core (github.com/xtls/xray-core v1.260327.1-0.20260908222543-52a412d9e2f5, go.mod:28) does not carry it either.

So Mieru would have to become the third out-of-core runtime, next to the two exceptions you correctly identified:

  • MTProto — a supervised sidecar binary, one process per inbound (internal/mtproto/, docs/architecture.md §1).
  • AmneziaWG — in-process userspace runtime (internal/amneziawgnet/). Its introduction, effcccce feat(amneziawg): add native AmneziaWG protocol support (#6105), changed 146 files, 15 241 insertions.

Your "Statistics / traffic counters" bullet is the part that bites hardest. Per-client accounting in this panel comes from Xray's gRPC stats, so AmneziaWG does not count traffic itself — it relays decapsulated traffic into a loopback Xray SOCKS5 inbound purely to borrow that identity:

// internal/amneziawgnet/relay.go:33-39
// Password is shared across every account. This traffic never leaves
// loopback, so the password is not a real secrecy boundary -- it only
// needs to satisfy Xray's SOCKS5 inbound requiring *some* username/
// password auth before it will accept a connection and use the
// username as the stats identity.

A Mieru integration would need the same relay, plus config generation, a reconcile cron job, share-link output in the three independent link implementations (internal/util/link/ + internal/sub/, frontend/src/lib/xray/, docs/lib/xray/), the frontend forms/schemas and i18n keys in 13 locale files.

Also note your example "port": "40000-40050": the inbound port is a single integer today (Port int ... validate:"gte=0,lte=65535", internal/database/model/model.go:64). Port ranges on an inbound are a separate open request, #5601.

What you can use today for port hopping

Hysteria2 inbounds already support a hop range. In Inbound → Stream → FinalMask → QUIC Params → "UDP Hop" you set Hop Ports and Hop Interval (s) (frontend/src/lib/xray/forms/transport/FinalMaskForm.tsx:1486-1501), and the panel advertises the range to clients as mport= in the share link (hysteriaHopPorts, internal/sub/service.go:1375-1384).

One thing that trips people up: the panel advertises the range but does not install host firewall rules — the operator forwards the range to the listen port. That is the maintainer's documented position in #5402 (and #4993 / #4974), with this workaround for listen port 443 and hop range 20000-30000:

# nftables
nft add rule ip nat prerouting udp dport 20000-30000 redirect to :443

# or iptables
iptables -t nat -A PREROUTING -p udp --dport 20000:30000 -j REDIRECT --to-ports 443

Make it persistent so it survives a reboot. A Mieru inbound would need the same operator-side NAT (or #5601) — port hopping is a client-side behaviour in every implementation the panel currently ships.

One thing I could not check

Your request links github.com/enigmasa/mieru. I have no network access in this environment, so I could not verify that repository; the Mieru project I am aware of is github.com/enfein/mieru. Please confirm which one you mean — whichever it is becomes a Go dependency of the panel (or a fetched sidecar binary like mtg-multi), so the exact upstream matters.

Verdict: Feature request — kept open for the maintainer to decide. Related: #5601 (inbound port ranges).

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

<!-- gh-comment-id:5599684964 --> @github-actions[bot] commented on GitHub (Sep 9, 2026): Thanks — this is a legitimate feature request, and nothing in the panel supports Mieru today (no `mieru` string exists anywhere in the repository). It is worth saying up front that this cannot be a small addition, and that the *port-hopping* half of what you are after already has a partial answer in the panel today. ## Why Mieru is not a drop-in The panel's protocol set is fixed in one place, `internal/database/model/model.go:24-36`, and enforced on the inbound: ```go // internal/database/model/model.go:65 Protocol Protocol `json:"protocol" form:"protocol" validate:"required,oneof=vmess vless trojan shadowsocks wireguard hysteria http mixed tunnel tun mtproto amneziawg" example:"vless"` ``` Everything in that list except `mtproto` and `amneziawg` is a native Xray-core inbound — the panel builds the account objects straight from Xray-core's own proto types (`internal/xray/api.go:614`, `case "hysteria":` → `hysteriaAccount.Account`). Mieru is not one of those: no `mieru` module appears in `go.sum`, so the pinned core (`github.com/xtls/xray-core v1.260327.1-0.20260908222543-52a412d9e2f5`, `go.mod:28`) does not carry it either. So Mieru would have to become the **third** out-of-core runtime, next to the two exceptions you correctly identified: - **MTProto** — a supervised sidecar binary, one process per inbound (`internal/mtproto/`, `docs/architecture.md` §1). - **AmneziaWG** — in-process userspace runtime (`internal/amneziawgnet/`). Its introduction, `effcccce feat(amneziawg): add native AmneziaWG protocol support (#6105)`, changed **146 files, 15 241 insertions**. Your "Statistics / traffic counters" bullet is the part that bites hardest. Per-client accounting in this panel comes from Xray's gRPC stats, so AmneziaWG does not count traffic itself — it relays decapsulated traffic into a loopback Xray SOCKS5 inbound purely to borrow that identity: ```go // internal/amneziawgnet/relay.go:33-39 // Password is shared across every account. This traffic never leaves // loopback, so the password is not a real secrecy boundary -- it only // needs to satisfy Xray's SOCKS5 inbound requiring *some* username/ // password auth before it will accept a connection and use the // username as the stats identity. ``` A Mieru integration would need the same relay, plus config generation, a reconcile cron job, share-link output in the three independent link implementations (`internal/util/link/` + `internal/sub/`, `frontend/src/lib/xray/`, `docs/lib/xray/`), the frontend forms/schemas and i18n keys in 13 locale files. Also note your example `"port": "40000-40050"`: the inbound port is a single integer today (`Port int ... validate:"gte=0,lte=65535"`, `internal/database/model/model.go:64`). Port *ranges* on an inbound are a separate open request, #5601. ## What you can use today for port hopping Hysteria2 inbounds already support a hop range. In **Inbound → Stream → FinalMask → QUIC Params → "UDP Hop"** you set *Hop Ports* and *Hop Interval (s)* (`frontend/src/lib/xray/forms/transport/FinalMaskForm.tsx:1486-1501`), and the panel advertises the range to clients as `mport=` in the share link (`hysteriaHopPorts`, `internal/sub/service.go:1375-1384`). One thing that trips people up: the panel advertises the range but does **not** install host firewall rules — the operator forwards the range to the listen port. That is the maintainer's documented position in #5402 (and #4993 / #4974), with this workaround for listen port 443 and hop range 20000-30000: ```bash # nftables nft add rule ip nat prerouting udp dport 20000-30000 redirect to :443 # or iptables iptables -t nat -A PREROUTING -p udp --dport 20000:30000 -j REDIRECT --to-ports 443 ``` Make it persistent so it survives a reboot. A Mieru inbound would need the same operator-side NAT (or #5601) — port hopping is a client-side behaviour in every implementation the panel currently ships. ## One thing I could not check Your request links `github.com/enigmasa/mieru`. I have no network access in this environment, so I could not verify that repository; the Mieru project I am aware of is `github.com/enfein/mieru`. Please confirm which one you mean — whichever it is becomes a Go dependency of the panel (or a fetched sidecar binary like `mtg-multi`), so the exact upstream matters. Verdict: Feature request — kept open for the maintainer to decide. Related: #5601 (inbound port ranges). *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@Iaslav24 commented on GitHub (Sep 9, 2026):

Thank you for the detailed architectural breakdown.

  1. Upstream Repository:
    Yes, the official and canonical repository is indeed https://github.com/enfein/mieru. Please consider github.com/enfein/mieru as the target dependency.

  2. Architecture & Traffic Stats:
    Following the AmneziaWG pattern (internal/amneziawgnet/relay.go decapsulating traffic into a loopback Xray SOCKS5 inbound) makes complete sense. It cleanly solves the per-client gRPC traffic accounting without requiring upstream changes in Xray-core.

  3. Port-Hopping Handling:
    Using the same approach as Hysteria 2 (binding to a single port while delegating the port range redirection to host-level iptables / nftables REDIRECT rules) is a completely acceptable and practical solution. It avoids blocking on #5601 and keeps the database model intact.

Looking forward to the maintainers' feedback on this!

<!-- gh-comment-id:5599942259 --> @Iaslav24 commented on GitHub (Sep 9, 2026): Thank you for the detailed architectural breakdown. 1. **Upstream Repository:** Yes, the official and canonical repository is indeed **https://github.com/enfein/mieru**. Please consider `github.com/enfein/mieru` as the target dependency. 2. **Architecture & Traffic Stats:** Following the AmneziaWG pattern (`internal/amneziawgnet/relay.go` decapsulating traffic into a loopback Xray SOCKS5 inbound) makes complete sense. It cleanly solves the per-client gRPC traffic accounting without requiring upstream changes in Xray-core. 3. **Port-Hopping Handling:** Using the same approach as Hysteria 2 (binding to a single port while delegating the port range redirection to host-level `iptables` / `nftables` REDIRECT rules) is a completely acceptable and practical solution. It avoids blocking on #5601 and keeps the database model intact. Looking forward to the maintainers' feedback on this!
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#4359
No description provided.