]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Add example of DNS over TLS (#1126)
authorMoshe Kaplan <mosheekaplan@gmail.com>
Sun, 8 Sep 2024 18:29:07 +0000 (14:29 -0400)
committerGitHub <noreply@github.com>
Sun, 8 Sep 2024 18:29:07 +0000 (11:29 -0700)
examples/dot.py [new file with mode: 0644]

diff --git a/examples/dot.py b/examples/dot.py
new file mode 100644 (file)
index 0000000..a6f40c9
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3\r
+#\r
+# This is an example of sending DNS queries over TLS (DoT) with dnspython.\r
+\r
+import dns.message\r
+import dns.query\r
+import dns.rdatatype\r
+\r
+\r
+def main():\r
+    where = "1.1.1.1"\r
+    qname = "example.com."\r
+    q = dns.message.make_query(qname, dns.rdatatype.A)\r
+    r = dns.query.tls(q, where)\r
+    for answer in r.answer:\r
+        print(answer)\r
+\r
+        # ... do more lookups\r
+\r
+\r
+if __name__ == "__main__":\r
+    main()\r