Skip to content

[Bug]: "Reset to default" in subscription settings does not restore backend defaults (breaks v2rayN/v2rayNG) #825

Closed

Description

@m-chrome

Before you submit

  • I searched existing issues and did not find the same problem.
  • I am using the latest available PasarGuard version, or I included the exact version below.

PasarGuard version

v5.3.0 and v5.2.1

Installation type

Docker Compose

What happened?

The "Reset to default" button in Settings → Subscriptions applies a hardcoded frontend copy of the rule list, defaultSubscriptionRules (dashboard/src/features/subscriptions/components/subscription-settings-schema.ts:138, used at dashboard/src/pages/_dashboard.settings.subscriptions.tsx:309). That list has drifted from the defaults the backend seeds into the database on install (app/db/migrations/versions/9af04c077ede_init_settings.py:201). As a result, resetting to default does not restore the default state — it silently applies a different one and breaks a working configuration. There is no undo and no backup.

Divergences:

The frontend unconditionally adds the rule

^([Vv]2rayNG|[Vv]2rayN|[Ss]treisand|[Hh]app|[Kk]tor-client) → xray
On the backend this rule is added only when USE_CUSTOM_JSON_DEFAULT / USE_CUSTOM_JSON_FOR_V2RAYN / USE_CUSTOM_JSON_FOR_V2RAYNG / USE_CUSTOM_JSON_FOR_STREISAND / USE_CUSTOM_JSON_FOR_HAPP / USE_CUSTOM_JSON_FOR_NPVTUNNEL are set (9af04c077ede_init_settings.py:179-198). On a default install (all of them false) v2rayN and v2rayNG fall through to the catch-all ^.* → links_base64. After the button is pressed they start receiving Xray JSON, and clients that expect a base64 link list can no longer parse the subscription. The environment configuration is ignored.

The ^[Ii]n[Hh]ive → xray rule present in the backend defaults is lost.

Steps to reproduce

  1. Install Panel
  2. Go to Settings -> Subscriptions -> Subscription Rules section
  3. Click "Reset to Default"
  4. See rule for v2rayN(G) clients with XRAY format

Expected behavior

Resetting defaults for subscriptions rules must do one of following things with rule ^([Vv]2rayNG|[Vv]2rayN|[Ss]treisand|[Hh]app|[Kk]tor\-client):

  • add rule for v2rayNG and v2rayN with links (base64)
  • or delete this rule for these clients and let them drop to rule .* links (Base64)

Logs and error messages

No logs, only screenshots.

Environment

OS: Ubuntu Server 24.04
Database: SQLite
Python version: -
Node.js version: -
Browser: Firefox 152.0.1
Reverse proxy / CDN: no

Relevant configuration

UVICORN_HOST = "0.0.0.0"
UVICORN_PORT = 8000
UVICORN_SSL_CERTFILE = "/var/lib/pasarguard/certs/ip/fullchain.pem"
UVICORN_SSL_KEYFILE = "/var/lib/pasarguard/certs/ip/privkey.pem"
UVICORN_SSL_CA_TYPE = "public"
WIREGUARD_ENABLED = True
WIREGUARD_GLOBAL_POOL = "10.0.0.0/8"
WIREGUARD_RESERVED = "10.0.0.0/31"
SQLALCHEMY_DATABASE_URL = "sqlite+aiosqlite://///var/lib/pasarguard/db.sqlite3"

Screenshots or videos

Image

But normal rule, which works with v2rayN and v2rayNG - links base 64

Image

Additional context

My temporary fix - manually set rule format for v2rayNG v2rayN as links (base64)

Suggested fix from Claude Code

Drop the duplicated frontend constant and serve the defaults from the backend — e.g. GET /api/settings/subscription/defaults — so there is a single source of truth. At minimum, sync defaultSubscriptionRules with the migration and add a confirmation prompt before overwriting rules.

Activity

  1. added
    bug
    on Aug 29, 2026
  2. dr-hoseyn commented on Aug 29, 2026

    @dr-hoseyn
    Contributor

    Confirmed — thanks for the detailed report. The dashboard's hardcoded rule list had drifted from the environment-aware defaults seeded by the backend, so Reset could incorrectly route v2rayN/v2rayNG to Xray JSON and also drop the InHive rule.

    Fixed in #826. The reset action now fetches its rules from a backend defaults endpoint, and both fresh installs and resets use the same rule builder. With the default USE_CUSTOM_JSON_* values, v2rayN/v2rayNG fall through to links_base64; the Xray rule is added only when the relevant custom JSON option is enabled. The InHive rule is preserved as well.

    I also added unit/API coverage for the default and custom-JSON cases and verified the dashboard production build.

  3. added a commit that references this issue on Sep 8, 2026
    74dc348
  4. added a commit that references this issue on Sep 12, 2026
    74f192f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions