
HTTP/1.1 pipelining example: DNS-Over-HTTPS - textmode
As a demonstration using only standard utilities, the three scripts below 1.sh, 2.sh and 3.sh will<p>1. accept a list of domains and output the required Base64URL-encoded DNS request<p>2. make a single HTTP connection to retrieve all the responses in binary format and write them to a file<p>3. convert the binary file to text, suitable for manipulation with text-formatting utilities so the DNS data can be added to HOSTS file or a zone file<p>bindparser is from curveprotect project; it converts BIND-style output from drill to tinydns zone file format.<p>Most HTTP servers on the internet do have pipelining enabled, sometimes with a max-limit of 100.  The three examples listed below were pipelining enabled with max-limit greater than 100 last time I checked.<p>Example usage:<p><pre><code>   1.sh &lt; list-of-domains &gt; 1.txt
   2.sh 001 &lt; 1.txt &gt; 1.bin 
   3.sh &lt; 1.bin &gt; 1.txt
   bindparser 1.txt &gt; 1.zone
   x=tinydns&#x2F;root&#x2F;data;cat 1.zone &gt;&gt; $x&#x2F;data;cd $x;
   awk &#x27;!x[$0]++&#x27; data &gt; data.tmp;mv data.tmp data;tinydns-data;cd -

   # 1.sh
   #!&#x2F;bin&#x2F;sh
   while IFS= read -r x;do printf $x&#x27; &#x27;;
   drill -q &#x2F;dev&#x2F;stdout $x @0.0.0.0 a|sed &#x27;s&#x2F;;.*&#x2F;&#x2F;&#x27;|xxd -p -r \
   |openssl base64|sed &#x27;s&#x2F;+&#x2F;-&#x2F;g;s|&#x2F;|_|g;s&#x2F;=.*$&#x2F;&#x2F;&#x27;|tr -d &#x27;\n&#x27;;echo;
   done

   # 2.sh
   #!&#x2F;bin&#x2F;sh
   case $1 in
   &quot;&quot;)sed &#x27;&#x2F;;;[0-9]*&#x2F;!d&#x27; $0;
      echo usage: $0 provider-number \&lt; output-from-script1.txt;exit
   ;;001)x=doh.powerdns.org;y=1              
   ;;002)x=ibuki.cgnat.net;y=1               
   ;;003)x=dns.aa.net.uk;y=1                 
   esac;
   case $y in
   1) sed &#x27;s&#x2F;\(.* \)\(.*\)&#x2F;GET \&#x2F;dns-query?dns=\2 HTTP\&#x2F;1.1\r\nHost: \1\r\n&#x2F;;
       $!s&#x2F;$&#x2F;Connection: keep-alive\r\n&#x2F;;$s&#x2F;$&#x2F;Connection: close\r\n\r\n&#x2F;;&#x27; \
       |socat -,ignoreeof ssl:$x:443,verify=0 &gt; 1.bin
   esac;
   3.sh &lt; 1.bin

   # 3.sh
   #!&#x2F;bin&#x2F;sh
   while IFS= read -r x;do sed -n &#x2F;${1-\.}&#x2F;p\;&#x2F;${1-\.}&#x2F;q|xxd -p|drill -i &#x2F;dev&#x2F;stdin 2&gt;&#x2F;dev&#x2F;null;done</code></pre>
======
textmode
Better 3.sh

    
    
       # 3.sh
       #!/bin/sh
       while IFS= read -r x;do sed -n '/\./p;/\./q'|xxd -p |drill -i /dev/stdin 2>/dev/null;done

------
textmode
Correction:

\- x=tinydns/root/data;cat 1.zone >> $x/data;cd $x;

\+ x=tinydns/root;cat 1.zone >> $x/data;cd $x;

