1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-06-06 23:36:26 +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 """ """ return DKIM record for domain """
if self.dkim_key: if self.dkim_key:
selector = app.config['DKIM_SELECTOR'] selector = app.config['DKIM_SELECTOR']
txt = f'v=DKIM1; k=rsa; p={self.dkim_publickey}' return f'{selector}._domainkey.{self.name}. 600 IN TXT "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}'
@cached_property @cached_property
def dns_dmarc(self): def dns_dmarc(self):

View File

@ -36,10 +36,6 @@
</td> </td>
</tr> </tr>
{%- if domain.dkim_publickey %} {%- 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> <tr>
<th>{% trans %}DNS DKIM entry{% endtrans %}</th> <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> <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') @access.domain_admin(models.Domain, 'domain_name')
def domain_download_zonefile(domain_name): def domain_download_zonefile(domain_name):
domain = models.Domain.query.get(domain_name) or flask.abort(404) domain = models.Domain.query.get(domain_name) or flask.abort(404)
final = domain.dns_mx+"\n" res = [domain.dns_mx, domain.dns_spf]
final = final + domain.dns_spf+"\n"
if domain.dkim_publickey: if domain.dkim_publickey:
final = final + domain.dkim_publickey+"\n" record = domain.dns_dkim.split('"', 1)[0].strip()
final = final + domain.dns_dkim+"\n" txt = f'v=DKIM1; k=rsa; p={domain.dkim_publickey}'
final = final + domain.dns_dmarc+"\n" 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: if domain.dns_tlsa:
final = final + domain.dns_tlsa res.append(domain.dns_tlsa)
for i in domain.dns_autoconfig: res.extend(domain.dns_autoconfig)
final = final + i+"\n" res.append("")
return flask.Response(final,content_type="text/plain",headers={'Content-disposition': 'attachment; filename='+domain.name+'-zonefile.txt'}) 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']) @ui.route('/domain/genkeys/<domain_name>', methods=['GET', 'POST'])