$ show 2dust/v2rayNG
v2rayNG is a production-grade Android VPN/proxy client that provides a comprehensive interface for managing V2Ray and Xray proxy configurations. It supports multiple proxy protocols (VMess, VLESS, Shadowsocks, Trojan, WireGuard, Hysteria2, SOCKS, HTTP), subscription management with auto-update, routing rules, per-app proxy, and backup/restore via local files or WebDAV. The app runs in three modes: VPN (TUN), proxy-only (local SOCKS/HTTP), and root (iptables transparent proxy). It uses native cores (Xray or v2fly) via JNI and manages complex configuration generation, including DNS segmentation, observatory-based load balancing, and fragment settings. The architecture follows standard Android patterns with Compose UI, ViewModels, and background services in separate processes. The codebase is actively maintained with a large community, though some modules (e.g., CoreConfigManager) are monolithic and could benefit from further decomposition.
The LLM identified 3 files worth highlighting for reuse:
Parses and serializes VMess share links (v2rayN format, legacy, and new) into ProfileItem objects and vice versa. Handles base64-encoded JSON, query parameters, and multiple configuration versions. The implementation is self-contained, with clear error handling and round-trip fidelity. Could be extracted as a standalone library for VMess URI handling.
Executes shell commands with root privileges using a timeout mechanism. Manages process lifecycle, captures stdout/stderr, and handles cancellation. The abstraction is clean and reusable for any Android app requiring root command execution with safety guarantees.
Extracts ZIP archives with strict security checks: limits on archive size, entry count, individual entry size, total decompressed bytes, and compression ratio to prevent zip bombs. The implementation is self-contained and can be reused in any Kotlin/Java project needing safe ZIP extraction.
The divergent implementation provides a more robust and efficient network connectivity observer by properly handling device idle mode through BroadcastReceiver and using ArraySet for network tracking, which is more efficient than the typical approach. It correctly implements network callback logic to track available networks and posts accurate connection states, while also properly handling the device idle mode scenario by posting false when idle and rechecking state when exiting idle mode. The use of `postCurrentState()` ensures proper initialization and state synchronization, making it more reliable than typical implementations that may miss edge cases or have less efficient data structures.