only delete matching type (by benneti)

suggested in https://github.com/porkbundomains/porkbun-dynamic-dns-python/pull/6#issuecomment-1037362375 by @benneti
This commit is contained in:
con-f-use 2022-02-13 13:48:09 +01:00 committed by GitHub
parent 99afcf45bf
commit b8edd0d5a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,8 +41,9 @@ def get_records(args):
def delete_record(args):
type_ = "A" if args.public_ip.version == 4 else "AAAA"
for i in get_records(args)["records"]:
if i["name"] == args.fqdn and i["type"] in ["A", "AAAA", "ALIAS", "CNAME"]:
if i["name"] == args.fqdn and i["type"] in [type_, "ALIAS", "CNAME"]:
print("Deleting existing {}-Record: {}".format(i["type"], i))
api(args, "/dns/delete/" + args.domain + "/" + i["id"])