Skip to content

Commit

Permalink
Merge branch 'main' into multi-subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
mietzen committed Oct 7, 2023
2 parents 39f8eb3 + 3a6b00a commit 9313b51
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions porkbun_ddns/porkbun_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ def update_records(self):
# Update records
self.records = self.get_records()

def delete_records(self):
"""Update DNS records for the specified domain.
"""
self.records = self.get_records()
domain_names = [x['name'] for x in self.records if x['type']
in ["A", "AAAA"]]
if self.fqdn in domain_names:
for i in self.records:
if i["name"] == self.fqdn:
logger.debug('Deleting existing entry:\n{}'.format(json.dumps(
{"name": self.fqdn, "type": i['type'], "content": str(i['content'])})))
self._delete_record(i['id'])
else:
logger.debug('Record not found:\n{}'.format(json.dumps(
{"name": self.fqdn, "type": i['type'], "content": str(i['content'])})))

def _delete_record(self, domain_id: str):
"""Delete a DNS record with the given domain ID.
"""
Expand Down

0 comments on commit 9313b51

Please sign in to comment.