Skip to content

Refactor XRayMOD into a Secure VPN Infrastructure Control Plane - #59

Open
Pakrohk wants to merge 20 commits into
EvolveBeyond:mainfrom
askarniroomand:main
Open

Refactor XRayMOD into a Secure VPN Infrastructure Control Plane#59
Pakrohk wants to merge 20 commits into
EvolveBeyond:mainfrom
askarniroomand:main

Conversation

@Pakrohk

@Pakrohk Pakrohk commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a major architectural refactor of XRayMOD, moving the project from a traditional VPN/proxy panel model toward a Secure VPN Infrastructure Control Plane.

The new architecture clearly separates the control plane from the data plane, introduces an Edge Provider abstraction, establishes a Node Agent model, makes the Wizard the canonical deployment/orchestration path, and adds stronger security, policy, deployment, and CI infrastructure.

This PR also synchronizes the project with upstream 1.9.12 while preserving XRayMOD-specific architecture and security decisions.

Type of change

  • Refactor
  • Security hardening
  • New infrastructure
  • CI / deployment improvements
  • Documentation
  • Dependency / upstream synchronization

Architectural Changes

Control Plane / Data Plane separation

XRayMOD now explicitly distinguishes between:

  • Control Plane

    • Cloudflare Worker
    • D1
    • Admin panel
    • API routes
    • Policies
    • Subscriptions
    • Node management
    • Onboarding and orchestration
  • Data Plane

    • Xray / sing-box
    • User nodes
    • Gateways
    • Proxy traffic

The Worker is no longer treated as the VPN runtime. Its role is limited to infrastructure control, policy, orchestration, and edge-facing services.

Edge Provider abstraction

A new Edge Provider abstraction decouples XRayMOD from Cloudflare-specific implementation details.

Cloudflare is currently the first provider implementation, allowing future providers or infrastructure integrations to be introduced without coupling the core architecture directly to Cloudflare APIs.

Node Agent

A new Node Agent contract provides a structured way for managed nodes to:

  • Authenticate securely
  • Send heartbeats
  • Pull configuration
  • Report health
  • Integrate with the control plane

The architecture keeps actual proxy/data-plane execution outside the Worker.

Wizard as the canonical orchestrator

The installation and deployment Wizard is now the primary orchestration surface.

It provides:

  • Stateful deployment flow
  • Capability discovery
  • OAuth/PKCE support
  • Remote deployment
  • Rolling artifact deployment
  • Node onboarding
  • Configuration management

Legacy shell installers remain available for compatibility but are no longer treated as the primary installation path.

Security Improvements

This refactor introduces a dedicated security policy layer and strengthens several infrastructure boundaries:

  • Node authentication using xrm_node_ bearer credentials
  • Explicit control/data-plane separation
  • Security policy engine
  • Improved admin policy APIs
  • Honest edge endpoint and origin-protection terminology
  • Removal of misleading "clean IP" / stealth-as-camouflage claims
  • Preservation of disguise and panel-path protections
  • Reduced exposure of internal implementation details

Deployment & Release Infrastructure

The deployment workflow has been redesigned around reproducible rolling artifacts.

Added:

  • publish-rolling.sh
  • ship-panel.sh
  • Rolling worker.mjs artifacts
  • assets.tar.gz deployment flow
  • run_worker_first deployment handling
  • Automated rolling bundle publishing through GitHub Actions

The preferred production path now preserves existing D1 state and supports controlled panel updates.

CI Improvements

CI now validates the actual project surfaces instead of silently ignoring failures.

The pipeline now runs:

npm run lint
npm run build:ui
npm test

A dedicated rolling-bundle workflow was also added for publishing deployable artifacts.

Product & Repository Cleanup

This PR also removes deprecated product surfaces that no longer fit the new architecture:

  • Telegram Mini App / TWA
  • Telegram commerce/store
  • Telegram bot integration
  • telegram-bot/

These removals are intentional architectural decisions rather than simple file cleanup.

Legacy installer and compatibility code remains where required and is not permanently removed without an explicit cleanup decision.

