]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Add a simple tsig example.
authorBob Halley <halley@dnspython.org>
Mon, 11 Mar 2024 15:32:12 +0000 (08:32 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 11 Mar 2024 15:32:12 +0000 (08:32 -0700)
examples/tsig.py [new file with mode: 0644]

diff --git a/examples/tsig.py b/examples/tsig.py
new file mode 100644 (file)
index 0000000..3487ec9
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import dns.message
+import dns.query
+import dns.tsig
+
+
+key = dns.tsig.Key("keyname.", "bnp6+y85UcBfsieuB/Uhx3EUsjc8wAFyyCSS5rhScb0=",
+                   algorithm=dns.tsig.HMAC_SHA256)
+
+
+q = dns.message.make_query("example.", "SOA")
+q.use_tsig(keyring=key)
+r = dns.query.udp(q, "127.0.0.1")   # your authority address here
+soa = r.find_rrset(r.answer, "example", "IN", "SOA")
+print(soa)
+
+