Skip to content

fix(subscription): build Hysteria2 hosts whose FinalMask has no udp mask - #993

Merged
T3ST3ST3R0N merged 1 commit into
devfrom
fix/hysteria-finalmask-quic-only
Oct 10, 2026
Merged

T3ST3ST3R0N merged 1 commit into
devfrom
fix/hysteria-finalmask-quic-only

Conversation

@T3ST3ST3R0N

Copy link
Copy Markdown
Collaborator

Summary

  • A Hysteria2 host (or inbound) whose FinalMask has quicParams, such as udpHop port hopping or brutal settings, but no udp mask made the share link, Clash Meta and sing-box builders fail with AttributeError: 'FinalMask' object has no attribute 'get'. The subscription has no per-host error handling, so the whole subscription failed for every user who gets that host.
  • Cause: SubscriptionInboundData.finalmask was typed FinalMask | dict | None, and Pydantic's smart union turned these dicts back into a FinalMask while the builders expect a dict. The field is now always a plain dict, and a FinalMask is dumped once with Xray field names.
  • The Hysteria builders also read quicParams, udpHop and the salamander settings null-safely, since a core config can write them as null (sing-box already did this).

Follows up #987. The exact case reported there (salamander plus quicParams without udpHop) is already fixed on dev by #974, and is kept as a test.

Upgrade note

With a NATS host cache, a host of this shape that was cached by the old code keeps its old cache entry, and its Hysteria links lack port hopping until the host is saved again or the core config is updated. Before this change, those hosts failed outright.

Tests

  • 9 new cases in tests/test_subscription_hysteria_finalmask.py: host, inbound and NATS round trip with udpHop only, brutal only, empty quicParams, and explicit nulls in a core config. 8 fail on dev without the fix.
  • Full suite: all pass except the known flaky test_record_node_usages_updates_totals, which also fails intermittently on dev.

- SubscriptionInboundData.finalmask is always a plain dict; host masks are
  dumped with Xray field names. The FinalMask | dict union turned dicts with
  no udp or tcp list (udpHop port hopping or brutal settings only) back into a
  FinalMask, and the share link, Clash Meta and sing-box builders then failed
  with "'FinalMask' object has no attribute 'get'", taking the whole
  subscription down
- Read quicParams, udpHop and the salamander settings null-safely, since a
  core config may write them as null

Follows up #987, whose exact case #974 already fixed.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f26a6de-7ed6-4042-89b8-888ec86dedab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
T3ST3ST3R0N merged commit 2aaa5c1 into dev Oct 10, 2026
18 checks passed
@T3ST3ST3R0N
T3ST3ST3R0N deleted the fix/hysteria-finalmask-quic-only branch October 22, 2026 12:34
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
…ain bba95f274

Checked with git ls-remote on 2026-10-11 02:55 UTC. Panel dev moved from
d94e157 to 83fe90e with 22 commits; main is still v5.4.1.

- PasarGuard#879 (2d0ca81, loopback Xray client inbounds) is ported by design: the
  fork took the open pull request on 2026-09-25 as 2e7fc45 with migration
  bfd88026565b, the same listener rewrite.
- PasarGuard#934 (a5b28f3) moves from the port queue to a dated waiver until
  2026-11-09: the fork refuses to delete a core that nodes still use
  (W3-013, fix/node-health) instead of restarting those nodes.
- PasarGuard#993 (Hysteria2 FinalMask without a udp mask) is queued until 2026-10-18:
  the fork has the same FinalMask | dict field and the same non-null-safe
  udpHop reads, so a udpHop-only host can fail the whole subscription.
- PasarGuard#984, PasarGuard#985, PasarGuard#986, PasarGuard#989, PasarGuard#944, PasarGuard#864, PasarGuard#948, PasarGuard#951, PasarGuard#778, PasarGuard#774, PasarGuard#787, PasarGuard#994,
  PasarGuard#865, PasarGuard#875, PasarGuard#718, PasarGuard#967, PasarGuard#772, PasarGuard#662, PasarGuard#995 and PasarGuard#913 are queued as
  security: no until 2026-10-25, each with its reason; PasarGuard#913's node-removal
  half is already in the fork through sync_remove_users.
- The branch commits that upstream squash-merged (the three dashboard
  branches, telegram/tests, fix/core-editor-api-section-followup,
  fix/hwid-count-test-cleanup, fix/hysteria-finalmask-quic-only) follow
  their squash, by patch-id or by an equal tree.

