Skip to content

Compile downloaded DNS blocklists for a home DNS sinkhole (hosts, adblock and plain formats, IDN, allow exceptions, minimal output)

Exact prompt

# Compile downloaded DNS blocklists for a home DNS sinkhole Our home network's DNS sinkhole takes one merged list. `lists/` holds downloaded lists in three styles. Rewrite `blocklist.py` (Python 3 stdlib only) so that `compile_lists(folder)` returns the merged, minimal result described below, `is_blocked(result, domain)` answers queries, and `python blocklist.py [folder]` (default `lists`) writes the result to `report.json`. ## Reading lines 1. Read every file in `folder` whose name ends in `.txt`, in sorted filename order, as UTF-8; lines are numbered from 1 in each file. Each line is stripped. Skip blank lines and lines starting with `!` or `#`. Then cut a trailing comment: everything from the first whitespace character that is followed by `#`. 2. A line containing `$` (adblock options) is **unsupported**. 3. `||D^` is a **wildcard block** of D (D and all subdomains); `@@||D^` is a **wildcard allow**. (D must not contain `|`, `^` or `/`.) 4. Any other line that starts with `@@` or `|`, or contains `/` or `^`, is **unsupported**. 5. A single word `*.D` is a wildcard block of D; any other single word D is an **exact block** of D only. 6. Several words: if the first is one of `0.0.0.0`, `127.0.0.1`, `::`, `::1`, each following word is an exact block. Lines starting with any other word (e.g. `192.168.1.20 nas.home.arpa`, a local name override) are ignored without a report. 7. Unsupported lines are reported as `[filename, line_number, original_line]` where original_line is the line without its trailing newline (not stripped). ## Domains 8. Before validation: strip, lowercase and remove one or more trailing dots. If the result is one of `localhost`, `localhost.localdomain`, `broadcasthost`, `local`, `ip6-localhost`, `ip6-loopback`, `0.0.0.0`, skip it silently. 9. Convert with Python's built-in `idna` codec (`d.encode("idna").decode("ascii")`; `UnicodeError` = invalid). The result is valid if it is at most 253 characters, has at least 2 labels, the last label is not all digits, and every label is 1-63 characters of `a-z 0-9 -` not starting or ending with `-`. 10. Each invalid domain adds `[filename, line_number, original_line]` to `invalid` (once per invalid domain, so a hosts line with two invalid domains appears twice). ## Result (all lists sorted ascending, no duplicates) 11. "A covers B" means B equals A or ends with `"." + A`. 12. `wildcard`: wildcard-block domains not covered by another wildcard-block domain (other than themselves) and not covered by any wildcard-allow domain. 13. `exact`: exact-block domains not covered by any domain in the final `wildcard` list and not covered by any wildcard-allow domain. 14. `allow`: wildcard-allow domains that are covered by some domain in the final `wildcard` list (allows that unblock nothing are dropped), then minus those covered by another kept allow domain. 15. `invalid` and `unsupported`: in reading order. 16. `is_blocked(result, domain)`: normalise `domain` as in rules 8-9 (an invalid domain is not blocked); it is not blocked if any `allow` domain covers it; otherwise it is blocked if it is in `exact` or covered by a `wildcard` domain. For `lists/` here the correct `wildcard` is `["doubleclick.example", "telemetry.example", "xn--bcher-ads-q9a.example"]`. ## Scoring Hidden checks (partial credit = fraction passed; all must pass): on a hidden folder of 4 lists (~300 lines) `wildcard_exact`, `exact_exact`, `allow_exact`, `invalid_exact`, `unsupported_exact` (each key equal), `is_blocked_queries` (400 queries), `fresh_lists_exact` (all five keys on a second hidden folder) and `cli_report` (`python blocklist.py lists` writes `report.json` equal to the result for `lists/`).

Three line formats with unsupported-vs-ignored distinctions, IDN conversion and label validation, and a minimal output where wildcards absorb exact entries, allows override blocks, and allows that unblock nothing are dropped. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).

Success criteria: 1. wildcard_exact 2. exact_exact 3. allow_exact 4. invalid_exact 5. unsupported_exact 6. is_blocked_queries 7. fresh_lists_exact 8. cli_report

Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.02, 15m).

Run this on another model

All runs (4)

100% pass rate across 4 eligible runs: 4 pass, 0 partial, 0 fail. Partial and failed runs are listed below with everything else.ⓘ

Runs for this use case
ModelCostTimeStep-insⓘAutonomyOutcomeTrustⓘDateCompare
OGPT-6.1 Soldefault · thinking on$0.0456s0Fully autonomouspassTrust 80%2026-10-22
AClaude Haiku 5.5default · thinking on$0.0215m0Fully autonomouspassTrust 75%2026-10-20
AClaude Opus 5.5default · thinking on$0.1937s0Fully autonomouspassTrust 80%2026-10-20
AClaude Sonnet 5.5default · thinking on$0.0823s0Fully autonomouspassTrust 80%2026-10-20

Embed this result

A live badge for this use case. It links back here and updates as new runs are published.

UseCaseRank badge for Compile downloaded DNS blocklists for a home DNS sinkhole (hosts, adblock and plain formats, IDN, allow exceptions, minimal output)

Get new runs and ranking changes weekly

Which models got better or cheaper on real tasks like this one.