examples/dot.py
raw| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # This is an example of sending DNS queries over TLS (DoT) with dnspython. |
| 4 | |
| 5 | import dns.message |
| 6 | import dns.query |
| 7 | import dns.rdatatype |
| 8 | |
| 9 | |
| 10 | def main(): |
| 11 | where = "1.1.1.1" |
| 12 | qname = "example.com." |
| 13 | q = dns.message.make_query(qname, dns.rdatatype.A) |
| 14 | r = dns.query.tls(q, where) |
| 15 | for answer in r.answer: |
| 16 | print(answer) |
| 17 | |
| 18 | # ... do more lookups |
| 19 | |
| 20 | |
| 21 | if __name__ == "__main__": |
| 22 | main() |