Scripts main moved to bba95f274 (PasarGuard#35, PasarGuard#36, PasarGuard#37 after PasarGuard#34). The three
squashes are queued security: no until 2026-10-25, and their pre-squash
branch commits are waived as superseded (equal trees).

Against live upstream the panel gate now fails only on the 17 port-queue
commits classified security: yes, and the forks gate only on node
f72ac0ef (security: yes). No upstream commit is undecided.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
…ask (PasarGuard#993)

- SubscriptionInboundData.finalmask is always a plain dict; host masks are
  dumped with Xray field names. The FinalMask | dict union turned dicts with
  no udp or tcp list (udpHop port hopping or brutal settings only) back into a
  FinalMask, and the share link, Clash Meta and sing-box builders then failed
  with "'FinalMask' object has no attribute 'get'", taking the whole
  subscription down
- Read quicParams, udpHop and the salamander settings null-safely, since a
  core config may write them as null

Follows up PasarGuard#987, whose exact case PasarGuard#974 already fixed.
(cherry picked from commit 2aaa5c1)

Fork resolution:
- app/subscription/base.py keeps the fork's conversion of a FinalMask or
  dict into finalmask_dict and reads quicParams and the salamander settings
  from it null-safely, as upstream now does.
- tests/test_subscription_hysteria_finalmask.py keeps the fork's tests and
  adds upstream's PasarGuard#993 tests with the helpers they use. The udphop model
  tests that came with 7f670cf stay with that wave-2 pick. sing-box
  server_ports is asserted as 20000:20010: the fork already writes sing-box
  port ranges as START:END (7e7dca7), which is the form sing-box accepts.
- The plain-dict finalmask also reaches the fork's OpenVPN, L2TP and
  MTProto readers in app/fork/subscription/helpers.py, which already take a
  dict.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 4, 2026
…ask (PasarGuard#993)

- SubscriptionInboundData.finalmask is always a plain dict; host masks are
  dumped with Xray field names. The FinalMask | dict union turned dicts with
  no udp or tcp list (udpHop port hopping or brutal settings only) back into a
  FinalMask, and the share link, Clash Meta and sing-box builders then failed
  with "'FinalMask' object has no attribute 'get'", taking the whole
  subscription down
- Read quicParams, udpHop and the salamander settings null-safely, since a
  core config may write them as null

Follows up PasarGuard#987, whose exact case PasarGuard#974 already fixed.
(cherry picked from commit 2aaa5c1)

Fork resolution:
- app/subscription/base.py keeps the fork's conversion of a FinalMask or
  dict into finalmask_dict and reads quicParams and the salamander settings
  from it null-safely, as upstream now does.
- tests/test_subscription_hysteria_finalmask.py keeps the fork's tests and
  adds upstream's PasarGuard#993 tests with the helpers they use. The udphop model
  tests that came with 7f670cf stay with that wave-2 pick. sing-box
  server_ports is asserted as 20000:20010: the fork already writes sing-box
  port ranges as START:END (7e7dca7), which is the form sing-box accepts.
- The plain-dict finalmask also reaches the fork's OpenVPN, L2TP and
  MTProto readers in app/fork/subscription/helpers.py, which already take a
  dict.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 4, 2026
…ream PasarGuard#974

Upstream 7f670cf tests, adapted to the fork test files, committed
before the pick so they fail on 1fc2b45:

- tests/test_subscription_xray_finalmask.py: udphop and exp survive the
  Xray stream settings; exp rejects a blank or non-string packet; exp is
  refused in header-custom items
- tests/test_subscription_hysteria_finalmask.py: host and inbound
  FinalMask reach the Hysteria2 link, Clash Meta and sing-box builders,
  including after the NATS cache round trip; udphop validation; udphop
  passes through the fm link parameter. Inserted next to the PasarGuard#993
  scaffolding the fork already had
- tests/api/test_host.py: udphop and exp over the host API

On 1fc2b45: 21 failed, 45 passed (non-API) and 3 failed, 8 passed
(tests/api/test_host.py). Failures: "udphop" is not a FinalMaskUdpType,
and "exp" does not match ^$|^(:?array|str|base64|hex)$.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 4, 2026
…ard#974)

* fix(hosts): dump host FinalMask with Xray field names once

- Hysteria2 links, Clash Meta and sing-box no longer fail for hosts with FinalMask settings
- Host QUIC params survive a reload of the NATS host cache

* feat(finalmask): add Xray udphop UDP mask

- Hosts and core outbounds can set the udphop mask that Xray 26.9.9+ clients use for port hopping
- Layer orders and values Xray cannot dial are rejected with a clear error

* feat(finalmask): add Xray exp noise type

- Offer exp in the UDP noise mask of the host and core-config editors
- Reject exp outside UDP noise and require a non-empty template packet
- Show a saved udphop mode outside the presets instead of an empty select

* fix(finalmask): reject udphop intervals above the Xray int32 limit

- Stop saving udphop intervals that Xray would wrap into another value or refuse with a misleading error

(cherry picked from commit 7f670cf)

Fork port notes:
- app/, dashboard/ and locale hunks applied without conflict.
- The three test files conflicted only because the RED commit before
  this pick already added upstream's tests to them (the hysteria test
  file is add/add: the fork created it when porting PasarGuard#993 first). The
  RED commit's version is kept; it differs from upstream only by the
  dropped helper docstrings and comments.
- No fork-relocated copy needs the change: app/fork and
  dashboard/src/fork hold no copy of FinalMask or of the two finalmask
  editors (fork readers only take the openvpn, l2tp and mtproto keys).
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