File: tsig.py

package info (click to toggle)
dnspython 2.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,448 kB
  • sloc: python: 34,885; sh: 7; makefile: 4
file content (18 lines) | stat: -rw-r--r-- 404 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)