Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Built NetShield: A 100% Native Android VPN & Firewall Engine in Pure Kotlin & Jetpack Compose

说明与用途

NetShield 是一款 100% 原生 Android VPN 与防火墙,能够拦截广告、跟踪器和成人内容,保持低功耗并确保即时推送通知。

问题

Developing a local network protection engine that blocks ads, trackers, and adult content across all apps while maintaining battery efficiency and push notification reliability on Android.

结果

NetShield delivers native ad and tracker blocking across all apps, maintains low battery drain, and ensures reliable push notifications, all without third‑party binaries.

工作流

  • 1. Implement VpnService and DatagramSocket in pure Kotlin.
  • 2. Build an O(k) reverse label trie for instant domain sinkholing.
  • 3. Resolve socket owner UIDs via getConnectionOwnerUid for per‑app firewalling.
  • 4. Use a zero‑CPU CountDownLatch wait thread and in‑memory LRU DNS cache to avoid battery doze mode.
  • 5. Add fast‑path routing for FCM (mtalk.google.com) and WhatsApp push sockets.
  • 6. Persist rules, stats, and custom domains in Room DB v5 SQLite.
  • 7. Release on GitHub and publish APK release.

证据

Building a local network protection engine from scratch came with major technical challenges and engineering learnings:

来源

I learned why DNS-level VPNs excel at blocking 3rd-party ad networks, pop-ups, and tracking domains across 100% of apps, but cannot block inlined first-party video streams (like YouTube or Instagram) without breaking main video playback.

来源

Solved Android OEM background battery killers by implementing a zero-CPU CountDownLatch wait thread and an in-memory LRU DNS cache to keep idle battery drain under ~1–2%.

来源

Added specialized fast-path routing for FCM (mtalk.google.com) and WhatsApp push sockets so real-time notifications deliver instantly even in deep sleep.

来源

100% Native Kotlin: Built using Android standard library (VpnService, DatagramSocket) with zero 3rd-party C++ binaries.

来源

  • 记录日期: 2026-10-13T14:55:54.168Z