一位开发者在 GitHub 发布了基于 ESP32-C3 芯片的 Pi-hole 风格 DNS 广告拦截器项目,以极低的硬件成本实现高效的广告过滤功能 1。该方案采用价格仅为 2 美元的 ESP32-C3 芯片、4 MB 闪存构成,无需额外的 PSRAM 扩展 1。
项目的核心创新在于存储优化策略 1。开发者将 140,000+ 个域名转换为 40 位 FNV-1a 哈希值存储在闪存中,仅占用约 0.7 MB 空间,通过二分查找算法实现约 10 毫秒的域名匹配延迟,内存占用仅需 50 KB RAM 1。在 141,000 个域名规模下,哈希碰撞率约为 0 次,即使在 537,000 个域名的场景下也仅产生约 1 次碰撞 1。该方案扩展性良好,在 16 MB 的 ESP32-S3 芯片上可存储约 2.7 百万个域名,超越传统 PSRAM 字符串存储方案的 466,000 域名上限 1。
项目提供了完整的管理功能,包括 Web 仪表板、WiFi 设置门户、固件 OTA 更新和远程自动更新等 1。安全方面采用 HTTP Basic Auth 认证、CSRF 防护、HTML 转义和默认凭证检测等措施 1。项目采用 MIT 许可证开源发布 1。
A developer has released an open-source DNS ad-blocker designed to run on a $2 ESP32-C3 microcontroller, eliminating the need for external RAM while delivering performance comparable to larger systems 1. The project stores over 140,000 domain names as 40-bit hash values in flash memory, occupying approximately 0.7 MB of storage and consuming just 50 KB of RAM during operation 1. Using binary search algorithms, the system achieves domain matching in roughly 10 milliseconds 1.
The technical approach relies on storing hashed domain names rather than full strings, a strategy that enables exceptional memory efficiency on the resource-limited ESP32-C3, which features only 4 MB of flash storage 1. Testing demonstrates virtually no hash collisions across 141,000 domains, with collision rates rising to approximately one collision at 537,000 domains 1. The scalability of this architecture becomes more apparent on higher-end variants; a 16 MB ESP32-S3 could theoretically accommodate approximately 2.7 million domains, surpassing the capacity of traditional string-based approaches that max out around 466,000 domains on the same hardware 1.
The project includes practical management features such as a web dashboard, WiFi configuration portal, firmware over-the-air updates, and remote automatic list updates 1. Security measures incorporate HTTP Basic Authentication with configurable credentials, CSRF protection, HTML escaping, and detection of unchanged default login credentials 1. Released under the MIT license, the solution has attracted coverage from technology publications including Tom's Hardware and XDA Developers 1.
评论
还没有评论,欢迎留下第一条。