Skip to content

Blocking

Name a published list in blocking.toml, save the file, and the server blocks what that list holds. Nothing is blocked until you do.

./data/config/blocking.toml
[[source]]
id = "hagezi-pro"
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/pro-onlydomains.txt"

The server reads the file, fetches the list and starts blocking, with no restart. Ask it about a name the list holds:

Terminal window
dig @127.0.0.1 -p 5300 ads.example.com A +short
0.0.0.0

0.0.0.0 means blocked. blocking.toml: the lists this server blocks from has every key this file takes, with its default and its range.

A source is one list somebody publishes, with an id you choose. The id is yours: it names the column a blocked query’s row carries, so hagezi-pro in a row is the source you called hagezi-pro.

A source is a url or a path, never both.

A url is https only. Anybody on the path can edit a list over plain HTTP, and so can change which names this server refuses. A url goes through the outbound proxy where outbound_proxy_for names blocklists, which it does by default. It never goes direct where the proxy fails (Requests through a proxy).

A path is a file inside the config root, for the names you keep yourself. Its name cannot be one that the config root skips, such as .local-list, names.tmp or notes~, because no revision holds such a file. A blocklist this server will not take says what to do with one.

A file under blocklists/ of the config root can hold 16 MiB, about 600,000 names. A file at another place can hold 4 MiB. Every revision and every backup holds the file. A file under blocklists/ that did not change takes the disk space of one copy for all the kept revisions. A file at another place takes one copy for each revision, and so does a file where the server cannot make a hard link.

Every hop of a fetch must reach a public address, the first hop included, or the fetch ends. A list served by a machine of your network, or by this one, needs private = true on its source. An admin sets it (Blocklist sources on your network). The setting covers the host and the port that the URL names. A redirect to another host still reaches a public address alone. A publisher who answers with location: pointing at an address in your house gets the fetch stopped. Without the rule, whoever can name a URL could make this server knock on the machines of the house. A publisher who later points its name inside would reach them at each refresh.

The rule is a filter of special addresses, not a firewall. It puts each address in one of three classes. An address that carries another one, in an IPv6 form, a NAT64 prefix, 6to4 or Teredo, takes the worse class of the two:

  • A public address passes, on every hop.
  • An address inside your network passes only on the host and the port of the URL of a source with private = true: loopback, the private ranges, carrier-grade NAT, unique-local IPv6, the documentation ranges, every IPv6 address outside 2000::/3, and the prefixes of rebind_inside. An address in a prefix of rebind_nat64 is judged by the IPv4 address that it carries.
  • An address that no source reaches is always refused: the unspecified address, link-local such as 169.254.169.254, multicast and broadcast. A host written as a number in a form other than four decimal parts is refused too, such as 0xa9fea9fe or 169.254. A resolver or a proxy can read it as any address.

What it does not do:

  • A global address of your house that no prefix of rebind_inside names passes. So does an address of a translation prefix that nobody declared. An operator can change both lists in server.toml. The rule binds a publisher, and not an operator.
  • Through the outbound proxy, the proxy looks the name up, so this server sees no address. An address in the URL meets the three classes above. A name of one label, such as localhost, and a name under local, home.arpa or internal go to the proxy only from a source with private = true. Any other name goes to the proxy, and the proxy decides where it connects. A role below admin adds a URL through the proxy only from the catalog of known lists. An admin adds any other. Only an admin sends the lists through a proxy that no list fetch of the running revision went through: a moved proxy, a new one, or one that sat unused while the lists went direct.
  • The time a refresh takes can still tell a refused connection from a silent one. The rule does not hide that.

The record of a refused fetch names the address for an admin. An operator, a viewer and the log read a short phrase of its kind, which names no address.

A pass reads the list file of a path from the running revision, not from the config root. A hand edit of the file serves only once the watcher takes it as a revision. An edit that the watcher refuses is not served, and the list keeps the file of the revision. A revision that changes the file makes the source due at once, so the pass that the revision starts reads the new file. The old list serves until the new one is compiled.

Write the path in the case of the file: where the file is blocklists/home.txt, the path blocklists/Home.txt is refused. A list can hold bytes that are not UTF-8, such as a list in Latin-1. Each line with such a byte counts as an invalid line. Configuration says when such a file enters a revision. The server cannot see a hard link to a file, so keep the config root to the account that runs the server.

The server reads every source at a start and at every change to this file. After that each source has its own interval. A publisher declares how long their file stays current, and a declaration shorter than refresh_hours shortens that source’s interval, down to min_refresh_minutes. So a list that says one hour is read hourly beside one that says eight hours. blocking.toml: the lists this server blocks from has both settings and the refresh_hours you can put on one source, which wins over the other two.

An interval carries up to a tenth of itself as jitter, so every server does not ask its publisher at the same moment. A source that did not arrive is tried again in half a minute. The server keeps answering meanwhile with whatever that source held. A body that arrived and was refused waits the ordinary interval of the source instead. The publisher has to change it, and asking twice a minute would only load the publisher. A list file that the running revision does not hold, or holds damaged, waits the interval too, because the revision does not change in half a minute. The log warns about it once, and again when a revision changes it or the source did something else in between. Any revision after it, a rollback among them, makes the source due at once. A list file that the system did not open, such as with too many files open, is tried again in half a minute.

A source whose url you change is read at once, whatever its interval says. So is one whose action, subtree or exceptions you change, because those decide what the compiled list holds.

What each source last did is written down. blocklists/attempts.toml in the state root holds one record per source. The record names when this server last asked, what happened, when it last worked, the numbers a gate refused it with, and the body it refused. A source that keeps failing is stale from the last time it worked rather than from the last time it was asked.

A source you take out of the file has its content deleted by the pass that notices, and its record with it.

A list is read line by line, and each line is read as what it is. So a list of plain names, a hosts file and an Adblock Plus list all work, and a list that mixes them works too.

Line Means
ads.example.com Block it and the names under it
*.ads.example.com The same, said the other way
0.0.0.0 ads.example.com The same. A hosts file to a null address
||ads.example.com^ The same. The Adblock Plus form
||ads.example.com The same, with no separator character
@@||good.example.com^ Allow it and the names under it, inside this list
||ads.example.com^$badfilter Cancel that block, inside this list
# anything or ! anything A comment, skipped
192.0.2.10 host.example Skipped. That is a real mapping, not a rule

So a name blocks the names under it: ads.example.com blocks img.ads.example.com and does not block adsnot.example.com. A list whose entries mean the exact name and nothing else wants subtree = false on its source. An Adblock rule says what it covers itself, so ||ads.example.com^ covers the names under it whatever subtree says.

||ads.example.com without the separator means a prefix in a browser, so it would also match ads.example.com.other.test. This server reads it as the name and the names under it and nothing else, for a block and for an @@ line alike. Narrower is the safe direction in both. A block that covered a prefix would block a stranger’s name because a list mentioned part of it. An exception read narrowly blocks a name that the publisher meant to let through, and you can add that name to your own allow entries. Nobody can find the stranger’s name.

