Skip to content

Commit

Permalink
Added warning for records masked by child zones
Browse files Browse the repository at this point in the history
  • Loading branch information
peteeckel committed Oct 18, 2024
1 parent 369a31a commit 5424ff2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netbox_dns/templates/netbox_dns/record.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ <h5 class="card-header">{% trans "Record" %}</h5>
<th scope="row">{% trans "Name" %}</th>
<td style="word-break:break-all;">{{ object.name }}</td>
</tr>
{% if mask_warning %}
<tr class="text-warning">
<th scope="row">{% trans "Warning" %}</th>
<td>{{ mask_warning }}</td>
</tr>
{% endif %}
{% if unicode_name %}
<tr>
<th scope="row">{% trans "IDN" %}</th>
Expand Down
13 changes: 13 additions & 0 deletions netbox_dns/views/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ def get_extra_context(self, request, instance):
else:
context["cname_table"] = self.get_cname_records(instance)

fqdn = dns_name.from_text(instance.fqdn)
name = dns_name.from_text(instance.name, origin=None)

if len(name) > 1 and not instance.is_glue:
if Zone.objects.filter(
name__in=get_parent_zone_names(
instance.fqdn, min_labels=len(fqdn) - len(name)
)
).exists():
context["mask_warning"] = _(
"Record is masked by a child zone and may not be visible in DNS"
)

return context


Expand Down

0 comments on commit 5424ff2

Please sign in to comment.