X4G2
A FastAPI-based gateway server for proxy management and configuration distribution
Overview
X4G2 is a web gateway application that provides proxy configuration management with a focus on VLESS protocol support and HTTP transport. The server offers both web interface and WebSocket connectivity for real-time configuration updates.
Key Features
- Proxy Configuration Management: Handles VLESS proxy configurations with various transport protocols
- Web Interface: Browser-based management dashboard with authentication
- Real-time Updates: WebSocket support for live configuration synchronization
- Persistent Storage: JSON-based state persistence with automatic backup
- HTTP/2 Support: Enhanced transport capabilities via httpx
- CORS Enabled: Cross-origin resource sharing for web client integration
Tech Stack
- Framework: FastAPI 0.104.1
- ASGI Server: Uvicorn with standard extras
- HTTP Client: HTTPX with HTTP/2 support
- WebSockets: Native websockets 12.0
- File I/O: aiofiles for async file operations
- Runtime: Python 3.11+ (inferred from zoneinfo usage)
Core Components
# Main application server
main.py # FastAPI application with authentication & state management
pages.py # Web interface and HTML page routing
relay_vless.py # VLESS protocol relay functionality
xhttp_siz10.py # HTTP transport sizing/optimization
Configuration
The application uses environment variables for configuration:
PORT: Server port (default: 8000)
SECRET_KEY: Authentication secret
RAILWAY_PUBLIC_DOMAIN: Public domain for Railway deployment
DATA_DIR: Persistent data directory (default: /data)
Quick Start
pip install -r requirements.txt
python main.py
The server will start on the configured port with web interface accessible via browser.