Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use IPv6 DNS Servers #24

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions dehydrated-hook-ddns-tsig.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ def query_NS_record(domain_name):
for i in range(0, len(name_list)):
nameservers = []
try:
for ns in [rdata.target.to_unicode()
for rdata in dns.resolver.query('.'.join(name_list[i:]),
'NS')]:
nameservers += [_.to_text() for _ in dns.resolver.query(ns)]
fqdn = '.'.join(name_list[i:])
for rdata in dns.resolver.query(fqdn, dns.rdatatype.NS):
ns = rdata.target.to_unicode()
nsL = []
nsL.extend([_.to_text() for _ in dns.resolver.query(ns)]) # default type: A
nsL.extend([_.to_text() for _ in dns.resolver.query(ns, rdtype=dns.rdatatype.AAAA)])
nameservers.append(nsL)
Copy link

@ukleinek ukleinek Jun 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be written more easily and probably with shorter execution time as:

ns = rdata.target.to_unicode()
nsL = [_.to_text() for _ in chain(dns.resolver.query(ns), 
                                  dns.resolver.query(ns, rdtype=dns.rdatatype.AAAA))]
nameservers.append(nsL)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you could do that, but in case you run in a 30s timeout, you have no clue, where this comes from. I personally do not like lines that does multiple things and leave you in the dark if something goes wrong.

except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN) as e:
continue
if nameservers:
Expand Down Expand Up @@ -197,7 +200,7 @@ def verify_record(domain_name,
rtype,
rdata if rdata is not None else "*",
ns))
resolver.nameservers = [ns]
resolver.nameservers = ns
answer = []
try:
answer = [_.to_text().strip('"'+"'")
Expand Down