From 047dcb68d14f31f67400a05af5e18f4975e8793e Mon Sep 17 00:00:00 2001 From: Nils Stein <31704359+mietzen@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:58:21 +0200 Subject: [PATCH 1/2] Fix bug that overwrites root domain handle if it is not in the first place --- porkbun_ddns/porkbun_ddns.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/porkbun_ddns/porkbun_ddns.py b/porkbun_ddns/porkbun_ddns.py index 2713dc2..74f44ef 100644 --- a/porkbun_ddns/porkbun_ddns.py +++ b/porkbun_ddns/porkbun_ddns.py @@ -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: From 366ace9afff577a86679120b6a83dc9ffa6f9407 Mon Sep 17 00:00:00 2001 From: Nils Stein <31704359+mietzen@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:58:40 +0200 Subject: [PATCH 2/2] only delete A and AAAA records --- porkbun_ddns/porkbun_ddns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/porkbun_ddns/porkbun_ddns.py b/porkbun_ddns/porkbun_ddns.py index 74f44ef..a9808c3 100644 --- a/porkbun_ddns/porkbun_ddns.py +++ b/porkbun_ddns/porkbun_ddns.py @@ -199,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'])