Skip to content

Commit

Permalink
Merge pull request #49 from mietzen/fix-minor-bugs
Browse files Browse the repository at this point in the history
This PR addresses a bug identified by @kandykarter #46 (comment) , where the order of the root domain handle @ determines whether it is set or not.

Additionally, another bug was fixed where all records of a domain were deleted, not just A and AAAA records.
  • Loading branch information
mietzen authored Apr 2, 2024
2 parents 8e81a5a + 366ace9 commit abb1106
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions porkbun_ddns/porkbun_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def _check_config(self) -> None:

def set_subdomain(self, subdomain: str) -> None:
self.subdomain = subdomain.lower()
if self.subdomain != '@':
if self.subdomain == '@':
self.fqdn = self.domain
else:
self.fqdn = '.'.join([self.subdomain, self.domain])

def get_public_ips(self) -> list:
Expand Down Expand Up @@ -197,7 +199,7 @@ def delete_records(self):
in ["A", "AAAA"]]
if self.fqdn in domain_names:
for i in self.records:
if i["name"] == self.fqdn:
if i["name"] == self.fqdn and i['type'] in ["A", "AAAA"]:
logger.debug('Deleting existing entry:\n{}'.format(json.dumps(
{"name": self.fqdn, "type": i['type'], "content": str(i['content'])})))
self._delete_record(i['id'])
Expand Down

0 comments on commit abb1106

Please sign in to comment.