An @@ line allows a name inside the list it came from, which is the same rule your own allow entries follow for a source. To let a list’s exceptions cancel every list, write exceptions = "global" on that source.

A $badfilter line cancels a rule the same list holds: ||ads.example.com^$badfilter takes that block out, and @@||good.example.com^$badfilter takes that exception out. It cancels inside its own list only, and it cancels the rule about that name whichever line wrote it.

These Adblock lines are counted and not read, because a name lookup cannot honor them:

Line Why
||ads.example.com^$important A modifier this build does not read
@@||x.example.com^$dnstype=AAAA An exception for one query type is not one for all
/^ads[0-9]+\.example\.com/ A regular expression
||ads.*.example.com^ A wildcard inside the pattern
.ads.example.com^ A leading dot means the names under it and not it
example.com##.ad-banner A rule about an element on a page
|http://ads.example.com/x A rule about a URL
local=/ads.example.com/ The dnsmasq form, which nothing reads yet

Two of those are shapes this server could hold and does not yet: a wildcard inside a pattern and a leading dot. The rest are rules for a browser, which a name lookup cannot honor however this is written.

GET /api/blocking/sources counts each shape on its own, so a list of element rules reads as a browser list rather than as a list holding nothing. Point this server at a DNS list instead: the same publishers ship one.

A source you know the shape of can say so with format = "abp", and then a line that is not one of the Adblock forms is counted rather than read. That is how a list that changed shape becomes visible. format = "auto" is the default and reads all of the above.

Put it in the same file. Your own allow entries beat every list. Your own blocks beat every list except two kinds of allow rule. These are an @@ line of a source with exceptions = "global", and every rule of an allow source, below.

A group can allow a name you block here. Every allow name is read before every block name, so an allow wins wherever you write it. clients.toml: who is asking has the group keys.

[[allow]]
name = "clicks.example.com"
note = "the shop we buy from sends order mail through this"
[[block]]
name = "ads.example.net"
note = "the smart television"

Save the file and ask again. A blocked answer lives two seconds, so the name works almost at once, and nothing on your network holds the old answer for long.

A published list of names to allow is a source with action = "allow":

[[source]]
id = "fixes"
url = "https://example.net/lists/allow-common-breakage.txt"
action = "allow"

Every rule of its body allows its name: a plain name, a hosts line, ||name^ and @@||name^ alike. A $badfilter line takes out the rule of its name inside the list. An allow source cancels every block of the groups that use it: the other lists, your own [[block]] entries and the group’s own block names. A group that does not use it keeps its blocks. The answers to the canary name and to the Private Relay names come first, and an allow source does not change them.

An allow source takes no exceptions, and a file that gives it the key is refused. Its min_rules counts its allow rules, and so do its row in GET /api/blocking/sources, its dns_blocklist_rules and tadoru blocklist status. A change of action reads the list again, and the set of the old action does not serve in the meantime.

If you arrive from another server with a file of names, read the file in. Typing it again is not a migration.

Terminal window
# A running server takes the import over its socket. Both directions are in cli.md.
tadoru blocklist import allow ./allowlist.txt

The command line has the rules an import follows, and what an export writes. With the server running, the API takes the same file.

A [[regex]] rule matches a name by its shape. It is for a family of names one advertiser adds to every week, which a list of exact names never catches up with.

[[regex]]
pattern = "^ad[sx]?[0-9]*\\."
note = "the advertiser that numbers its hosts"

Save the file and apply it, the same as any other change. blocking.toml: the lists this server blocks from has every key of a rule. These are the query types it applies to, the answer it carries, the groups it covers, and the limits that one revision holds them all to.

A pattern is tested last. Your own entries answer first, then the lists, then the patterns. So an allow entry of yours reaches no pattern at all, and a name a list blocked keeps the list’s answer. An allow pattern still cancels a block a list found. No block answers until the allow half is finished, and the allow patterns are the end of that half.

Ask before you write the rule down:

Terminal window
tadoru regex-test '^ad[sx]?[0-9]*\.' ads.example.com img.example.com

That reads no configuration file, so it answers about a pattern that is nowhere yet. Each name goes through the matcher a real query goes through.

Terminal window
tadoru regex-test --running www.example.com

That asks the rules of the revision the server adopted, one answer per group. Both forms are read-only and both work while the server answers queries. The command line has the options, the moment after an apply where the two differ, and what the second form leaves out.

An inverted rule fires for every name its pattern does not match. An inverted block rule therefore blocks the whole internet apart from what it matches. When you mean it, that is a walled garden for one machine. When you do not, it is a house with no working name.

Its own keys still bound it. It reaches the groups it names and the query types it names. An allow entry of yours still wins, and a bypass client never sees it.

Nothing refuses such a rule, because it is a real policy. So look at one first:

Terminal window
tadoru regex-test --invert '^school\.' school.example.com ads.example.com
Terminal window
# The server must be stopped for an import.
tadoru blocklist import regex ./regex.list

Every line that names a pattern becomes one rule, with its ;querytype=, ;reply= and ;invert modifiers. A blank line and a # comment are skipped. The server refuses the whole file rather than write a rule that means less than your old one did. These modifiers refuse, and each refusal names the line it read:

  • A negated query type, such as ;querytype=!A, because no rule here says “every type except this one”
  • ;querytype=OTHER, which is a blocker class of query rather than a query type
  • A query type this build does not name by word, and the message says what to write instead
  • Any ;reply= value beyond NXDOMAIN, NODATA and IP
  • ;reply=IP where blocking.toml names neither block_v4 nor block_v6
  • Any other modifier, and a second ;querytype= or ;reply= on one line

A pattern is refused the same way. Every rule goes through the same check blocking.toml goes through. So a blocker pattern this engine cannot compile names its own line, rather than failing the file later. A file holding no rule at all is refused too, and that message names the file.

A rule the file already holds is counted instead of added. So a second run of the same list changes nothing.

Importing your own entries through the API

Section titled “Importing your own entries through the API”

POST /api/blocking/import does what tadoru blocklist import does, and the command sends to it while the server runs. The query into names where the file goes: allow or block for a file of names, and regex for a file of patterns. $TOKEN is a token of operator or admin. On the machine, the socket takes the request with no token from root and from the user that the server runs as.

