1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-01-18 03:21:36 +02:00

Only use split key in zonefile, not in gui/api/export

This commit is contained in:
Alexander Graf 2023-10-30 16:00:43 +01:00
parent a27845b213
commit 16af54b15d
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629
3 changed files with 15 additions and 16 deletions

View File

@ -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):

View File

@ -36,10 +36,6 @@
</td>
</tr>
{%- if domain.dkim_publickey %}
<tr>
<th>{% trans %}DKIM public key{% endtrans %}</th>
<td>{{ macros.clip("dkim_key") }}<pre id="dkim_key" class="pre-config border bg-light">{{ domain.dkim_publickey }}</pre></td>
</tr>
<tr>
<th>{% trans %}DNS DKIM entry{% endtrans %}</th>
<td>{{ macros.clip("dns_dkim") }}<pre id="dns_dkim" class="pre-config border bg-light">{{ domain.dns_dkim }}</pre></td>

View File

@ -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/<domain_name>', methods=['GET', 'POST'])