added functionality that DNS DMARC entry for report is only shown when needed

This commit is contained in:
Jumper78
2025-02-16 21:08:19 +00:00
parent 23dce74637
commit fa74b19f90
2 changed files with 22 additions and 0 deletions

View File

@@ -247,6 +247,15 @@ class Domain(Base):
ruf = f' ruf=mailto:{ruf}@{domain};' if ruf else ''
return f'_dmarc.{self.name}. 600 IN TXT "v=DMARC1; p=reject;{rua}{ruf} adkim=s; aspf=s"'
@cached_property
def dns_dmarc_report_needed(self):
""" return true if DMARC report record is needed """
domain = app.config['DOMAIN']
if self.name != domain:
return True
else:
return False
@cached_property
def dns_dmarc_report(self):
""" return DMARC report record for mailu server """
@@ -373,6 +382,15 @@ class Alternative(Base):
ruf = f' ruf=mailto:{ruf}@{domain};' if ruf else ''
return f'_dmarc.{self.name}. 600 IN TXT "v=DMARC1; p=reject;{rua}{ruf} adkim=s; aspf=s"'
@cached_property
def dns_dmarc_report_needed(self):
""" return true if DMARC report record is needed """
domain = app.config['DOMAIN']
if self.name != domain:
return True
else:
return False
@cached_property
def dns_dmarc_report(self):
""" return DMARC report record for mailu server """

View File

@@ -44,7 +44,9 @@
<th>{% trans %}DNS DMARC entry{% endtrans %}</th>
<td>
{{ macros.clip("dns_dmarc") }}<pre id="dns_dmarc" class="pre-config border bg-light">{{ domain.dns_dmarc }}</pre>
{%- if domain.dns_dmarc_report_needed %}
{{ macros.clip("dns_dmarc_report") }}<pre id="dns_dmarc_report" class="pre-config border bg-light">{{ domain.dns_dmarc_report }}</pre>
{%- endif %}
</td>
</tr>
{%- endif %}
@@ -89,7 +91,9 @@
<th>{% trans %}DNS DMARC entry{% endtrans %}</th>
<td>
{{ macros.clip("dns_dmarc") }}<pre id="dns_dmarc" class="pre-config border bg-light">{{ alternative.dns_dmarc }}</pre>
{%- if alternative.dns_dmarc_report_needed %}
{{ macros.clip("dns_dmarc_report") }}<pre id="dns_dmarc_report" class="pre-config border bg-light">{{ alternative.dns_dmarc_report }}</pre>
{%- endif %}
</td>
</tr>
{%- endif %}