From 6c401173dba86b73ca226f71a81d1c4783093fa7 Mon Sep 17 00:00:00 2001 From: missytake Date: Wed, 13 Dec 2023 02:48:02 +0100 Subject: [PATCH] DNS: also generate AAAA entry --- cmdeploy/src/cmdeploy/chatmail.zone.f | 1 + cmdeploy/src/cmdeploy/cmdeploy.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/cmdeploy/src/cmdeploy/chatmail.zone.f b/cmdeploy/src/cmdeploy/chatmail.zone.f index 9cc7e73b..7786227e 100644 --- a/cmdeploy/src/cmdeploy/chatmail.zone.f +++ b/cmdeploy/src/cmdeploy/chatmail.zone.f @@ -1,4 +1,5 @@ {chatmail_domain}. MX 10 {chatmail_domain}. +{chatmail_domain}. AAAA {ipv6} _submission._tcp.{chatmail_domain}. SRV 0 1 587 {chatmail_domain}. _submissions._tcp.{chatmail_domain}. SRV 0 1 465 {chatmail_domain}. _imap._tcp.{chatmail_domain}. SRV 0 1 143 {chatmail_domain}. diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index d082cf9c..36917257 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -94,6 +94,7 @@ def dns_cmd(args, out): """Generate dns zone file.""" template = importlib.resources.files(__package__).joinpath("chatmail.zone.f") ssh = f"ssh root@{args.config.mail_domain}" + get_ipv6 = "ip a | grep inet6 | grep 'scope global' | sed -e 's#/64 scope global##' | sed -e 's#inet6##'" def read_dkim_entries(entry): lines = [] @@ -107,6 +108,7 @@ def dns_cmd(args, out): print("Checking your DKIM keys and DNS entries...") acme_account_url = out.shell_output(f"{ssh} -- acmetool account-url") dkim_entry = read_dkim_entries(out.shell_output(f"{ssh} -- opendkim-genzone -F")) + ipv6 = out.shell_output(f"{ssh} -- {get_ipv6}").strip() to_print = [] with open(template, "r") as f: @@ -117,6 +119,7 @@ def dns_cmd(args, out): sts_id=datetime.datetime.now().strftime("%Y%m%d%H%M"), chatmail_domain=args.config.mail_domain, dkim_entry=dkim_entry, + ipv6=ipv6, ).strip() if " MX " in line: domain, typ, prio, value = line.split() @@ -130,6 +133,11 @@ def dns_cmd(args, out): current = get("SRV", domain[:-1]) if current != f"{prio} {weight} {port} {value}": print(line) + if " AAAA " in line: + domain, value = line.split(" AAAA ") + current = get("AAAA", domain.strip()[:-1]) + if current != value: + print(line) if " CAA " in line: domain, value = line.split(" IN CAA ") current = get("CAA", domain.strip()[:-1])