Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / vpn / AGENTS.md
| 1 | # AGENTS.md — vpn/ (':vpn') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `vpn/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install vpn (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :vpn / dir: vpn/ |
| 8 | - Package roots present: ui, data, platform, service |
| 9 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt |
| 10 | - Deps: :library:room, :library:network |
| 11 | - Metadata: metadata_data/vpn.md (present) |
| 12 | - Rust: yes / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** Offline-first WireGuard VPN client — user-imported configs, per-app bypass, connection logging. Tunnel crypto runs in a native Rust library. |
| 16 | **Key features:** |
| 17 | - WireGuard configs (manual import) with connect/disconnect via `service/VpnTunnelService` |
| 18 | - Per-app bypass list (`platform/BypassList` + `BypassListPage`); SNI parsing + packet inspection + DNS cache in `service/` |
| 19 | - Connection log persisted in Room; Material You UI |
| 20 | **Architecture / data-flow:** `ui/` config list/detail + logging → `platform/VpnViewModel` → `data/VpnRepository` over Room (`VpnConfig`, connection-log entities); tunnel control goes ViewModel → `service/VpnTunnelService` → Rust core via `util/VpnNative` JNI bridge; `service/ConnectionTracker` feeds the log. |
| 21 | **Entry points + reading order:** `Route` → `MainActivity.kt` → `Navigation.kt` → `ui/ConfigListPage.kt` → `platform/VpnViewModel.kt` → `service/VpnTunnelService.kt` → `util/VpnNative.kt`. |
| 22 | **Gotchas:** |
| 23 | - `util/` is NOT a closed package root — pending migration; don't add more files there |
| 24 | - Tunnel state lives in the service + Rust core — UI reflects, never drives; reconnect races come from driving twice |
| 25 | - VPN permission + always-on/blocking modes are system-mediated; test grant/revoke, not just in-app toggles |
| 26 | |
| 27 | ## Key files |
| 28 | ### Root — entry + navigation |
| 29 | - com/vayunmathur/vpn/MainActivity.kt |
| 30 | - com/vayunmathur/vpn/Navigation.kt |
| 31 | - com/vayunmathur/vpn/Route.kt |
| 32 | ### data/ — configs + connection log (Room) |
| 33 | - com/vayunmathur/vpn/data/VpnDatabase.kt |
| 34 | - com/vayunmathur/vpn/data/VpnRepository.kt |
| 35 | - com/vayunmathur/vpn/data/VpnConfig.kt |
| 36 | - com/vayunmathur/vpn/data/ConnectionLogDao.kt |
| 37 | - com/vayunmathur/vpn/data/ConnectionLogEntity.kt |
| 38 | ### platform/ — ViewModel + bypass |
| 39 | - com/vayunmathur/vpn/platform/VpnViewModel.kt |
| 40 | - com/vayunmathur/vpn/platform/BypassList.kt |
| 41 | ### service/ — tunnel, inspection, tracking |
| 42 | - com/vayunmathur/vpn/service/VpnTunnelService.kt |
| 43 | - com/vayunmathur/vpn/service/ConnectionTracker.kt |
| 44 | - com/vayunmathur/vpn/service/PacketInspector.kt |
| 45 | - com/vayunmathur/vpn/service/SniParser.kt |
| 46 | - com/vayunmathur/vpn/service/DnsCache.kt |
| 47 | - com/vayunmathur/vpn/service/AppResolver.kt |
| 48 | ### util/ — Rust bridge (pending migration to closed roots) |
| 49 | - com/vayunmathur/vpn/util/VpnNative.kt — JNI bridge into the WireGuard core |
| 50 | ### ui/ + ui/components/ — configs, bypass, logging |
| 51 | - com/vayunmathur/vpn/ui/VpnTabs.kt |
| 52 | - com/vayunmathur/vpn/ui/ConfigListPage.kt |
| 53 | - com/vayunmathur/vpn/ui/ConfigListContent.kt |
| 54 | - com/vayunmathur/vpn/ui/ConfigDetailPage.kt |
| 55 | - com/vayunmathur/vpn/ui/BypassListPage.kt |
| 56 | - com/vayunmathur/vpn/ui/LoggingPage.kt |
| 57 | - com/vayunmathur/vpn/ui/LoggingContent.kt |
| 58 | - com/vayunmathur/vpn/ui/SettingsPage.kt |
| 59 | - com/vayunmathur/vpn/ui/components/BypassHelpers.kt |
| 60 | |
| 61 | ## Verify (this module only) |
| 62 | ``` |
| 63 | ./gradlew :vpn:compileDevKotlin |
| 64 | ./gradlew :vpn:lint |
| 65 | ./gradlew :vpn:checkMetadata |
| 66 | ``` |