A modern, high-performance Xray GUI & CLI client for Windows and Linux. XenRay focuses on visual excellence, simplicity, and a premium VPN experience.
- Unified Engine: Single executable for both GUI and Headless CLI modes.
- Extreme RAM Optimization: GUI footprint reduced to ~130MB; CLI mode runs at a lean ~30MB.
- Lazy Load Architecture: Core frameworks (like Flet) are only loaded when the UI is requested.
- DI Lifecycle Management: Production-grade dependency injection with zero memory leaks.
- Signal-Based Monitoring: Clean separation - monitors emit facts, ConnectionManager decides actions.
- π© Global Flags: Automatic country flag emojis for all servers.
- π Smart GeoIP: Real-time detection of server Country and City.
- β‘ Unified Ping: Concurrent batch testing with visual latency feedback.
- π¨ Apple Glass UI: Modern glassmorphism design with dynamic connection status glow.
- π Dual Mode: Intelligent switching between VPN (TUN) and Proxy (SOCKS5/HTTP) modes.
- π Auto-Reconnect: Automatic connection recovery with hybrid detection (log + traffic analysis).
- π Battery Saver: Optional monitoring toggle to disable auto-reconnect and save resources.
- π₯ One-Click Import: Support for VLESS, VMess, Trojan, ShadowSocks, and Hysteria2.
- π State Adoption: CLI automatically detects and manages connections started by the GUI (and vice versa).
- π Real-time Diagnostics: Live log streaming with automatic console hiding for core processes.
- β‘ Auto-Updates: Seamless GitHub integration for updating Xray core and the app.
- π Startup on Boot: Optional Windows Task Scheduler integration for auto-start.
# Clone the repository
git clone https://github.com/xenups/xenray.git
cd xenray
# Install all dependencies (including CLI)
poetry install --with cli
# Run the GUI
poetry run xenray
# Run the CLI
poetry run xenray listXenRay features a powerful, colorized CLI for headless environments.
| Command | Description |
|---|---|
xenray list |
List all profiles with flags and location info |
xenray connect [N] |
Connect to profile #N or the default one |
xenray ping [N] |
Batch test all profiles or a specific one |
xenray disconnect |
Safely terminate the connection |
xenray status |
Show real-time connection status |
xenray add "LINK" |
Add a server from a share link |
XenRay is built with a modular, service-oriented architecture designed for efficiency and cross-platform flexibility.
src/
βββ core/
β βββ container.py # Dependency Injection (DI) Root
β βββ config_manager.py # Profile & settings persistence
β βββ connection_manager.py # High-level connection facade (event authority)
β βββ connection_orchestrator.py # Service coordination
β βββ i18n.py # Lazy-loaded internationalization
β βββ logger.py # Unified logging system
β
βββ services/
β βββ xray_service.py # Xray core lifecycle management
β βββ singbox_service.py # TUN-based VPN integration
β βββ latency_tester.py # Multi-threaded ping engine
β βββ connection_tester.py # Real-world connectivity validation
β βββ monitoring/ # Signal-based monitoring subsystem
β βββ signals.py # MonitorSignal enum (facts, not events)
β βββ service.py # ConnectionMonitoringService facade
β βββ passive_log_monitor.py # Log-based failure detection
β βββ active_connectivity_monitor.py # Traffic stall detection
β βββ auto_reconnect_service.py # Automatic reconnection
β
βββ ui/
β βββ main_window.py # GUI entry point (Glassmorphism)
β βββ components/ # Custom Flet widgets (Cards, Buttons, etc.)
β βββ handlers/ # UI-to-Service event handling
β
βββ utils/
β βββ admin_utils.py # UAC & Root elevation management
β βββ link_parser.py # VLESS/VMess/Trojan/Hysteria parser
β βββ platform_utils.py # OS-specific behavior logic
β
βββ cli.py # High-performance Typer CLI interface
- Dependency Injection: Centralized lifecycle management via
dependency-injector. - Signal-Based Architecture: Monitors emit signals (facts), ConnectionManager is the single event authority.
- Session-Scoped Lifecycle: All monitoring tied to connection sessions - no stale events after disconnect.
- Hybrid Entry Point: Smart routing between GUI and CLI modes based on runtime arguments.
- Background Persistence: State adoption logic allows the CLI and GUI to seamlessly share active background connections.
- Resource Management: Background threads and core processes are strictly lifecycle-bound to prevent zombie processes.
XenRay maintains high test coverage for core components:
# Run all tests with coverage
poetry run pytest
# Run specific test file
poetry run pytest tests/test_link_parser.py -v
# Generate HTML coverage report
poetry run pytest --cov=src --cov-report=htmlCurrent Coverage:
LinkParser: 88%SingboxService: 83%ConfigManager: 73%
We use automated tools to maintain code quality:
# Format code with Black
poetry run black src tests
# Sort imports with isort
poetry run isort src tests
# Lint with Flake8
poetry run flake8 src tests --max-line-length=120Pre-commit Hooks (Recommended):
poetry run pre-commit install
poetry run pre-commit run --all-filesSee docs/CODE_QUALITY.md for detailed information.
GitHub Actions automatically runs code quality checks on all PRs:
- β Black formatting
- β isort import sorting
- β Flake8 linting
- β Pytest test suite
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Run tests and code quality checks
- Submit a pull request
See docs/CODE_QUALITY.md for development setup.
Made with β€οΈ by Xenups

