From: Moshe Kaplan Date: Sun, 8 Sep 2024 18:29:07 +0000 (-0400) Subject: Add example of DNS over TLS (#1126) X-Git-Tag: v2.7.0rc1~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9365cf1f72c686334649a03fb628cc97d72e608b;p=thirdparty%2Fdnspython.git Add example of DNS over TLS (#1126) --- diff --git a/examples/dot.py b/examples/dot.py new file mode 100644 index 00000000..a6f40c91 --- /dev/null +++ b/examples/dot.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# +# This is an example of sending DNS queries over TLS (DoT) with dnspython. + +import dns.message +import dns.query +import dns.rdatatype + + +def main(): + where = "1.1.1.1" + qname = "example.com." + q = dns.message.make_query(qname, dns.rdatatype.A) + r = dns.query.tls(q, where) + for answer in r.answer: + print(answer) + + # ... do more lookups + + +if __name__ == "__main__": + main()