Terminal window
curl -s -X POST -H "Authorization: Bearer $TOKEN" -H "Idempotency-Key: $(uuidgen)" \
--data-binary @allowlist.txt "$API/api/blocking/import?into=allow"
  • The file is read as the command reads it, by the rules above. One line that the import cannot take refuses the whole file. The answer is 422 invalid-import, and line names the line. A ;reply=IP rule where blocking.toml names no address gets the same answer, with its line and file blocking.toml.
  • The file can be 4 MiB, the bound of blocking.toml. One byte more gets 413. One list holds 10,000 names at most, and blocking.toml holds 200 patterns at most. Past either bound, the answer is 422 too-many-entries. A file of more than 200 different patterns is refused at the 201st, as invalid-import with its line. The server reads a file of more than 10,000 different names up to the name past the bound, and refuses it there as too-many-entries.
  • The answer 200 gives revision, command, added and already. For patterns with ;reply=IP, address names the address that they answer with.
  • The import reads blocking.toml of the revision that runs, and not the file in the config root. A change that lands before the import is written gets 409, and nothing is imported. Send If-Match with the ETag of a read. The import is then refused where the file changed since.
  • A file that adds nothing, sent with no key, changes nothing. The answer says unchanged: true with the revision that runs. With a key, it makes a revision with the same blocking.toml, so the same key again gets that answer.
  • The same Idempotency-Key, the same file and the same into get the first answer again, with repeat: true and no counts, also after a restart. Another file under the key is another import. So is another into.
  • With a key, these refusals are kept, so the same key again answers 409 already-refused: a line or a bound of the file (422), blocking.toml that cannot take it (422), and an If-Match that names another revision (409). A revision that moved between the read and the write is not kept: the same request again reads the new revision and can land. A refusal before the import reads the file, such as 400, 401, 403 or 413, is not kept either.

GET /api/blocking/export?list=block gives your own entries of one list, as tadoru blocklist export block writes them. It writes one name a line, sorted, with each note as # lines above its name. Only those entries: no name of a source, no pattern, and nothing of the other list. It reads the revision that runs, not the config root, and its ETag names that revision. Any role can read it. The socket takes no word of the kernel for it: on the machine, tadoru blocklist export reads the config root.

Terminal window
curl -s -H "Authorization: Bearer $TOKEN" "$API/api/blocking/export?list=block" > block.txt

The server tests the names inside an answer as well as the name that was asked for. A site can publish metrics.example.com as an alias for tracker.adtech.test. The name a browser asks for belongs to the site, and the answer belongs to the tracker. No list can hold the first name, because the site invents it and every site invents a different one. This trick is called CNAME cloaking.

So a query gets two tests. The first is on the name in the question, and it is the one the rest of this page is about. The second runs after an answer arrives, on the names the answer’s alias chain reaches. Where the second test finds a rule, the client gets the blocked answer of that group, the same answer a blocked question gets.

The walk starts at the name in the question and follows CNAME owners. At each hop it looks for a CNAME whose owner is the name it stands on. So the order of the records in the answer changes nothing. It stops at 16 hops. An answer whose chain is longer than that is refused with SERVFAIL rather than sent. A longer chain hides a name this server did not test.

A query whose type is CNAME is the one query with no second test. It asks for the alias record itself, so the answer stops there and the chain behind it is the client’s business.

Three answers are refused for every client, whatever its group, and whether or not anything blocks:

  • An answer with two different aliases of one name has no single chain, because the client picks whichever record comes first.
  • An answer with more hops than the walk covers holds a name that no rule was read against.
  • A name that holds an alias and other data as well says two things, which the DNS forbids.

This server asks another upstream or name server for each of them. It answers SERVFAIL with Extended DNS Error 0 where none gives a clean answer (A name that answers SERVFAIL because of its aliases). An answer rewritten by a DNAME record is read the way a client follows it. The name that the DNAME leads to is tested like any name of the chain, with an alias beside the DNAME or without one. A failed answer is not blocked either, because the names it carries resolved for nobody.

The first blocked name in chain order is the one that matched. An allow entry exempts the name it is about and nothing else. So an allowed name in the middle of a chain does not clear a block further along it. And allowing the name the browser asked for does not allow the tracker behind it. To allow a chain that a rule stopped, allow the name the query log names.

The query log row of such a block carries two columns. block_name holds the name in the chain that matched, which is not the name in the question. chain holds the whole walk as a list of names in JSON, the question’s name first. A row for a name the first test blocked leaves both empty, because there was no chain to walk. Both follow store_names: with it off, the row says which list and rule matched and names nobody. A chain too long for the column is left out whole, and block_name still says what matched.

# The two columns of a cloaked block, as the query log holds them.
block_name tracker.adtech.test
chain ["metrics.example.com","tracker.adtech.test"]

Three things stay invisible to this test:

  • An address record for a name no hop of the chain reaches. The walk tests the chain, not every name an answer mentions.
  • A tracker the site serves from its own address. With no alias in the answer, there is nothing to walk.
  • A device that asks another resolver. This test runs on the answers this server gives.

cname_blocking = false in blocking.toml turns the second test off for every group that writes no answer of its own. A group in clients.toml can write its own cname_blocking and keep the rest of its rules, either way round: false in one group with the test on everywhere else, or true in one group with it off everywhere else. That is the answer for one group that has to tolerate one vendor’s aliases. Where the test is off, only the name in the question is tested for that group. blocking.toml: the lists this server blocks from has both settings.

Every pass writes one line per source:

INFO read a blocklist source source="hagezi-pro" lines=224585 rules=224572 duplicates=0 ignored=13 unsupported=0 invalid=0
Count Is
lines Lines in the body, which is what wc -l says
rules Names it now blocks or allows, after the repeats are dropped
duplicates Lines whose name was already there
ignored Comments, blank lines, and real hosts mappings
unsupported Lines in a syntax this build does not read
invalid Lines that look like a rule and hold no usable name

Compare rules with the count the publisher declares in their own header. The two agree for a list this server reads whole. A publisher declaring 224,572 entries beside a rules of 223,000 is a list this server reads only part of. That is worth a report.

invalid of a few lines in a big list is normal: a publisher sometimes ships a line with a space in it. invalid in the thousands is not a list at all.

Six gates decide whether a new body is worth serving, and a body that fails one keeps what the source had. The log line names the numbers, so you can see which gate and by how much:

The gate Refuses a body that The setting
Size Holds more than 64 mebibytes of text max_source_bytes
Not a list Has more than one rule line in five that is not a name max_invalid_percent
Floor Compiles to fewer than 100 block rules. A file of your own needs 1 min_rules
Declared count Arrives with more than 5 percent fewer rule lines than its header declares max_count_drift_percent
Continuity Keeps fewer than half the rules the source had before min_share_percent
Compiled size Compiles to more than 256 mebibytes max_compiled_bytes

Each of those six is a setting in blocking.toml and a key on one source, and a source’s own number wins. So a publisher who lists forty names gets min_rules = 40 on their own source and everybody else keeps the hundred. blocking.toml: the lists this server blocks from has the defaults and the ranges.

A rule line is any line the reader was meant to make a rule of. A comment and a blank line count towards neither side of that share. A hosts line naming three names is three rule lines.

An error page from a publisher’s web server fails the second gate, and usually the third as well. A download a proxy cut short fails the fourth, which is the one the others let through. A publisher who cleaned their list fails the fifth, and min_share_percent = 0 on that source is how you let them.

