Add punycode (IDN) support (#879)

This commit is contained in:
R. Daneel Olivaw
2021-03-16 14:37:05 -04:00
committed by GitHub
parent 4c19f95928
commit 46993e08c0
9 changed files with 78 additions and 28 deletions

View File

@ -162,6 +162,15 @@ class Record(object):
for record in submitted_records:
# Format the record name
#
# Translate record name into punycode (IDN) as that's the only way
# to convey non-ascii records to the dns server
record['record_name'] = record['record_name'].encode('idna').decode()
#TODO: error handling
# If the record is an alias (CNAME), we will also make sure that
# the target domain is properly converted to punycode (IDN)
if record["record_type"] == 'CNAME':
record['record_data'] = record['record_data'].encode('idna').decode()
#TODO: error handling
# If it is ipv6 reverse zone and PRETTY_IPV6_PTR is enabled,
# We convert ipv6 address back to reverse record format
# before submitting to PDNS API.