Inside Firefox’s DNS-over-HTTPS engine
Here is a brief demonstration of how &quot;DOH DNS servers&quot; can be useful.  Nevermind the idea of applications having their own DNS caches.<p>1. fetch page of html, e.g., hn front page<p><pre><code>   curl https:&#x2F;&#x2F;news.ycombinator.com &gt; 1.htm
</code></pre>
2. extract urls from 1.htm<p><pre><code>   yyt &lt; 1.htm &gt; 1.txt
</code></pre>
(example scanner &quot;yyt&quot; provided below as t.l)<p>3. convert urls to hostnames<p><pre><code>   g=1.txt k 1
</code></pre>
(example script provided below as &quot;1.k&quot;)<p>4. retrieve json dns data from doh dns server, efficiently, over a single connection<p><pre><code>   see https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17228745
</code></pre>
5. convert json dns data to csv<p><pre><code>   see https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17228473
</code></pre>
6. import csv into database e.g. sqlite3, kdb+, export to &#x2F;etc&#x2F;hosts, export to zonefile for localhost auth dns server, etc.<p>now, when user is reading hn front page, no dns lookups are needed. user already has the dns data. there is no network usage for dns requests, increasing hn front page browsing speed for the user.  there are no piecemeal dns requests sent, increasing user privacy.<p>7. track ip address changes over time, compare answers from different caches, etc.  retrieve type 2 (NS) instead of type 1 (A) records, then compare to NS records provided in public zonefiles from icann, public internet scans, etc.<p>cat t.l<p><pre><code>    #define p printf(&quot;%s\n&quot;,yytext);
   %%
   \200|\201|\204|\223|\224|\230|\231|\234|\235
   http:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* p;
   https:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* p;
   ftp:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* p;
   .|\n
   %%
   int main(){ yylex();}
   int yywrap(){}

    &#x2F;* compile with something like: 
    flex -Crfa -8 -i t.l 
    cc  -pipe lex.yy.c -static -o yyt 
    *&#x2F;

</code></pre>
cat 1.k<p><pre><code>   &#x2F;k3 (novice level)
   &#x2F;usage: g=f k 1 where f is list of urls
   h0:_getenv &quot;g&quot;;h1:0:h0; h1:{:[(#h1[x] _ss &quot;:&#x2F;&#x2F;&quot;)&gt;0;h1[x];_exit 1]}&#x27;!#h1;h1:{*((h1[x] _ss &quot;:&#x2F;&#x2F;[^&#x2F;]&quot;)+3) _ h1[x]}&#x27;!#h1;h2:{h1[x] _ss &quot;[^a-z^A-Z^0-9^.^-]&quot;};h3:{*h2[x]};h1:{h3[x]#h1[x]}&#x27;!#h1;h1:?:&#x2F;h1;h0 0:h1;
   \\</code></pre>