The publisher’s own header adds three facts. The count is the gate above. The title and the version go in the record, so a question about one bad rule starts with which version of which list. And the expiry is what a publisher says about how often their file changes.

Two sources holding the same body is a warning rather than a refusal. It is one list under two names, which counts its names twice in every report.

Ask the server whether every list is blocking:

Terminal window
curl -s --unix-socket ./data/run/api.sock http://localhost/api/health | jq .blocking
{
"ok": false,
"sources": 2,
"serving": 1,
"empty": [
{
"id": "hagezi-pro",
"state": "refused",
"problem": "it holds 3 block rules, and the fewest this source is allowed is 100"
}
]
}

ok is false while any source is serving no rules, and empty names each one with what its last pass said. This part of the answer needs no credentials, the same as the rest of that page, so a monitoring system can read it.

A list whose last pass reached no body also has unreached, the kind of that failure. It is one of the 11 words that last_attempt.unreached gives in GET /api/blocking/sources: inside, redirected_inside, forbidden, unresolved, unconnected, proxy, status, redirects, answer, file or defect. Every role reads it. The field is absent where the list has no failed attempt with a kind. The problem text keeps its rule: an admin and a caller on the socket read the full text, and every other role reads the words of the kind.

A source whose compiled list is on disk is serving from the first query after a start, so it is not in empty while the first pass runs. A source with nothing on disk yet is, and so is one whose subtree or exceptions you just changed, because the list it serves is compiled from those and has to be compiled again. In that last case state is absent: the pass this server remembers was about the settings before your change.

At a start, a source with a path serves its compiled list only where the list came from the file of the running revision. The server keeps a copy of each list on disk. Where that copy is there, the server compares it with the record of the revision, and reads no file. Otherwise it reads the file of the revision. Four cases put such a source in empty after a start:

  • The server stopped after a revision changed the file, and before a pass read it.
  • A rollback took an older file back.
  • An older build of the server read a hand edit of the file, and no revision took that edit.
  • An upload with accept landed a smaller list, and its pass did not publish it before the stop. Then the first pass refuses the list against the copy on disk, and the source serves nothing until POST /api/blocking/sources/{id}/accept takes it.

The first pass reads the file again at once, with no request to the network.

With the server stopped, tadoru blocklist status says what the running revision serves, by the same rule. It says empty for such a source, and shows no rules. It does not judge an edit that you made while the server was stopped. A start takes such an edit as a revision first, or refuses it, and only the start can tell which. So the status compares blocking.toml and the file of each source with the running revision. Where one differs, it prints a line that the hand edit is waiting and that the next start judges it. The rows stay what the running revision serves. A file that you deleted by hand counts as an edit too. So does a link in place of the file or of its directory.

Before the first start there is no revision yet. A line says that the config root waits for the first start, and a source with a path shows empty.

One list at a time, with what each one is doing:

Terminal window
curl -s --unix-socket ./data/run/api.sock \
http://localhost/api/blocking/sources | jq '.[] | {id, state}'

Each row has these fields:

  • serving is the set answering queries now. It holds its rules, what it costs to hold, when the body it came from arrived, and the six counts of that body.
  • last_attempt is what the last pass did. It holds what the pass ended as, when, when the source itself last answered, the numbers a gate refused it with, and the checksum of the refused body.
  • interval_minutes is how often the list is read.
  • next_at is when the server reads the list next on its own schedule, in seconds since 1970. It holds the jitter, and it is half a minute away after a host that did not answer.
  • state is ok while the list is serving, refused where a gate refused the body it read, and empty for every other way of serving nothing.
  • uploaded is true where the source reads blocklists/<id>.txt, the place of an upload of that id, whether an upload or a hand edit wrote it.

next_at is absent until the schedule first reads the list after a start. It is absent while the list is due now. It is absent as soon as you change the address of the list, its file, its compile settings or the limits of its gate, because the old time was for the list as it was. A change of refresh_hours or min_refresh_minutes leaves it as it was, and the new interval counts from the read after it. A refresh that you ask for leaves it as it was too. It is an estimate, worked out from the clock of the machine when you ask. So it follows the clock if the clock jumps, and it is never in the past while the read is still ahead. API Reference has every field.

The file itself, as the server runs it:

Terminal window
curl -s --unix-socket ./data/run/api.sock http://localhost/api/blocking | jq '{mode, source}'
curl -s --unix-socket ./data/run/api.sock -H 'accept: text/plain' http://localhost/api/blocking

The first answer is every setting of blocking.toml and every [[source]], [[block]], [[allow]] and [[regex]], with the notes. A setting that the file leaves out reads as the value that runs. It is null where no one value applies, such as a limit that each source takes from its own kind. The second answer is the file’s own text, with its comments, and it is empty on a server that has no blocking.toml. Both carry an ETag, the revision they come from. The JSON is what the server runs, so it answers even where the copy of the file on disk is damaged. The text then answers 500 and says to roll back or restore.

The body’s age and the last answer from the source are two numbers on purpose. A publisher who says “your copy is current” for a month is answering every hour, and their file is a month old.

On the machine this needs no token: the server takes the operating system’s word for who connected on its own socket, the same as tadoru config apply. From anywhere else it needs a reader’s credentials, because the answer holds the addresses of your lists and the reasons a fetch failed.

To change the file on a running server, send the settings that change as JSON:

Terminal window
curl -s --unix-socket ./data/run/api.sock -X PATCH \
-H 'content-type: application/json' -H "if-match: $TAG" \
-d '{"mode": "nxdomain", "block": [{"name": "ads.example.com", "note": "the banner"}]}' \
http://localhost/api/blocking

$TAG is the ETag of your read. If the configuration changed since that read, in this file or in any other, the answer is 409, and nothing is written. A setting you leave out stays as it is, and a setting sent as null goes back to its default.

A list, source, block, allow or regex, goes whole. It replaces every block of that list in the file, in place. The comment lines above each block stay at their place in the list, and do not follow their entry. The comment above the first block stays above the first block, whatever entry is first now. So a comment moves to another entry when you take an entry out or change the order. The comment lines inside a block are lost. An empty list or null takes every block out. So to add one name, read the list, add the name, and send the whole list back. A list that is the same as the one that runs changes nothing.

A server that has no blocking.toml gets one with the first change that writes into it. A change that leaves it empty, such as {"block": []}, adds no file and spends no revision. Each change is one revision, with every check of a change of the file, and GET /api/revisions shows who made it.

Send only the settings that change. If you send a whole read back, each setting in it is written into the file, so a later change of a default does not reach that setting any more. The lists are the exception: a list that did not change keeps its text.

To replace the whole file, send its text with PUT:

