{% extends "base.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}

{% load i18n %}

{% block content %}
  <h3>{% trans "DNS Records for domain:" %} {{ domain }}</h3>

  <p>
    {% blocktrans trimmed %}
      The following DNS records must be added manually on this domain for the
      mail server to work properly for this domain.
    {% endblocktrans %}
  </p>

  <div class="table-responsive">
    <table class="table table-sm">
      <thead>
        <tr>
          <th>{% trans "Domain" %}</th>
          <th>{% trans "TTL" %}</th>
          <th>{% trans "Class" %}</th>
          <th>{% trans "Type" %}</th>
          <th>{% trans "Priority" %}</th>
          <th>{% trans "Weight" %}</th>
          <th>{% trans "Port" %}</th>
          <th>{% trans "Host/Target/Value" %}</th>
        </tr>
      </thead>
      <tbody>
        {% for dns_entry in dns_entries %}
          <tr>
            <td>{{ dns_entry.domain|default_if_none:"" }}</td>
            <td>{{ dns_entry.ttl }}</td>
            <td>{{ dns_entry.class_ }}</td>
            <td>{{ dns_entry.type_ }}</td>
            <td>{{ dns_entry.priority }}</td>
            <td>{{ dns_entry.weight|default_if_none:"" }}</td>
            <td>{{ dns_entry.port|default_if_none:"" }}</td>
            <td class="text-break">{{ dns_entry.get_split_value }}</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  {% if domain == primary_domain %}
    <h3>{% trans "Reverse DNS Records for IP Addresses" %}</h3>

    <p>
      {% blocktrans trimmed %}
        If your {{ box_name }} runs on a cloud service infrastructure, you
        should configure <a href="https://en.wikipedia.org/wiki/Reverse_DNS_lookup">
        Reverse DNS lookup</a>. This isn't mandatory, however, it greatly improves
        email deliverability. Reverse DNS isn't configured where your regular DNS
        is. You should look for it in the settings of your VPS/ISP. Some providers
        preconfigure the IP address part for you and you only have to set the
        domain part. Only one of your domains can have Revese DNS lookup
        configured unless you have multiple public IP addresses.
      {% endblocktrans %}
    </p>

    <p>
      {% blocktrans trimmed %}
        An external service is used to lookup public IP address to show in the
        following section. This can be configured in the privacy app.
      {% endblocktrans %}
    </p>

    <div class="table-responsive">
      <table class="table table-sm">
        <thead>
          <tr>
            <th>{% trans "Host" %}</th>
            <th>{% trans "TTL" %}</th>
            <th>{% trans "Type" %}</th>
            <th>{% trans "Host/Target/Value" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for dns_entry in reverse_dns_entries %}
            <tr>
              <td>{{ dns_entry.domain|default_if_none:"" }}</td>
              <td>{{ dns_entry.ttl }}</td>
              <td>{{ dns_entry.type_ }}</td>
              <td class="text-break">{{ dns_entry.get_split_value }}</td>
            </tr>
            {% endfor %}
        </tbody>
      </table>
    </div>
  {% endif %}
{% endblock %}
