> From: [email protected] > Looking for a command line tool to do testing of DoH. Something like > dig or drill with DoH support. I suspect there's a Python tool or > the like out there somewhere, but my google-fu is failing. > > Don't want to re-invent the wheel if I don't have to.
Python has good DNS and HTTPS library. You can write DoH client easily and quickly. For me, I like perl. For example, (Many codes from manual pages) ------------------------------------------------------------- #!/usr/bin/env perl use strict; use Net::DNS::Packet; use MIME::Base64; use LWP::Protocol::https; use LWP::UserAgent; # my $server = 'https://cloudflare-dns.com/dns-query'; our @ARGV; # Usage: DoHclient.pl QNAME QTYPE QCLASS my $qname = shift @ARGV; if (!defined($qname)) { $qname = '.'; } my $qtype = shift @ARGV; if (!defined($qtype)) { $qtype = 'A'; } my $qclass = shift @ARGV; if (!defined($qclass)) { $qclass = 'IN'; } # my $q = new Net::DNS::Packet($qname, $qtype, $qclass); $q->header->rd(1); my $base64 = encode_base64($q->data); chomp $base64; my $url = sprintf("%s?dns=%s", $server, $base64); my $ua = LWP::UserAgent->new(); my $r = $ua->get($url); if ($r->is_success) { my $packet = new Net::DNS::Packet(\($r->decoded_content)); $packet->print; } else { die $r->status_line; } ------------------------------------------------------------- -- Kazunori Fujiwara, JPRS <[email protected]> _______________________________________________ dns-operations mailing list [email protected] https://lists.dns-oarc.net/mailman/listinfo/dns-operations