Terminal window
curl -s --unix-socket ./data/run/api.sock -H 'accept: text/plain' -D headers.txt \
http://localhost/api/blocking > blocking.toml
TAG=$(grep -i '^etag:' headers.txt | cut -d' ' -f2 | tr -d '\r')
KEY=$(uuidgen)
# Edit blocking.toml, then send it back with the ETag of that read.
curl -s --unix-socket ./data/run/api.sock -X PUT -H "if-match: $TAG" \
-H "idempotency-key: $KEY" --data-binary @blocking.toml http://localhost/api/blocking

The server keeps the text as you sent it, byte for byte, with its comments and its line ends. Any content type is taken, so --data-binary alone does. The body can be up to 4 MiB, the bound of one configuration file, on PUT and on PATCH. A larger one is refused with 413 before it is read. A server that has no blocking.toml gets one. An empty body writes an empty file: every setting goes back to its default, and every list is empty.

The text is checked as a whole before anything changes. The server refuses with 422 a file that does not read as TOML, a key that the file does not take, and a value that it cannot use. The answer names the line or the setting, and the file stays as it was.

$TAG is the ETag of the read. If any file of the configuration changed since that read, the answer is 409 and nothing is written. Read the file again, make your edit on it, and send it with the new tag. Where the answer did not arrive, or was a 503 still-writing, the change may have landed. Send the same request with the same $KEY. It answers with the outcome of the first, and does not apply it twice. A request with a new key or with none is a new change. Without a key, the same text sent again against the same revision is the same change. So a refused text sent again answers 409 already-refused until something changes.

To find out whether the server takes a change, without making it, send it to the check:

Terminal window
curl -s --unix-socket ./data/run/api.sock -X POST -H 'content-type: text/plain' \
-H "if-match: $TAG" --data-binary @blocking.toml http://localhost/api/blocking/check

The check reads the body by its content type. A JSON object is checked as PATCH applies it. Text sent as text/plain is checked as PUT applies the same text. Any other content type is refused with 415, so name the type: PUT takes text in any type, and the check does not. The body can be up to 4 MiB.

The answer is the answer of the save, and nothing is written. A 200 says that the change passes every check of its save, with "unchanged": true where the save makes no new revision. A refusal is the refusal of the save, with the same setting and line. A rule of regex is named by its place in the list, such as regex[1].pattern. An entry of source, block or allow is named by its list alone, and the detail says which entry. For a JSON change, line is a line of the file that the change makes, not a line of your body. A key that the file does not take is named only by that line.

If-Match and Idempotency-Key are read as the save reads them. The check keeps no record, so the key stays free for the save. The check does not fetch a source, so a URL that does not answer passes here. A change that lands between the check and the save is not covered. Send the save with the same $TAG, and it answers 409 then.

A check waits for the same lock as a save. At most four checks wait at once. Past that, a check answers 503 too-many-changes at once, so a save keeps at least four places. Send the check again in a moment.

A viewer can read the file, and only an operator or an admin can change or check it. On the machine, the server’s own user and root do both with no token.

The server carries a short table of published lists, so you do not have to look up an address. It is built into the server and changes with a release. Asking for it fetches nothing. $API is the address of the API and $TOKEN is a token of any role (see Accounts):

Terminal window
curl -s -H "Authorization: Bearer $TOKEN" \
"$API/api/blocking/catalog" | jq '.[] | {id, title, topic, source}'

Each entry gives the id that the console proposes for the source, the title and the publisher, the url of the list and the homepage of the project, and its license. It also gives a one-word topic (ads, privacy, security, adult, gambling, social or fixes), and the action, format and subtree that the source takes. names is an estimate of how many names the list held on the day as_of. It is not the size of the list today.

An entry that the running revision already reads has a source. It is the id of the first source with the same address, which may not be the id that the entry proposes. An entry that no source reads has no source. The match of the address ignores the case of the scheme and the host, and takes the rest byte for byte. Any role can read the catalog. The route is on the socket too, but the word of the socket does not count here: a token or a session is needed.

A list that is on no web server goes to the server as a file. The upload writes it into the config root as blocklists/<id>.txt and adds a [[source]] that reads it, in one revision. So a backup, a rollback and a cluster carry the list with its source. $TOKEN is a token of operator or admin. The route takes no word of the socket:

Terminal window
# The ETag of a read of the configuration names the revision that the upload is written against.
TAG=$(curl -s -D - -o /dev/null -H "Authorization: Bearer $TOKEN" "$API/api/blocking" \
| awk 'tolower($1) == "etag:" {print $2}' | tr -d '\r')
curl -s -X PUT -H "Authorization: Bearer $TOKEN" -H "If-Match: $TAG" \
-H "Idempotency-Key: $(uuidgen)" --data-binary @ours.txt \
"$API/api/blocking/sources/ours/list"
  • The body is the text of the list, up to 16 MiB, in UTF-8. The server reads its lines as the lines of any list (The lines this server reads).
  • ?action=allow makes the source allow its names (A list of names to allow). With no action, a new source blocks its names, and a source that exists keeps its action.
  • A new id adds the source at the end of the source array. An id that reads blocklists/<id>.txt gets the new version of its file. A source that reads a URL or another path is refused (source-not-uploaded), and so is an upload of a file that another source reads (list-shared).
  • An upload that adds a source or changes its action writes each [[source]] block of blocking.toml again, as a PATCH of source does. The comment lines above each block stay, and the comment lines inside a block go. A new version of a list leaves blocking.toml as it is.
  • The list is checked as a pass reads it, before the revision. A list that a gate refuses gets 422 list-unusable, with the gate and its numbers, and no revision is made.
  • A list that holds less than the source asks for (min_share_percent) gets 409 list-shrinks, with its numbers and its checksum, and no revision is made. The upload compares it with the list that serves, or, where nothing serves, with the copy of the last list on disk.
  • To take such a list, send the same request with ?accept=<checksum>. An accept of another checksum gets 422 accept-mismatch, and every other gate still applies. The file lands as a revision, and the same request runs the pass that takes the list, held to that revision. The answer says accepted: true where that pass published the list. It says accepted: false where the pass did not, such as where another revision landed first. Where the pass still runs at the end of the request, the answer is 202 with pass_running: true. The pass ends after the answer, and GET /api/blocking/sources says whether it published.
  • Where another pass holds the lists until the request runs out of time, or where nothing keeps the lists current, no pass starts for the accept, and the answer says accepted: false. Then the pass that the revision wakes refuses the list as smaller once more, and the row has its checksum in last_attempt.refused. A list that served before keeps serving until then, and after a restart the source serves nothing. Take it with POST /api/blocking/sources/{id}/accept and that checksum, as below.

The answer 200 gives revision, command, source, created, and counts, what the reader made of the list. A 200 confirms the revision, not that the list serves. The pass that the revision wakes reads the list a second or two later. GET /api/blocking/sources says what that pass did, and the names block or allow where it took the list. With accept, the answer says what the pass that takes the list did, as the list above says.

The same Idempotency-Key again gets the first answer, whatever ran since. The answer holds revision, command and source of the first try, with repeat: true. A refusal with a key is kept as its words, so the same key again answers 409 already-refused. Send it again with a new key, or with none, to read its numbers again. The same text and the same source as they run, sent with no key, change nothing, and the answer says unchanged: true with the revision that runs.

