Skip to content
/ xenray Public

A modern, lightweight Xray client for Windows, focusing on simplicity and enhancing VPN experience.

License

Notifications You must be signed in to change notification settings

xenups/xenray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌌 XenRay

A modern, high-performance Xray GUI & CLI client for Windows and Linux. XenRay focuses on visual excellence, simplicity, and a premium VPN experience.

License Python Platform Coverage RAM


✨ Features

πŸš€ Performance & Architecture

  • 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.

🌍 Connection & Visuals

  • 🚩 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.

πŸ› οΈ Management

  • πŸ“₯ 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.

πŸ“Έ Gallery

Main UI Settings


πŸš€ Getting Started

Installation (Poetry)

# 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 list

πŸ’» CLI Usage

XenRay 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

πŸ› οΈ Architecture

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

Core Principles

  • 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.

πŸ§ͺ Development

Testing

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=html

Current Coverage:

  • LinkParser: 88%
  • SingboxService: 83%
  • ConfigManager: 73%

Code Quality

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=120

Pre-commit Hooks (Recommended):

poetry run pre-commit install
poetry run pre-commit run --all-files

See docs/CODE_QUALITY.md for detailed information.

CI/CD

GitHub Actions automatically runs code quality checks on all PRs:

  • βœ… Black formatting
  • βœ… isort import sorting
  • βœ… Flake8 linting
  • βœ… Pytest test suite

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Run tests and code quality checks
  4. Submit a pull request

See docs/CODE_QUALITY.md for development setup.


βš–οΈ License

AGPL-3.0-or-later


Made with ❀️ by Xenups

About

A modern, lightweight Xray client for Windows, focusing on simplicity and enhancing VPN experience.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •