hn.today

ESP32-C3 Adblock

github.com81 points28 comments
Screenshot of ESP32-C3 Adblock

ESP32-C3 Adblock implements a Pi-hole-style DNS sinkhole on a $2 ESP32-C3 by storing sorted 40-bit FNV-1a domain hashes in flash and binary-searching them at query time. That fixed 5-byte hash-per-domain design fits large blocklists in flash instead of RAM: about 141k domains take ~0.67 MB flash and use ~50 KB RAM, with lookups taking ~10 ms (≈18 flash reads including Wi‑Fi RTT). The author explains the 40-bit tradeoff (near-zero collisions at 141k, ~1 collision at 537k), compares it to string-in-RAM approaches that require PSRAM and megabytes of RAM, and notes the same hash-in-flash method scales on larger ESP32 chips. Hardware tested is any ESP32‑C3 with 4 MB flash (C3 SuperMini), and a printable enclosure is provided.

Setup and operation are handled via PlatformIO for initial USB flash, then firmware and blocklists update over Wi‑Fi from a web dashboard at c3adblock.local or via remote URLs. A build script accepts hosts, domain lists, and AdGuard-style rules to produce blocklist.bin; the device offers a captive portal for Wi‑Fi setup if needed. Security uses HTTP Basic Auth for all mutating endpoints and a separate OTA password; read-only stats stay open. Because the device serves plain HTTP, credentials are sent as base64 and CSRF is mitigated by requiring a custom X-Requested-With header on state-changing requests. Partition choices affect OTA capability and maximum blocklist size.

Read on github.com28 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Hardware

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.