The list file of a source with a path reads back as the running revision holds it, byte for byte. Any role can read it:

Terminal window
curl -s -D headers.txt -H "Authorization: Bearer $TOKEN" -o ours.txt \
"$API/api/blocking/sources/ours/list"
  • A file that is UTF-8 comes as text/plain; charset=utf-8, and any other file as application/octet-stream. Nothing in it is changed, so a file written by hand reads as it is.
  • The ETag of the answer names the revision, so a delete can send it as If-Match.
  • A source that reads a URL has no list file, and gets 409 no-list-file. An id that no source has, and a path that the revision does not hold, get 404 not-found, with the reason.
  • A read of a file larger than 1 MiB takes the one place of the large bodies until its bytes are sent, as an upload does, and one of them during another answers 503 busy. A smaller file reads at any time.
  • The answer has 120 seconds to arrive, from the moment the server has read the file. A file of 16 MiB needs a link of about 140 KiB a second. A slower download ends with an error rather than with part of the file. Read it again over a faster link, or, on the machine, read blocklists/<id>.txt in the config root.

To remove an uploaded list, delete it. One revision removes blocklists/<id>.txt and the [[source]] that reads it. $TOKEN is a token of operator or admin:

Terminal window
curl -s -X DELETE -H "Authorization: Bearer $TOKEN" -H "If-Match: $TAG" \
-H "Idempotency-Key: $(uuidgen)" "$API/api/blocking/sources/ours/list"
  • The source must read blocklists/<id>.txt. A source that reads a URL or another path gets 409 source-not-uploaded: remove it with PATCH /api/blocking. A file that another source reads too gets 409 list-shared, which names that source.
  • A group of clients.toml that names the source in sources refuses the delete with 422, and the setting names the group. Take the source out of the group first.
  • A PATCH that removes a source leaves its list file in the configuration. The file blocks nothing, and GET /api/blocking/sources no longer names it. A delete of the id removes that file alone. A source whose file the revision does not hold goes alone too.
  • The answer 200 gives revision and command. The names of the list stop blocking or allowing with that revision. The same Idempotency-Key again gets the first answer, and deletes nothing more, even after a new upload of the same id.
  • A rollback to the revision before the delete brings the file and the source back together, and the first pass compiles the list again with no request to the network.

Reading a list now, and taking one this server refused

Section titled “Reading a list now, and taking one this server refused”

Two things you can ask for. Read a list at once, whatever its interval says:

Terminal window
curl -s -X POST --unix-socket ./data/run/api.sock \
http://localhost/api/blocking/sources/hagezi-pro/refresh

The answer is that source’s row afterwards, so you see what the pass did. One pass runs at a time. A refresh asked for while the server is reading its sources is refused with pass-running, because the pass that is running is already doing what you asked. A refresh does not move the list’s own schedule.

And take a body the continuity gate refused, once you have looked at the numbers and decided that the publisher meant to remove those names:

Terminal window
curl -s -X POST --unix-socket ./data/run/api.sock \
-H 'content-type: application/json' \
-d '{"checksum": "8f14e45fceea167a5a36dedd4bea2543474d7b1a5bfe6d3f6b2f1a3d7ba7f9c1"}' \
http://localhost/api/blocking/sources/hagezi-pro/accept

The checksum is the one the record shows for the refused body, which GET /api/blocking/sources gives as last_attempt.refused. The request must name it. It names one body rather than “whatever arrives next”, so an accept cannot become a habit that turns the gate off.

An accept passes four gates of the content: the continuity gate, the floor of rules, the share of lines that are not names, and the drift from the count that the header declares. Two bounds of bytes stay. They are the size of the body and the size of its compiled set, which are what this machine can hold and read back. A body past either is refused again. blocking.toml: the lists this server blocks from lists the settings that change them.

What you accept is one body, not an address. The body that arrives has to hash to the checksum you named. A publisher who changed their file in between gets the ordinary gates. If the server refused a different body while you were reading, the answer says which one it is holding now, so you can look again.

Both of these change what the server serves, so they need an operator’s credentials. On the machine itself the server takes the operating system’s word for who connected on its own socket, for the account it runs as and for root. Every other local user needs credentials like anybody else.

You can also read every list at once, one after the other:

Terminal window
curl -s -X POST --unix-socket ./data/run/api.sock -H "authorization: Bearer $TOK" \
http://localhost/api/blocking/refresh

This needs the token or the session of an operator or an admin, and a session also sends x-csrf-token. Here the server does not take the operating system’s word for who connected, so the call sends a token on the socket too. No command of the command line uses this route.

The answer has one entry for each list, in the order of blocking.toml. outcome is ran, superseded or removed:

  • ran: the list was read, and attempt is what this read recorded. A list that could not be read is ran too, and attempt says why.
  • superseded: the address or the settings of the list changed while it was read, so nothing was kept for it.
  • removed: the configuration no longer names the list.

report is the row of the list as it is when the answer is made. A read on the server’s own schedule that ran after this one can already show in it.

The server reads one list at a time for the whole run. While it runs, a refresh of one list is refused with pass-running, and the server’s own schedule waits. A second refresh of every list straight after the first can be refused too, because the scheduled read goes first. The scheduled read takes a list that the configuration adds or changes during the run straight after the run. The run moves no list’s schedule.

After 20 seconds the answer is 202, and the run carries on. Read GET /api/blocking/sources to see what it did. A 500 with pass-failed is a fault inside the server, a panic. It is not a list that could not be read, because that list is ran and attempt says why. The lists before the fault keep what they read, and the rest were not read in this run. The log says what happened. If the next request answers blocking-not-running, nothing reads the lists any more, so restart the server.

Five metrics carry the same thing over time, at the endpoint that Metrics names:

Metric Is
dns_blocklist_rules Rules of its action the source is serving, by source and action
dns_blocklist_bytes What its compiled list costs to hold, by source
dns_blocklist_check_age_seconds How long since a pass over it worked, by source
dns_blocklist_passes_total Passes over it, by source and by what the pass ended as
dns_blocked_total Blocked answers, by group and by the source that held the rule

Alert on dns_blocklist_check_age_seconds. A source that cannot be reached keeps serving what it had. That is right for an afternoon and wrong for a month, and this number says which. A source that has never worked publishes no value at all rather than zero, because zero reads as “checked just now”. A publisher that answers “your copy is current” counts as a check that worked, so this number stays low for a list whose body is old on purpose.

A source you take out of the file stops being measured, and the last value it published stays at the endpoint until the server restarts. So the health line above, not a dashboard, is what says which sources this server has.

dns_blocked_total carries source="(entries)" for one of your own names and source="(regex)" for one of your pattern rules, since neither belongs to a list. group is the group whose policy blocked the answer. With store_clients off the group label reads (hidden), because a group of one machine is that machine. The brackets keep all three apart from a list you call entries and a group you call hidden.

