From 16af54b15d76acef6dd33c134a5dfd569cfb5f81 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 30 Oct 2023 16:00:43 +0100 Subject: [PATCH] Only use split key in zonefile, not in gui/api/export --- core/admin/mailu/models.py | 4 +--- .../mailu/ui/templates/domain/details.html | 4 ---- core/admin/mailu/ui/views/domains.py | 23 +++++++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index 926ef2fc..45ec457c 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -232,9 +232,7 @@ class Domain(Base): """ return DKIM record for domain """ if self.dkim_key: selector = app.config['DKIM_SELECTOR'] - txt = f'v=DKIM1; k=rsa; p={self.dkim_publickey}' - record = ' '.join(f'"{txt[p:p+250]}"' for p in range(0, len(txt), 250)) - return f'{selector}._domainkey.{self.name}. 600 IN TXT {record}' + return f'{selector}._domainkey.{self.name}. 600 IN TXT "v=DKIM1; k=rsa; p={self.dkim_publickey}"' @cached_property def dns_dmarc(self): diff --git a/core/admin/mailu/ui/templates/domain/details.html b/core/admin/mailu/ui/templates/domain/details.html index a58c4477..74657c28 100644 --- a/core/admin/mailu/ui/templates/domain/details.html +++ b/core/admin/mailu/ui/templates/domain/details.html @@ -36,10 +36,6 @@ {%- if domain.dkim_publickey %} - - {% trans %}DKIM public key{% endtrans %} - {{ macros.clip("dkim_key") }}
{{ domain.dkim_publickey }}
- {% trans %}DNS DKIM entry{% endtrans %} {{ macros.clip("dns_dkim") }}
{{ domain.dns_dkim }}
diff --git a/core/admin/mailu/ui/views/domains.py b/core/admin/mailu/ui/views/domains.py index b03b96b0..6fb4410b 100644 --- a/core/admin/mailu/ui/views/domains.py +++ b/core/admin/mailu/ui/views/domains.py @@ -74,17 +74,22 @@ def domain_details(domain_name): @access.domain_admin(models.Domain, 'domain_name') def domain_download_zonefile(domain_name): domain = models.Domain.query.get(domain_name) or flask.abort(404) - final = domain.dns_mx+"\n" - final = final + domain.dns_spf+"\n" + res = [domain.dns_mx, domain.dns_spf] if domain.dkim_publickey: - final = final + domain.dkim_publickey+"\n" - final = final + domain.dns_dkim+"\n" - final = final + domain.dns_dmarc+"\n" + record = domain.dns_dkim.split('"', 1)[0].strip() + txt = f'v=DKIM1; k=rsa; p={domain.dkim_publickey}' + txt = ' '.join(f'"{txt[p:p+250]}"' for p in range(0, len(txt), 250)) + res.append(f'{record} {txt}"') + res.append(domain.dns_dmarc) if domain.dns_tlsa: - final = final + domain.dns_tlsa - for i in domain.dns_autoconfig: - final = final + i+"\n" - return flask.Response(final,content_type="text/plain",headers={'Content-disposition': 'attachment; filename='+domain.name+'-zonefile.txt'}) + res.append(domain.dns_tlsa) + res.extend(domain.dns_autoconfig) + res.append("") + return flask.Response( + "\n".join(res), + content_type="text/plain", + headers={"Content-disposition": f"attachment; filename={domain.name}-zonefile.txt"} + ) @ui.route('/domain/genkeys/', methods=['GET', 'POST'])