Skip to content
Open
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
8 changes: 7 additions & 1 deletion powerdns_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def _get_request_data(self, changetype, server, zone, name, rtype, set_ptr=False
record_content = list()
if content:
for record in content:
entry = dict(content=record, disabled=disabled)
if rtype == "CNAME":
entry = dict(content=self._make_canonical(record), disabled=disabled)
else:
entry = dict(content=record, disabled=disabled)
if rtype in ['A', 'AAAA'] and set_ptr:
entry['set-ptr'] = True

Expand Down Expand Up @@ -310,8 +313,11 @@ def ensure(module, pdns_client):
record = pdns_client.get_record(name=name, server=server, rtype=rtype, zone=zone_name)
existing_content = [c.get('content') for c in record["records"]]


# Sanitize user-provided input for certain record types
if content:
if rtype == 'CNAME':
content = "{}.".format(content)
if rtype == 'AAAA':
# Lowercase IPv6 addresses to match case returned by the API.
# Necessary for later comparisons.
Expand Down