dns_blocklist_ is the four numbers per source, and dns_blocked_total is the one about answers.

mode in blocking.toml picks the shape of it. zero is the default:

Question Answer
A 0.0.0.0
AAAA ::
ANY Both of those
Anything else NOERROR with no records

Three other modes answer differently:

mode A, AAAA, ANY Anything else
nodata NOERROR with no records NOERROR, no records
nxdomain NXDOMAIN NXDOMAIN
address block_v4, block_v6, or both NOERROR, no records

A zone transfer request, of type AXFR or IXFR, is decided before the blocking test runs. It gets the zone where its rules allow the client, and a refusal where they do not (Zone transfers). The mode does not reach it, and the query log row for it names no rule.

zero is the shape that keeps a device talking to this server. A browser with its own resolver reads nxdomain as a broken one and looks for another. nodata is what a blocker rule asked for. address sends your own address. Set block_v4 or block_v6 on their own to answer only that family. The other family gets an empty answer instead of a guess.

The address records live answer_ttl_seconds, two seconds by default, and so does the TXT report below. A resolver between you and this server can hold one for that long, and no longer. An empty answer and a refusal carry no SOA record, so this server gives a resolver no lifetime to hold either one for. This server itself caches none of the five. A blocked name never reaches an upstream resolver. So the first query for it tells nobody outside your network what a device in your house asked for.

A group of clients.toml gives a client its own blocked answer: mode, block_v4 and block_v6 of the group win over these. Groups says how.

A TXT question about a blocked name answers the list and the rule. It is the fastest way to ask why from a device that cannot read the query log:

Terminal window
dig @127.0.0.1 -p 5300 ads.example.com TXT +short
"blocked by tadoru: list hagezi-pro, rule *.ads.example.com"

block_report turns this off. A TXT question then gets whatever mode says for a type it has no answer of its own for. That is an empty answer under zero, nodata and address, and NXDOMAIN under nxdomain.

The string names the list and the rule, and nothing else. Whoever asks gets this answer, so it never names a group or a client. An entry of your own names (entries) in place of a list, because that rule belongs to no list. A [[regex]] rule names (regex) there, and the rule is the pattern as you wrote it. A rule too long for one 255 octet string is cut, and the string ends .... The list is the id you gave the source. A source you named after a person or a room says that back to whoever asks it.

The report answers ahead of nxdomain, so it still explains a name that mode denies. A resolver that ignores the missing SOA and caches the earlier A or AAAA answer anyway can still hide it behind that wrong cache.

A blocked answer also carries an Extended DNS Error, which is a numbered code in the OPT record of the response. You read it with an ordinary question, of any type:

Terminal window
dig @127.0.0.1 -p 5300 ads.example.com A
; EDE: 4 (Forged Answer): (blocked by tadoru: list hagezi-pro, rule *.ads.example.com)

Code 4 (Forged Answer) goes on an answer that holds a record this server made up. That is zero and address for a type they answer, and the TXT report. Code 15 (Blocked) goes on an answer with no made-up record. That is nodata, nxdomain, a type the mode has no record for, and the canary and Private Relay answers. An alias from a zone of your own can stand in front of a code 15 answer. The alias is your data, and the block made nothing up.

The text of the code follows block_report. With the setting on, a block by a rule carries the sentence of the TXT report. The canary answer carries blocked by tadoru: canary, and the Private Relay answer carries blocked by tadoru: private-relay. With the setting off, the code goes out with no text, and says that a block happened and nothing more. A query with no OPT record gets no code, because the code has nowhere to go.

The API answers for a name that nobody asked yet, and for any client. It tests the name with the rules that a query from that client meets, and it says which rule decides:

Terminal window
curl -s --unix-socket ./data/run/api.sock -H "authorization: Bearer $TOK" \
'http://localhost/api/blocking/search?name=ads.example.com&client=192.168.1.20'
{
"name": "ads.example.com.", "qtype": 1, "client": "kids", "group": "strict",
"bypass": "not-listed", "policy": "applied", "decision": "blocked",
"by": {"action": "block", "origin": "source", "list": "b", "rule": "*.example.com"},
"matches": [
{"action": "allow", "origin": "source", "list": "a", "rule": "ads.example.com", "effect": "cancels"},
{"action": "block", "origin": "source", "list": "a", "rule": "*.example.com", "effect": "cancelled"},
{"action": "block", "origin": "source", "list": "b", "rule": "*.example.com", "effect": "decides"}
]
}

client is an address, and picks the client as a query from it does. client_name=kids names a client of the running configuration instead, or default. The search reads what the server runs, so a change to clients.toml counts once it is applied. qtype is the type of the question, A by default, and only a [[regex]] rule with qtype reads it.

  • decision is what the rules answer: blocked, allowed or unlisted. by is the rule that decided, and it is absent for unlisted.
  • policy is what a query gets now, in the words of the query log. Where policy says that the rules do not run, decision is still the answer of the rules. So you can see what blocks a name before you turn blocking on again.
  • bypass is listed or not-listed for an address, and not-tested for a name, which has no address.
  • matches lists the rules that cover the name, in the order of the test. effect says what each one did. decides is by, cancelled is a block that an allow of its own list cancels, cancels is that allow, and unused changed nothing. Above, list a allows and blocks the name, so its two rules cancel out and list b decides.
  • rule is the rule as this server compiled it, name or *.name, for a list and for an entry of your own. It is never the line as the list wrote it. For a [[regex]] rule it is the pattern. The canary and Private Relay answers have no rule and no list.

The search tests the name you sent. It does not resolve it, so the answer leaves out a block that the target of an alias causes. The query log row of such a query names that block in block_name. The search skips what the server does before the rules. Examples are a name under resolver.arpa, the recursion access list and the decision of a zone transfer. It reads no arrived_on selector, because that needs the address a query came to. A list that the group of the client does not use is not in matches.

A viewer can search. The server does not take the operating system’s word on the socket here, so the call sends a token. One search runs at a time, and a second one answers 429 with Retry-After: 1. Troubleshooting lists the refusals.

bypass = ["192.168.1.10", "192.168.10.0/24"]

An address or a subnet in bypass is answered as though no rule matched it, for every name. It is meant for one machine that has to keep working while you tune the rest: a television or a game console you cannot afford to break.

A subnet covers every address inside it. 192.168.10.0/24 covers 192.168.10.0 through 192.168.10.255, both ends included. Either family works, so 2001:db8:20::/64 is as good a line as the IPv4 one above. The address has to be that range’s own: 192.168.10.5/24 is refused, because 192.168.10.5 is one address inside 192.168.10.0/24 and not the range itself.

A wide prefix bypasses many clients rather than one. 0.0.0.0/0 bypasses every IPv4 client this server hears from, and ::/0 every IPv6 one. The pair stops blocking for everybody. The durable way to do that is enabled = false in blocking.toml, which names it as one setting (blocking.toml: the lists this server blocks from). Two narrower ways exist: blocking = false on a group, and the timed disable over the API.