Versioning

The canonical product version is now maintained through:

worker/lib/version.ts

Target product version:

1.9.12

This avoids conflicting legacy version identities across the repository.

Testing

The refactor has been validated through the project's main build and test surfaces:

npm run lint
npm run build:ui
npm test

Additional deployment and installer paths were reviewed as part of the migration.

Notes

This PR is intentionally larger than a conventional feature PR because it establishes the architectural foundation for the next phase of XRayMOD development.

The goal is not to add another layer around the existing panel, but to establish a cleaner and more scalable infrastructure model that can support future providers, managed nodes, policy enforcement, automated deployment, and additional control-plane capabilities without coupling them to the VPN data plane.

askarniroomand and others added 20 commits August 9, 2026 03:44
Add /twa user+admin surfaces (scoped by ?ref=), six-language keys, and refresh the main panel dashboard/protocols with the same bento patterns. Version stays 5.1.1.
Add DE/NL/FI/TR-weighted clean-IP pools with larger scan limits, one-click
recommended subscription, in-panel GitHub→Cloudflare self-update with live
steps, and clearer Persian login UX.

Co-authored-by: Cursor <cursoragent@cursor.com>
Accept the install-time password when hashes desync, resync PBKDF2 hashes,
and return clearer Persian login errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Tag recommended/clean-IP subscription entries with 🇩🇪/🇳🇱/… so clients
display the country next to each node.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add nightly Auto Clean-IP + health-check cron, speed profiles, 24h guest
subs with QR, Iran split routing, failover tags, pro canary, presets,
backup/restore, multi-node, Worker rollback, and a polished Lab panel.
Update EN/FA READMEs with the new feature set.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Wire D1-backed plans/wallet/coupons/reseller, complete ?ref= invite attribution with commission, and cron Telegram alerts for pause/cap/weak IPs/suspicious login.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop /twa UI, telegram-bot, worker Telegram/commerce/alerts paths, and related deps so the product is panel-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Edge was still serving cached Mini App HTML via SPA fallback; block /twa,/bot,/api/commerce explicitly.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Guarantee Mini App paths never hit SPA/assets, even under SECURE PATH or stale edge cache.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Lab + TWA removal overlays; take upstream deps/remote API; restore canonical 1.9.12 versioning.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fix post-merge lint fallout, document architecture/cleanup audits, and introduce Cloudflare Edge Provider for control-plane API calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
sync: EvolveBeyond 1.9.12 + AGENTS control-plane migration plan
Panel update was marking itself current after applying an old rolling
bundle. Track the rolling tag commit, warn when it lags main, and bust
download cache so republished assets are actually fetched.

Co-authored-by: Cursor <cursoragent@cursor.com>
…copy

Add agent enroll/heartbeat APIs, security policy, rolling wizard artifacts, and a panel Wizard page. Mark shell installers deprecated without deleting them.

Co-authored-by: Cursor <cursoragent@cursor.com>
Panel deploys via prebuilt worker.mjs (not wrangler TS) with run_worker_first
so CSS/JS get correct Content-Type; HTML routes no longer download as files.

Co-authored-by: Cursor <cursoragent@cursor.com>
One-command panel ship from ~/.xraymod/config.json; deploy script retries
transient SSL/API failures when uploading UI assets.

Co-authored-by: Cursor <cursoragent@cursor.com>
… lib.

Align wizard remote deploy with rolling worker.mjs + assets and run_worker_first; add OAuth PKCE endpoints and operator docs for ship-panel/rolling publish.

Co-authored-by: Cursor <cursoragent@cursor.com>
English-only control-plane docs and panel copy; delete README.fa.md; drop fa i18n/RTL/Vazirmatn defaults.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Pakrohk Pakrohk changed the title Moving towards the future Refactor XRayMOD into a Secure VPN Infrastructure Control Plane Aug 20, 2026
@Pakrohk
Pakrohk marked this pull request as draft August 21, 2026 00:56
@Pakrohk
Pakrohk marked this pull request as ready for review August 21, 2026 00:57
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