惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
Jina AI
Jina AI
小众软件
小众软件
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
MyScale Blog
MyScale Blog

dnsmasq-discuss

[Dnsmasq-discuss] Announce: dnsmasq-2.92rc2 Re: [Dnsmasq-discuss] [PATCH] Fix arguments order for chaos subdomain check Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] server= with interface parameter changes behavior over time [Dnsmasq-discuss] NFTsets and hosts-files [Dnsmasq-discuss] [PATCH] Allow expired RRSIGs when stale caching is enabled [Dnsmasq-discuss] [PATCH] Fix local host records being overridden by upstream NXDOMAIN [Dnsmasq-discuss] [PATCH] Fix arguments order for chaos subdomain check Re: [Dnsmasq-discuss] Malformed RRSIG Can Crash dnsmasq [Dnsmasq-discuss] Malformed NSEC/NSEC3 Can Hang dnsmasq [Dnsmasq-discuss] Malformed RRSIG Can Crash dnsmasq [Dnsmasq-discuss] Security - IMPORTANT Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] dnssec problem here and now Re: [Dnsmasq-discuss] dnssec problem here and now [Dnsmasq-discuss] dnssec problem here and now Re: [Dnsmasq-discuss] server= with interface parameter changes behavior over time Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] Preserve existing log file permissions when adding group-write bit. [Dnsmasq-discuss] server= with interface parameter changes behavior over time [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD
[Dnsmasq-discuss] patch: block-file/allow-file - for revi...
Ercolino de Spiacico · 2026-05-22 · via dnsmasq-discuss
In dnsmasq, domain filtering (for example, adblocking) currently relies on built-in directives such as local and address. That approach works well up to a point, but it does not scale: around 15 MB (≈700–800k domains) the process hangs regardless of available system resources.

To take a different approach I developed this patch in attachment that adds two new directives: block-file and allow-file. Summary of the functionality:

 - Uses mmap() to load domain lists into RAM.

 - Multiple block-file directives are supported.

 - Multiple allow-file directives are supported.

 - Example syntax:

block-file=/path/to/blockfile#NX,1

NX is optional and can be replaced with any IP address to return instead of NX.

The trailing ,1 is optional too, and enables logging when domains from that file are matched (useful to log only blocked domains).

allow-file=/mnt/USB/blockfile-override,1

- Mapped files must be pre-sorted (sorting is not included in this patch to keep the code minimal).

- Blocking/allowing behaviour mimics dnsmasq’s current semantics. For example:

  dnsmasq config:
  local=/example.com/ (blocked)
  server=/www.example.com/ (unblocked)

After the patch:

  example.com → listed in block-file
  www.example.com → listed in allow-file

- Files are loaded one at a time and assesses against the amount of RAM available. If Current RAM usage + blockfile >= 80% of Total RAM, the loading is skipped and logged as a warning.

- This code does not change DNS resolution itself; it performs a very fast name match to decide whether a query should proceed or be answered with NX or a custom IP.


I developed this patch for FreshTomato router (dnsmasq v2.93rc1). On those small devices I performed a functional test loading 2.2M domains (55 MB blockfile) and reload the configuration without interruptions; no packet drops were observed during a config when reloading. This is already 3 time the current limit, but I haven't performed any proper capacity testing yet, which is expected to be much higher.


Any comments or considerations are greatly appreciated.
Thanks.

<<attachment: dnsmasq-block-file.zip>>

_______________________________________________
Dnsmasq-discuss mailing list
[email protected]
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss