File: tsig_demo.py

package info (click to toggle)
python-getdns 1.0.0~b1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: ansic: 3,538; python: 607; makefile: 130
file content (17 lines) | stat: -rwxr-xr-x 532 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python

import getdns
import base64

u = [ { 'address_data': '185.49.141.37', 
        'address_type': 'IPv4', 
        'tsig_algorithm': 'hmac-md5.sig-alg.reg.int', 
        'tsig_name': 'hmac-md5.tsigs.getdnsapi.net',
        'tsig_secret':  base64.b64decode('16G69OTeXW6xSQ==')
 }]

c = getdns.Context()
c.resolution_type = getdns.RESOLUTION_STUB
c.upstream_recursive_servers = u
f = c.general('getdnsapi.net', request_type = getdns.RRTYPE_SOA)
print('tsig_status is {0}'.format(f.replies_tree[0]['tsig_status']))