bypass holds 64 entries at most. An IPv4 range written as an IPv6 one is refused as well, such as ::ffff:192.168.10.0/120. A client of that network arrives as an IPv4 address, and the line matches no IPv4 client. ::/96 and each range inside it, such as ::/120, are refused for the same reason. A range that holds nothing but :: and ::1, such as ::/127, is read. allow_recursion and the client selectors refuse both.

A bypassed client’s query is still logged. Its row carries no list and no rule, the same as a name nobody blocked.

A browser or a phone can carry an encrypted resolver of its own and ask that one instead. Then this server sees none of its queries, and every rule above counts for nothing. Two settings answer the two cases this server can answer:

canary = true
private_relay = "allow"

canary = true is the default. Firefox asks for use-application-dns.net before it turns on DNS over HTTPS. NXDOMAIN for that name is the agreed answer for “this network filters DNS”, and Firefox then keeps the resolver the network gave it. Turn it off on a server that filters nothing, because the answer is then a claim about this network that is not true.

private_relay = "block" refuses mask.icloud.com and mask-h2.icloud.com. An Apple device resolves those two names to start Private Relay. If they fail, the device sends its queries here. The default is "allow", because people pay for Private Relay and a homelab that turns it off without being asked is a surprise.

Both answers are NXDOMAIN, for every query type, and neither carries a SOA record. So no resolver in between holds the refusal after you turn the setting off. Neither name is a list entry, so an allow entry for it changes nothing.

Anything that stops filtering stops these two answers as well. enabled = false in blocking.toml turns them off for every client, and tadoru blocking disable turns them off for as long as it lasts. A bypass address never gets them. A group with blocking = false gets them for none of its machines. A server that filters nothing must not tell Firefox that it does.

canary = false and private_relay = "allow" mean “treat these names like any other name” rather than “let them resolve”. A list that holds mask.icloud.com still blocks it, under that list’s own name in the log. Each setting is also a group key. So one group of machines can keep Firefox or Private Relay working while the rest of the house does not.

A blocked row for either one reads canary or private-relay in block_origin, with no list and no rule. Nothing holds the name, so there is nothing to name. Those two words stay in the row with store_names off, and each one names its name. A canary row is a query for use-application-dns.net. Every Firefox asks that name on every network it joins, so the row says which device features are on rather than what somebody read.

This server leaves three related things alone. _esni was part of an older way to hide which site a connection asks for, and nothing asks for it now. The names under resolver.arpa are how a client finds the encrypted addresses of the resolver it already uses, which is this server. This server answers those names itself, and no list or rule blocks them. A rule that blocks the name of tls_server_name does change one answer. The encrypted listeners are not named to a client whose group blocks that name (Encrypted DNS says why). Refusing either breaks clients that use this server correctly. Chrome upgrades only to a resolver on its own list, and a home address is never on it, so there is nothing to stop.

None of this is a firewall rule. A television with 8.8.8.8 compiled in never asks this server at all. On the router, block outbound port 53 and port 853 for every address except this server, and redirect port 53 to it. Block the published addresses of the DNS over HTTPS resolvers you care about as well. Those answer on port 443, so no port rule finds them. That is the work that makes the settings above the last case rather than the first.

Terminal window
# Off for ten minutes, then on again with no further command.
tadoru blocking disable 10m
# Off until you say otherwise.
tadoru blocking disable
# On again now.
tadoru blocking enable

The switch lives in the memory of a running server, not in a file. A restart always starts with the switch on, whatever the switch said before the restart.

To keep blocking off across a restart, write enabled = false in blocking.toml (blocking.toml: the lists this server blocks from has the key). That is a revision: every node of a cluster takes it, and the history keeps it. Blocking is in force only where the setting is true and the switch is on. So tadoru blocking enable while the setting is false turns the switch on and leaves blocking off, and its output says so. The lists stay current while either one is off. The command line has the third command, tadoru blocking status.

A timed disable is bounded to 24 hours, and a duration past that is refused with the bound in the message. An untimed disable has no bound. It is meant for a device you are debugging right now, and it is safe because it is loud: GET /api/health names it, tadoru blocking status names it, and the metric below reads 1 while it holds.

Every query that reaches the blocking test while the switch is off, or while the setting enabled is false, is logged the same as one nobody blocked. Its policy column reads disabled rather than applied. A device that keeps working while you tune the rest is a device whose queries you can still read back.

A query the server refuses before that test keeps applied. Three kinds are refused that early: a malformed question, an EDNS version this server does not answer, and a class other than IN. The reason is the protocol rather than a rule, so the switch does not change what they get.

Read and change it over the socket, the same as the routes above:

Terminal window
curl -s --unix-socket ./data/run/api.sock http://localhost/api/blocking/state
curl -s -X PUT --unix-socket ./data/run/api.sock \
-H 'content-type: application/json' \
-d '{"disabled": true, "seconds": 600}' \
http://localhost/api/blocking/state

The answer names three states. state is the switch, with remaining_seconds for a timed disable. enabled is the setting enabled of blocking.toml in the running revision. in_force is on where the switch is on and the setting is true, and off otherwise. A PUT changes the switch alone. GET /api/health gives the same object as blocking_disabled while blocking is not in force, and leaves the field out while it is.

Reading needs any role’s credentials, and changing it needs an operator’s, the same as a blocklist refresh. On the machine itself the server takes the operating system’s word for who connected, for the account it runs as and for root.

The body takes disabled and seconds and no other field. A misspelled field is refused with its name, because a body read leniently turns a ten-minute disable into one with no end. seconds outside 1 to 86400 is refused with the bound, and seconds together with disabled: false is refused as well. There is no length to turn blocking on for.

dns_blocking_disabled is 1 while the switch is off and 0 while it is on, at the endpoint that Metrics names. dns_blocking_setting_disabled is 1 while the setting enabled is false and 0 while it is true. Blocking is in force where both read 0.

The query log holds a row per query, and a blocked row names the list, the rule and the group. The query log says how to read them back and what a privacy setting takes out.

Terminal window
# The last hundred rows this server kept, newest first, and the blocked ones out of them.
curl -s --unix-socket ./data/run/api.sock -H "authorization: Bearer $TOK" \
"http://localhost/api/queries?limit=100" | jq '.rows[] | select(.source == "blocked")'

from and to narrow that to a span of time, in milliseconds since the epoch. API Reference has both.

A row’s block_rule is the rule as this server holds it, which is *.ads.example.com for a name that covers the names under it. A pattern rule puts the pattern there, as you wrote it. Its block_list is the source’s id. It is absent for an entry of your own and for a pattern, because neither rule belongs to a list. What names the kind of rule is block_origin, and it reads regex for a pattern. It reads canary or private-relay for the two names above, with no list and no rule beside it.