Try Live
Add Docs
Rankings
Pricing
Enterprise
Docs
Install
Install
Docs
Pricing
Enterprise
More...
More...
Try Live
Rankings
Add Docs
Clash Verge Rev
https://github.com/clash-verge-rev/clash-verge-rev
Admin
Clash Verge Rev is a continuation of Clash Verge, offering a Clash Meta GUI built with Tauri,
...
Tokens:
10,227
Snippets:
106
Trust Score:
6.1
Update:
3 weeks ago
Context
Skills
Chat
Benchmark
Suggestions
Latest
Show doc for...
Code
Info
Show Results
Context Summary (auto-generated)
Raw
Copy
Link
# Clash Verge Rev Clash Verge Rev is a modern, cross-platform GUI application for the Clash/Mihomo network proxy core, built with Tauri 2.0 (Rust backend) and React (TypeScript frontend). It provides an intuitive interface for managing proxy configurations, subscription profiles, TUN mode, system proxy settings, and traffic monitoring across Windows, macOS, and Linux platforms. The application integrates the Mihomo (Clash Meta) core internally and offers features like profile enhancement through merge configs and scripts, visual node/rule editing, WebDAV backup synchronization, and customizable themes. The project follows a client-server architecture where the Rust backend handles core proxy management, system integration, and configuration persistence, while the React frontend provides the user interface through Tauri's IPC mechanism. Commands are exposed as Tauri commands that can be invoked from the frontend, enabling seamless communication between the UI and the underlying proxy core. ## Profile Management Profile management handles subscription imports, local profile creation, and profile switching. Profiles can be imported from URLs or created locally, with support for automatic updates and enhanced configurations. ```typescript // Import a subscription profile from URL import { invoke } from '@tauri-apps/api/core'; // Import a remote subscription await invoke('import_profile', { url: 'https://example.com/subscription.yaml', option: { update_interval: 1440, // Update every 24 hours (in minutes) user_agent: 'clash-verge-rev', with_proxy: false } }); // Get all profiles const profiles = await invoke('get_profiles'); console.log(profiles); // { // current: "profile-uid-123", // items: [ // { uid: "profile-uid-123", name: "My Subscription", type: "remote", ... }, // { uid: "profile-uid-456", name: "Local Config", type: "local", ... } // ] // } // Switch to a different profile const success = await invoke('patch_profiles_config_by_profile_index', { profileIndex: 'profile-uid-456' }); // Update a specific profile (re-download subscription) await invoke('update_profile', { index: 'profile-uid-123', option: { with_proxy: true } // Use proxy for update }); // Create a new local profile await invoke('create_profile', { item: { type: 'local', name: 'Custom Rules', desc: 'My custom proxy rules' }, fileData: ` proxies: - name: "proxy1" type: ss server: server.example.com port: 443 cipher: aes-256-gcm password: "password" proxy-groups: - name: "auto" type: url-test proxies: ["proxy1"] rules: - DOMAIN-SUFFIX,google.com,auto - MATCH,DIRECT ` }); // Delete a profile await invoke('delete_profile', { index: 'profile-uid-123' }); // Read profile file content const content = await invoke('read_profile_file', { index: 'profile-uid-123' }); ``` ## Clash Core Management The Clash core commands control the Mihomo proxy engine, including starting, stopping, restarting, and switching between core versions. ```typescript import { invoke } from '@tauri-apps/api/core'; // Get current Clash configuration info const clashInfo = await invoke('get_clash_info'); console.log(clashInfo); // { // status: "running", // port: 7897, // socks_port: 7898, // mixed_port: 7897, // server: "127.0.0.1:9097", // secret: "your-secret" // } // Start the core await invoke('start_core'); // Stop the core await invoke('stop_core'); // Restart the core await invoke('restart_core'); // Change Clash core version (mihomo or mihomo-alpha) const error = await invoke('change_clash_core', { clashCore: 'verge-mihomo-alpha' }); if (error) { console.error('Failed to change core:', error); } // Patch Clash configuration (runtime config changes) await invoke('patch_clash_config', { payload: { 'mixed-port': 7890, 'allow-lan': true, 'mode': 'rule' } }); // Change Clash mode (rule/global/direct) await invoke('patch_clash_mode', { payload: 'rule' }); // Test URL delay (latency check) const delay = await invoke('test_delay', { url: 'https://www.google.com' }); console.log(`Latency: ${delay}ms`); // Get Clash core logs const logs = await invoke('get_clash_logs'); logs.forEach(log => console.log(log)); // Copy Clash environment variables to clipboard await invoke('copy_clash_env'); ``` ## Verge Application Configuration Verge configuration manages application-level settings including theme, language, proxy settings, hotkeys, and TUN mode options. ```typescript import { invoke } from '@tauri-apps/api/core'; // Get current Verge configuration const vergeConfig = await invoke('get_verge_config'); console.log(vergeConfig); // { // language: "en", // theme_mode: "dark", // enable_tun_mode: false, // enable_system_proxy: true, // enable_auto_launch: true, // verge_mixed_port: 7897, // ... // } // Patch Verge configuration await invoke('patch_verge_config', { payload: { // UI Settings language: 'en', theme_mode: 'dark', // 'light' | 'dark' | 'system' start_page: '/', traffic_graph: true, enable_memory_usage: true, // Proxy Settings enable_system_proxy: true, enable_tun_mode: false, enable_proxy_guard: true, proxy_guard_duration: 30, proxy_host: '127.0.0.1', verge_mixed_port: 7897, verge_socks_port: 7898, // Auto-start enable_auto_launch: true, enable_silent_start: false, // Advanced auto_close_connection: true, auto_check_update: true, default_latency_test: 'https://www.gstatic.com/generate_204', default_latency_timeout: 5000, // Hotkeys (format: "function,key") hotkeys: [ 'toggle_system_proxy,Alt+Shift+P', 'toggle_tun_mode,Alt+Shift+T', 'open_dashboard,Alt+Shift+D' ], // Theme customization theme_setting: { primary_color: '#1976d2', secondary_color: '#9c27b0', font_family: 'Roboto, sans-serif', css_injection: '.custom-class { color: red; }' } } }); ``` ## DNS Configuration DNS settings allow customization of DNS resolution behavior within the proxy core. ```typescript import { invoke } from '@tauri-apps/api/core'; // Save DNS configuration to file await invoke('save_dns_config', { dnsConfig: { enable: true, listen: '0.0.0.0:1053', 'enhanced-mode': 'fake-ip', 'fake-ip-range': '198.18.0.1/16', nameserver: [ 'https://dns.google/dns-query', 'https://cloudflare-dns.com/dns-query' ], fallback: [ 'tls://8.8.8.8:853', 'tls://1.1.1.1:853' ], 'fallback-filter': { geoip: true, 'geoip-code': 'CN', ipcidr: ['240.0.0.0/4'] } } }); // Apply DNS configuration await invoke('apply_dns_config', { apply: true }); // Check if DNS config file exists const exists = await invoke('check_dns_config_exists'); // Get DNS config content const dnsContent = await invoke('get_dns_config_content'); // Validate DNS config const [isValid, message] = await invoke('validate_dns_config'); if (!isValid) { console.error('DNS config validation failed:', message); } ``` ## Local Backup Management Local backup commands handle creating, listing, restoring, and managing backup archives on the local filesystem. ```typescript import { invoke } from '@tauri-apps/api/core'; // Create a local backup await invoke('create_local_backup'); // List all local backups const backups = await invoke('list_local_backup'); console.log(backups); // [ // { filename: "backup_2024-01-15_10-30-00.zip", size: 102400, created: 1705311000 }, // { filename: "backup_2024-01-14_08-00-00.zip", size: 98304, created: 1705219200 } // ] // Restore from a local backup await invoke('restore_local_backup', { filename: 'backup_2024-01-15_10-30-00.zip' }); // Delete a local backup await invoke('delete_local_backup', { filename: 'backup_2024-01-14_08-00-00.zip' }); // Import external backup file const importedFilename = await invoke('import_local_backup', { source: '/path/to/external/backup.zip' }); // Export backup to external location await invoke('export_local_backup', { filename: 'backup_2024-01-15_10-30-00.zip', destination: '/path/to/export/directory' }); ``` ## WebDAV Cloud Backup WebDAV integration enables cloud backup and synchronization of configurations. ```typescript import { invoke } from '@tauri-apps/api/core'; // Save WebDAV configuration (credentials are encrypted) await invoke('save_webdav_config', { url: 'https://webdav.example.com/clash-verge/', username: 'your-username', password: 'your-password' }); // Create and upload backup to WebDAV await invoke('create_webdav_backup'); // List backups on WebDAV server const cloudBackups = await invoke('list_webdav_backup'); console.log(cloudBackups); // [ // { href: "/clash-verge/backup_2024-01-15.zip", ... }, // { href: "/clash-verge/backup_2024-01-14.zip", ... } // ] // Restore backup from WebDAV await invoke('restore_webdav_backup', { filename: 'backup_2024-01-15.zip' }); // Delete backup from WebDAV await invoke('delete_webdav_backup', { filename: 'backup_2024-01-14.zip' }); ``` ## Service Mode Management Service mode commands manage the privileged system service required for TUN mode on supported platforms. ```typescript import { invoke } from '@tauri-apps/api/core'; // Check if service is available const isAvailable = await invoke('is_service_available'); console.log('Service available:', isAvailable); // Install the service (requires admin/root privileges) await invoke('install_service'); // Uninstall the service await invoke('uninstall_service'); // Reinstall the service (upgrade) await invoke('reinstall_service'); // Repair/force reinstall the service await invoke('repair_service'); // Get current running mode const runningMode = await invoke('get_running_mode'); console.log(runningMode); // "Service" or "Sidecar" ``` ## Network and System Information Network commands provide system proxy status, network interface information, and port availability checks. ```typescript import { invoke } from '@tauri-apps/api/core'; // Get system proxy settings const sysProxy = await invoke('get_sys_proxy'); console.log(sysProxy); // { enable: true, server: "127.0.0.1:7897", bypass: "localhost;127.0.0.1" } // Get auto proxy (PAC) settings const autoProxy = await invoke('get_auto_proxy'); console.log(autoProxy); // { enable: false, url: "" } // Get system hostname const hostname = await invoke('get_system_hostname'); console.log('Hostname:', hostname); // Get network interfaces const interfaces = await invoke('get_network_interfaces'); console.log(interfaces); // ["eth0", "wlan0", "lo"] // Get detailed network interface info const interfaceInfo = await invoke('get_network_interfaces_info'); interfaceInfo.forEach(iface => { console.log(`${iface.name}: ${iface.addr}`); }); // Check if port is in use const portInUse = await invoke('is_port_in_use', { port: 7897 }); console.log('Port 7897 in use:', portInUse); ``` ## Application Utilities Application utility commands for directory access, app lifecycle, and icon management. ```typescript import { invoke } from '@tauri-apps/api/core'; // Open application directories await invoke('open_app_dir'); // Open config directory await invoke('open_core_dir'); // Open binary directory await invoke('open_logs_dir'); // Open logs directory // Open log files await invoke('open_app_log'); // Open Verge app log await invoke('open_core_log'); // Open Clash core log // Open external URL in browser await invoke('open_web_url', { url: 'https://github.com/clash-verge-rev' }); // Toggle developer tools await invoke('open_devtools'); // App lifecycle await invoke('restart_app'); await invoke('exit_app'); // Get app info const isPortable = await invoke('get_portable_flag'); const appDir = await invoke('get_app_dir'); const autoLaunch = await invoke('get_auto_launch_status'); // Icon caching for proxy groups const iconPath = await invoke('download_icon_cache', { url: 'https://example.com/icon.png', name: 'proxy-group-icon' }); // Copy custom icon file const copiedPath = await invoke('copy_icon_file', { path: '/path/to/icon.svg', iconInfo: { type: 'tray', name: 'custom-tray' } }); ``` ## IP Geolocation Detection (Frontend API) The frontend service provides IP geolocation detection using multiple fallback providers. ```typescript import { getIpInfo } from '@/services/api'; // Detect current IP and geolocation try { const ipInfo = await getIpInfo(); console.log(ipInfo); // { // ip: "203.0.113.45", // country_code: "US", // country: "United States", // region: "California", // city: "San Francisco", // organization: "Example ISP", // asn: 12345, // asn_organization: "Example Networks", // longitude: -122.4194, // latitude: 37.7749, // timezone: "America/Los_Angeles", // lastFetchTs: 1705320000000 // } } catch (error) { console.error('IP detection failed:', error.message); } ``` ## Development Setup Build and run the application from source for development or contribution purposes. ```bash # Prerequisites: Install Rust and Node.js # See https://tauri.app/start/prerequisites/ # Enable corepack for pnpm corepack enable # Install dependencies pnpm install # Download Mihomo core binary pnpm run prebuild pnpm run prebuild --force # Force re-download # Run development server pnpm dev # Standard development pnpm dev:diff # If app instance exists pnpm dev:tauri # Tauri development mode # Build for production pnpm build # Standard build pnpm build:fast # Fast build for testing # Code quality cargo clippy # Rust linting cargo fmt # Rust formatting pnpm lint # Frontend linting pnpm format # Frontend formatting # Windows portable version pnpm portable ``` ## Summary Clash Verge Rev serves as a comprehensive GUI solution for network proxy management, particularly suited for users who need flexible proxy configuration with support for multiple protocols through the Mihomo/Clash Meta core. The application excels in scenarios requiring TUN mode for system-wide transparent proxying, subscription management with automatic updates, and multi-profile switching for different network environments. Its WebDAV backup feature enables seamless configuration synchronization across devices, while the built-in profile enhancement system (merge configs and scripts) allows advanced users to customize proxy behavior without modifying source subscriptions. Integration with external systems is straightforward through Tauri's command system, which exposes all core functionality as async IPC calls from the React frontend. Developers can extend the application by adding new Tauri commands in the Rust backend (`src-tauri/src/cmd/`) and consuming them from TypeScript. The modular architecture separates concerns between configuration management (`config/`), core proxy operations (`core/`), feature implementations (`feat/`), and UI commands (`cmd/`), making it maintainable and extensible for custom workflows and automated proxy management scenarios.