Skip to content

fix(finalmask): support stable fragment schema - #864

Merged
T3ST3ST3R0N merged 5 commits into
PasarGuard:devfrom
dr-hoseyn:codex/fix-finalmask-stable-schema
Oct 10, 2026
Merged

T3ST3ST3R0N merged 5 commits into
PasarGuard:devfrom
dr-hoseyn:codex/fix-finalmask-stable-schema

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • emit both singular (length/delay) and plural (lengths/delays) FinalMask fragment fields
  • apply compatibility to host subscription links, generated Xray subscriptions, and Core Editor inbound/outbound configs
  • preserve newer multi-range behavior while using the first range as the stable-core fallback

Validation

  • python -m pytest -q tests/test_finalmask_compatibility.py tests/test_subscription_clash_hysteria.py tests/test_subscription_clash_xhttp.py (15 passed)
  • python -m pytest -q tests --ignore=tests/api --ignore=tests/test_review_admins_unit.py (173 passed, 2 skipped)
  • python -m ruff check ...
  • npm exec -- tsc --noEmit
  • npm run build
  • Core Kit validation accepts a config containing both schemas

Fixes #845

Summary by CodeRabbit

  • Bug Fixes
    • Improved Xray final-mask compatibility by ensuring fragment settings include the expected singular length and delay values.
    • Preserved explicitly configured singular values while filling missing or empty values from their corresponding lists.
    • Applied compatibility handling consistently to inbound and outbound configurations.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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: d7c91a05-afa8-48f9-a2ee-54b19144c3d4

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d2f9efdd-8bb6-40ad-bc39-082e9249f5b4


📥 Commits

Reviewing files that changed from the base of the PR and between 630b33d and b3f7ca3.


📒 Files selected for processing (5)
  • app/core/hosts.py
  • app/models/host.py
  • app/subscription/xray.py
  • dashboard/src/features/core-editor/kit/xray-adapter.ts
  • tests/test_finalmask_compatibility.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.



Walkthrough

FinalMask serialization now emits singular and plural fragment fields. Backend host and subscription paths use the shared serializer. Dashboard compiled configurations normalize FinalMask settings for inbound and outbound entries.

Changes

FinalMask compatibility

Layer / File(s) Summary
FinalMask serializer and validation
app/models/host.py, tests/test_finalmask_compatibility.py
Adds shared FinalMask serialization, fragment-field fallback handling, and tests for explicit, empty, plural, and singular values.
Backend serialization integration
app/core/hosts.py, app/subscription/xray.py
Routes host and subscription FinalMask output through the shared serializer.
Dashboard compiled-config normalization
dashboard/src/features/core-editor/kit/xray-adapter.ts
Normalizes fragment fields in FinalMask settings for inbound and outbound compiled configuration entries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: immohammad20000, x0sina, m03ed

Merge Risk: ⚪ Minimal · up to b3f7c

FinalMask configurations now include stable-core singular fragment fields alongside newer plural fields without changing multi-range values, allowing generated configurations to work across supported Xray-core schemas. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: FinalMask support for the stable fragment schema.
Linked Issues check ✅ Passed The changes satisfy issue #845 by emitting singular and plural FinalMask fragment fields across host subscriptions, generated Xray subscriptions, and Core Editor configurations. The implementation pre…
Out of Scope Changes check ✅ Passed All modified files and added tests directly support FinalMask schema compatibility described in issue #845. No unrelated code changes are identified.

✨ 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

A rabbit packs fields in a neat little row
Singular and plural now travel in tow
Fragment masks hop through each config gate
Tests guard the values at every state
Xray finds both names waiting in place

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

@dr-hoseyn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor
✅ 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.

@dr-hoseyn
dr-hoseyn force-pushed the codex/fix-finalmask-stable-schema branch from 92b4767 to 7cc4a2d Compare October 8, 2026 22:29
dr-hoseyn and others added 2 commits October 9, 2026 02:09
Resolve tests/test_subscription_xray_finalmask.py: keep this PR's stable fragment schema test and the udphop and exp noise tests that PasarGuard#974 added at the same spot, with both import sets.
@T3ST3ST3R0N
T3ST3ST3R0N merged commit 5a63605 into PasarGuard:dev Oct 10, 2026
10 checks passed
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 4, 2026
* fix(finalmask): support stable fragment schema

* test: remove added PR tests

---------

Co-authored-by: T3ST3ST3R0N <[email protected]>
(cherry picked from commit 5a63605)

Conflict resolution. The fork had its own emission step, to_xray_finalmask
(b0bafaf, 4edae15), which popped the lengths/delays lists from every tcp
and udp layer and wrote the span they cover as the scalar, overwriting a
scalar that was already set. Upstream keeps the lists and adds the scalar
length/delay from the first entry when the scalar is absent, for tcp
fragment layers only. The node's shipped Xray v26.3.27 reads only the
scalar and ignores the lists; Xray v26.10.21 and later apply the lists per
segment. The upstream form is taken: dump_final_mask_for_xray has upstream's
body, and to_xray_finalmask and _collapse_to_range are removed. The
dashboard core-editor hunk, which already emits the upstream form for the
node config, applies unchanged, so the link, the xray subscription and the
core config now agree.

Kept from the fork: the prune_blank_values step and the suppress() form in
_stream_setting_config, the OpenVPNHostOverrides/ProxyHost/DB_RELOAD_ATTEMPTS
imports in app/core/hosts.py. Not taken: upstream's docstring and inline
comment in the helper (fork rule: no explanatory comments), and the upstream
test context in tests/test_subscription_xray_finalmask.py that belongs to
unported 7f670cf. The two upstream tests are taken as written.
tests/test_finalmask_blank.py used to_xray_finalmask and pinned the span; it
now goes through dump_final_mask_for_xray and pins the first-entry scalar
next to the unchanged lists.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 4, 2026
…r10/train-q SHAs, and the 1bf4af3 row says profileToPersistedConfig ends as upstream's now that PasarGuard#864 is carried
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 22, 2026
…ith MySQL evidence)

# Conflicts:
#	UPSTREAM_SYNC.md
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.

2 participants