Skip to content

Instantly share code, notes, and snippets.

@MelindaShore
Created November 21, 2017 03:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelindaShore/0230d7f78446d333b239d84f5f2feb46 to your computer and use it in GitHub Desktop.
Save MelindaShore/0230d7f78446d333b239d84f5f2feb46 to your computer and use it in GitHub Desktop.
import getdns
u = [ { 'address_data': '9.9.9.9', 'address_type': 'IPv4', } ] # TLS-capable public DNS resolver
c = getdns.Context()
c.resolution_type = getdns.RESOLUTION_STUB # these three lines are all the setup
c.dns_transport_list = [ getdns.TRANSPORT_TLS ] # needed to execute a query over TLS
c.upstream_recursive_servers = u
r = c.address('getdnsapi.net')
if r.status == getdns.RESPSTATUS_GOOD:
for a in r.just_address_answers:
print(a['address_data'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment