How prasx/vless-manager-proxy works
Purpose and Runtime
VLESS Manager Proxy is a Flask-based control plane for importing, validating, selecting, and operating VLESS proxies through a local Xray instance. It exposes an HTML dashboard, REST/SSE APIs, and a generated subscription endpoint for VLESS clients.
Primary process entry point: app.py. Flask application creation and route registration are centralized in app/__init__.py. Deployment is intended as a systemd service via vless-manager.service.
Web and API Boundary
Server-rendered dashboard pages are handled separately from operational APIs:
• Page routes: app/routes/pages.py
• REST APIs, SSE test-progress stream, subscription, Xray controls, traffic/connections endpoints: app/routes/api.py
• Browser clients and dashboard interactions: static/dashboard.js, static/sources.js, static/settings.js
The API is the control boundary between the UI/external consumers and proxy lifecycle services. /api/subscribe.txt is a machine-facing output consumed by VLESS-compatible clients.
Persistent State and Settings
SQLite is the durable source of truth for proxies, sources, settings, logs, and likely test/traffic state:
• app/db.py
• config.py
The database layer owns schema initialization/migrations and settings access. Runtime configuration combines base defaults in config.py, persisted UI settings, and potentially environment configuration such as import proxy settings. Generated subscription content is cached/exported as configured through the subscription stage.
Source Import and Proxy Normalization
Import sources may be remote URLs or stored text content. Importing supports conditional HTTP retrieval through ETags, import-proxy routing, and curl fallback; repeated source imports remove stale proxies absent from the refreshed subscription:
• app/importer.py
• app/vless.py
• app/utils.py
app/vless.py is the protocol boundary that parses vless:// inputs into structured proxy records/configuration. Utility enrichment determines country metadata from link fragments or external IP geolocation (ip-api.com).
Validation and Background Lifecycle
The proxy manager coordinates concurrent proxy checks, scheduled DB-only versus import-and-check runs, cancellation/progress reporting, optional failed-node cleanup, speed testing, and failover reconciliation:
• app/proxy_manager.py
• app/importer.py
• app/db.py
Validation is not merely socket probing: each candidate is tested using a temporary Xray execution and an HTTP generate_204 request. Working candidates may then undergo throughput tests; those measurements influence active-node ordering. Progress crosses to clients via API/SSE rather than direct worker/UI coupling.
Xray Configuration and Apply Boundary
The configurator translates selected database proxies and settings into Xray configuration, including SOCKS/HTTP inbounds, country filtering, GeoSite routing, sniffing, Observatory, and balancer strategy:
• app/xray_configurator.py
• app/subscribe.py
• config.py
It also interfaces with Xray’s local gRPC API and system service lifecycle to apply/rebuild configuration and inspect outbounds. This is the critical side-effect boundary: database candidates become live Xray outbounds, while app/subscribe.py emits the corresponding allowed/working VLESS links for external clients.
Monitoring and Host Dependencies
Operational visibility includes Xray outbound status, application logs, traffic history, active connections, and performance recommendations:
• app/proxy_manager.py
• app/routes/api.py
• static/logs.js
Material dependencies are Python 3.9+, Flask, SQLite, Xray 26.3+, and systemd. Xray needs installed geo assets (geosite.dat, geoip.dat) for routing. Host-level traffic and connection telemetry depends on nftables and conntrack; management may invoke systemctl to control the separate Xray service.
Main entry points: api.py Control API and SSE · proxy_manager.py Proxy manager · xray_configurator.py Xray configurator · db.py SQLite state
Components 18
Web boundary
- Application entry
app.py - Flask application · Registers dashboard and operational routes.
app/__init__.py - Dashboard pages
app/routes/pages.py - Control API and SSE · Serves controls, telemetry, progress, and subscriptions.
app/routes/api.py - Browser dashboard
static/dashboard.js
State and import
- SQLite state · Owns schema, proxies, sources, settings, logs, and measurements.
app/db.py - Base configuration
config.py - Source importer · Refreshes URL or text sources and removes stale source proxies.
app/importer.py - VLESS parser · Parses VLESS links into structured proxy records.
app/vless.py - Proxy enrichment · Derives country metadata from fragments or IP geolocation.
app/utils.py
Validation and apply
- Proxy manager · Runs checks, scheduling, cancellation, speed tests, and failover.
app/proxy_manager.py - Temporary Xray validation · Tests candidates through Xray with an HTTP generate_204 request.
- Xray configurator · Builds Xray outbounds, routing, balancing, and applies runtime changes.
app/xray_configurator.py - Subscription generator · Emits allowed working VLESS links for client consumption.
app/subscribe.py
Host runtime
- Xray service · Local Xray process with gRPC API and geo routing assets.
- systemd · Runs the manager and controls the separate Xray service.
vless-manager.service - Host telemetry · Provides traffic history and active connection data.
Other components
- VLESS clients
Connections 24
- Application entry → Flask application: starts
- Flask application → Dashboard pages: registers
- Flask application → Control API and SSE: registers
- Browser dashboard → Dashboard pages: loads dashboard
- Browser dashboard → Control API and SSE: uses controls and SSE
- Control API and SSE → Proxy manager: operates
- Control API and SSE → Subscription generator: serves subscribe.txt
- Control API and SSE → SQLite state: reads state and logs
- Source importer → VLESS parser: normalizes links
- Source importer → Proxy enrichment: enriches proxies
- Source importer → SQLite state: persists refreshed sources
- Proxy manager → Source importer: runs import-and-check
- Proxy manager → SQLite state: selects and records results
- Proxy manager → Temporary Xray validation: checks candidates
- Temporary Xray validation → Xray service: temporary execution
- Proxy manager → Xray configurator: reconciles active nodes
- SQLite state → Xray configurator: selected proxies and settings
- Base configuration → Xray configurator: routing defaults
- Xray configurator → Xray service: applies configuration and gRPC control
- Subscription generator → SQLite state: exports working proxies
- Subscription generator → VLESS clients: VLESS links
- Control API and SSE → Host telemetry: queries traffic and connections
- systemd → Application entry: runs manager service
- Xray configurator → systemd: controls Xray service