Return to Laboratory Monograph
ARTIFACT 01 // SYSTEMS SPECIFICATIONRUST · ANDROID TUN · NATIVE DESKTOP · SHADOWMUX-WSS
Bilvalabs emblem
Kestrel application crest

Kestrel: A Subtractive Network & Cryptographic Shield

Kestrel is Bilvalabs' primary systems engineering artifact — built to test whether deep HTTP/2 content filtering, per-application firewalling, encrypted DNS, and censorship-resistant zero-trust tunneling can coexist inside a tiny, auditable Rust core without kernel root, Electron bloat, or battery drain.

STATUS: BETA 1·MIT License·Authors: N. Rakkasi, Ranapratap
GitHub Repository — Public Release Forthcoming
DNS / SNI Lookup
161.3 ns
~6.20M ops/s · flat HashSet
Screen-Off CPU
0.70%
993K rules · 0 Hz idle TUN
Dalvik Heap PSS
9.2 MB
−95.5% via Rust stream loader
Relay Peak RAM
5.26 MB
64 streams · 1.1 MB musl binary
01 // Etymology & Architectural Thesis

Why Kestrel: biological precision backed by Rust

A kestrel is a compact falcon built for speed, open-sky hunting, motionless wind-hovering, and ultraviolet vision. Every trait of the bird maps directly to an engineering invariant inside kestrel-core:

Open Sky, No Cage
Carrier Freedom

Escalates Direct → DoH → ShadowMux-WSS past ISP blocks without caging clean traffic.

Midair Wind-Hover
0 Hz Idle Watch

Parks in Linux epoll at 0.70% CPU — motionless at rest while scanning every packet.

Ultraviolet Sight
Deep HTTPS Hunting

Sees inside TLS 1.3 HTTP/2 streams to strip ads and trackers invisible to plain DNS.

Small Bird, Larger Prey
Pure Rust Muscle

A 3.7 MB core and 1.1 MB relay outperforming bloated 200 MB security suites.

On unrooted Android, only one VpnService slot exists; on desktop, security suites routinely ship 150+ MB Electron shells. Kestrel solves both through one shared Rust engine attached to smoltcp on mobile and a fail-open loopback proxy (PROXY 127.0.0.1:47800; DIRECT) on Linux, Windows, and macOS.

02 // Modular Decomposition

Four crates, explicit platform boundaries

kestrel-core
Platform-agnostic Rust engine

4-layer AdGuard/uBO/DNS filter (~993K rules), ECDSA P-256 dynamic CA (84.8 ns LRU hit), HTTP/2 & HTTP/1.1 MITM, single-pass lol_html rewriter, SmartRouter, and lock-free telemetry.

android-core + android/
Non-root Android VpnService (3.7 MB arm64 .so)

Userspace smoltcp TCP/UDP stack, 0 Hz epoll-parked idle TUN loop, AtomicWaker backpressure, 16 KB page alignment, and VpnService-level auto-bypass for Indian UPI & banking apps.

kestrel-desktop
Zero-Electron native desktop daemon (Linux, Windows, macOS)

Single 6–10 MB Rust binary with native OS tray, hardened loopback proxy (:47800), fail-open PAC generator, crash-recovery proxy journal, OS/NSS CA trust, and MDM policy layer.

shadowmux-proto + relay-server
1.1 MB static-musl AEAD cloud micro-relay

Single-threaded Tokio server for 256 MB VMs. BLAKE3 keyed upgrade auth, inner ChaCha20-Poly1305 E2EE across TLS-terminating edges, 64 KB stream credit windows, and fdaa::/16 SSRF guard.

03 // Wire Protocol

ShadowMux-WSS v1: Zero-trust inner AEAD over untrusted edges

Clean traffic flows directly on Tier 0 with 0 ms detour. ISP DNS sinkholes promote automatically to Tier 1 encrypted HTTP/2 DoH/DoT. Only flows experiencing active SNI or TCP-RST censorship escalate to Tier 2: a personal 1.1 MB relay running on a 256 MB VM. Even though edge proxies terminate outer TLS 1.3, inner streams remain end-to-end encrypted:

# 1. Anti-probing HTTP Upgrade (±60s window, replay cache; unauthenticated probes -> static 200 OK)
X-Kestrel-Auth: <unix_ts>.<nonce_16hex>.BLAKE3_KEYED(PSK, "kestrel-auth-v1|...")[0..16]

# 2. Ephemeral 33-byte salt exchange & directional key derivation
ikm     = BLAKE3_KEYED(PSK, client_salt_32B || server_salt_32B)
c2s_key = BLAKE3_KEYED(ikm, "kestrel-shadowmux-v1-c2s")
s2c_key = BLAKE3_KEYED(ikm, "kestrel-shadowmux-v1-s2c")
stream_id0x00..0x03 · 4 B (BE)

0 for control plane (PING/PONG); odd IDs for client streams

cmd0x04 · 1 B

0x01 SYN_TCP · 0x02 SYN_UDP · 0x03 SYN_ACK · 0x04 DATA · 0x06 WINDOW_UPDATE · 0x07 FIN · 0x08 RST

flags0x05 · 1 B

Reserved (0x00 in v1)

length0x06..0x07 · 2 B (BE)

Payload length in bytes (0..=16,384 B)

payload0x08..N · length B

Encrypted inside ChaCha20-Poly1305 AEAD [dir_tag(4B), counter_le(u64)]

04 // Empirical Telemetry

Measured benchmarks & power engineering

Environment: rustc 1.93.1 --release · Sony Xperia SOG09 (Android 14, arm64-v8a) · Fly.io 256 MB shared-cpu-1x

Filter Rule Compilation103.32 ms
115,134 mixed DNS + AdGuard/uBO rules
~1.11M rules/sec (rustc 1.93.1 --release)
DNS / SNI Suffix Lookup161.3 ns / op
100,000 domains (50% hit / 50% miss)
~6.20M lookups/sec
Indexed HTTP/URL Rule Eval3.74 µs / op
15,000 deep network rules
~267K requests/sec
Streaming HTML Rewrite356.5 µs / 432.5 µs
52 KB HTML (CSS + scriptlets + CSP nonce, plain / gzip)
Single-pass lol_html · 2 MB stream cap
Dynamic ECDSA P-256 Leaf Cert0.12 ms / 84.8 ns
Cold sign vs. 512-entry LRU hit
~8.3K certs/s cold · ~11.8M hits/s cached
ShadowMux AEAD Throughput168.5 MB/s
ChaCha20-Poly1305 duplex (64 MB, 16 KB frames)
~1.35 Gbps single-core
Relay Peak RAM (VmHWM)5.26 MB
64 concurrent multiplexed streams, 4 MB echo
97.9% of 256 MB Fly.io cap free · 5.04 MB post-stress
Android Dalvik Heap PSS9.2 MB
993K active rules on Xperia SOG09 (Android 14)
Down 95.5% from 204.5 MB via streaming JNI loader
Settled Screen-Off Idle CPU0.70% of 1 core
993K rules loaded, active VPN, 10s sample
0 Hz idle TUN + 0 JNI calls while screen locked
Live adblock-tester.com22 / 22 checks
Zero-cache Chrome HTTP/2 session
11/11 services blocked (H2 403 + NXDOMAIN w/ 30s SOA)
05 // Explicit Boundaries

Trade-offs & active desktop research

  • Certificate Pinning & Opt-In CA: Deep HTTP/2 cosmetic filtering requires installing Kestrel's on-device ECDSA P-256 Root CA; pinned financial and Indian UPI applications are excluded automatically at the OS tunnel/proxy boundary so payments never fail. Layers 1–3 operate with zero CA installed.
  • Bounded Streaming Ceilings: HTML rewriting is strictly capped at 2 MB per document and 4,000 global CSS selectors so large downloads and video streams pass through without buffering.
  • Desktop QUIC & TLS Fingerprint Parity: Active desktop work focuses on deterministic Alt-Svc handling for HTTP/3 flows, TTL-cached auto-bypass on strict anti-bot origins, and sandboxed Linux NSS certificate store detection.