Added reverse DNS check

This commit is contained in:
Sebastian Lohff 2017-05-01 06:41:29 +02:00
parent 10580c4b4b
commit eda76052dd
6 changed files with 56 additions and 30 deletions

View File

@ -8,6 +8,6 @@ urlpatterns = [
url(r'inetnum/get-subnet/$', api_views.getSubnet, name='inetnum-get-subnet'),
url(r'domain/check/$', api_views.checkDomain, name='domain-check'),
url(r'rzone/check/$', api_views.checkRzone, name='rzone-check'),
url(r'rzone/check/$', api_views.checkRzone, name='reversezone-check'),
]

View File

@ -206,15 +206,15 @@ def checkRzone(request):
}
try:
rzonePk = ReverseZone.fixName(request.GET.get('rzone', ''))
rzonePk = int(request.GET.get('domain', ''))
rzone = ReverseZone.objects.get(pk=rzonePk)
if not rzone.canEdit(request.user):
raise ReverseZone.DoesNotExist()
ret["success"] = True
# FIXME: change this if we ever have more than one...
ret["result"] = helperCheckDomain(rzone.name, TLD_NAMESERVERS[0], rzone.nameservers.all())
except Domain.DoesNotExist:
ret["result"] = helperCheckDomain(rzone.getZone(), TLD_NAMESERVERS[0], rzone.nameservers.all())
except (ReverseZone.DoesNotExist, ValueError):
ret["errorMsg"] = "ReverseZone does not exist"
return JsonResponse(ret)

View File

@ -18,6 +18,7 @@ urlpatterns = [
url(r'reversezone/create/$', domains_views.ReverseZoneCreate.as_view(), name='reversezone-create'),
url(r'reversezone/show/(?P<pk>[0-9]+)/$', domains_views.ReverseZoneDetail.as_view(), name='reversezone-show'),
url(r'reversezone/check/(?P<pk>[0-9]+)/$', domains_views.ReverseZoneCheck.as_view(), name='reversezone-check'),
url(r'reversezone/edit/(?P<pk>[0-9]+)/$', domains_views.ReverseZoneEdit.as_view(), name='reversezone-edit'),
url(r'reversezone/delete/(?P<pk>[0-9]+)/$', domains_views.ReverseZoneDelete.as_view(), name='reversezone-delete'),

View File

@ -1,5 +1,5 @@
from django.shortcuts import render
from django.urls import reverse_lazy
from django.urls import reverse_lazy, reverse
from django.contrib.auth.decorators import login_required
from django.views.generic import DetailView, CreateView, UpdateView
from django.contrib.auth.mixins import LoginRequiredMixin
@ -39,8 +39,15 @@ class DomainCheck(LoginRequiredMixin, DetailView):
slug_field = "name"
slug_url_kwarg = "domain"
context_object_name = "domain"
template_name = "domains/dns_check.html"
def get_context_data(self, **kwargs):
ctx = super(DomainCheck, self).get_context_data(**kwargs)
ctx["key"] = self.object.name
ctx["apiUrl"] = reverse("api:domain-check")
return ctx
template_name = "domains/domain_check.html"
class DomainDetail(LoginRequiredMixin, DetailView):
model = Domain
@ -116,6 +123,17 @@ class ReverseZoneCreate(LoginRequiredMixin, CreateView):
return kwargs
class ReverseZoneCheck(LoginRequiredMixin, DetailView):
model = ReverseZone
template_name = "domains/dns_check.html"
def get_context_data(self, **kwargs):
ctx = super(ReverseZoneCheck, self).get_context_data(**kwargs)
ctx["key"] = self.object.id
ctx["apiUrl"] = reverse("api:reversezone-check")
return ctx
class ReverseZoneDetail(LoginRequiredMixin, DetailView):
model = ReverseZone
template_name = "whoisdb/handle_show.html"

View File

@ -36,8 +36,8 @@ function addRecord(d, key, title) {
$(document).ready(function() {
$("#dnscontent").text("Running API request...");
$.get({
url: "{% url "api:domain-check" %}",
data: {domain: "{{ domain.name }}"},
url: "{{ apiUrl }}",
data: {domain: "{{ key}}"},
beforeSend: function() {
$("#dnscontent").html('<img src="{% static "img/loader.gif" %}">');
},

View File

@ -17,26 +17,6 @@
{% endif %}
<h4>Your Nameservers (<a href="{% url "domains:nameserver-create" %}">New nameserver</a>)</h4>
<table class="table">
<tr>
<th>Nameserver</th>
<th>Glue IPv4</th>
<th>Glue IPv6</th>
<th>MNTs</th>
<th></th>
</tr>
{% for nameserver in nameservers %}
<tr>
<td><a href="{% url "domains:nameserver-show" nameserver.getPK %}">{{ nameserver.name }}</a></td>
<td>{{ nameserver.glueIPv4|default:"-" }}</td>
<td>{{ nameserver.glueIPv6|default:"-" }}</td>
<td>{{ nameserver.mnt_by.all|linkObjects }}</td>
<td><a href="{% url "domains:nameserver-edit" nameserver.getPK %}">Edit</a> <a href="{% url "domains:nameserver-delete" nameserver.getPK %}">Delete</a></td>
</tr>
{% endfor %}
</table>
<h4>Your Domains (<a href="{% url "domains:domain-create" %}">New domain</a>)</h4>
<table class="table">
<tr>
@ -56,7 +36,31 @@
</ul>
</td>
<td>{{ domain.mnt_by.all|linkObjects }}</td>
<td><a href="{% url "domains:domain-edit" domain.name %}">Edit</a> <a href="{% url "domains:domain-delete" domain.name %}">Delete</a></td>
<td>
<a href="{% url "domains:domain-check" domain.name %}">DNS-check</a>
<a href="{% url "domains:domain-edit" domain.name %}">Edit</a>
<a href="{% url "domains:domain-delete" domain.name %}">Delete</a>
</td>
</tr>
{% endfor %}
</table>
<h4>Your Nameservers (<a href="{% url "domains:nameserver-create" %}">New nameserver</a>)</h4>
<table class="table">
<tr>
<th>Nameserver</th>
<th>Glue IPv4</th>
<th>Glue IPv6</th>
<th>MNTs</th>
<th></th>
</tr>
{% for nameserver in nameservers %}
<tr>
<td><a href="{% url "domains:nameserver-show" nameserver.getPK %}">{{ nameserver.name }}</a></td>
<td>{{ nameserver.glueIPv4|default:"-" }}</td>
<td>{{ nameserver.glueIPv6|default:"-" }}</td>
<td>{{ nameserver.mnt_by.all|linkObjects }}</td>
<td><a href="{% url "domains:nameserver-edit" nameserver.getPK %}">Edit</a> <a href="{% url "domains:nameserver-delete" nameserver.getPK %}">Delete</a></td>
</tr>
{% endfor %}
</table>
@ -80,7 +84,10 @@
{% endfor %}
</ul>
</td>
<td><a href="{% url "domains:reversezone-edit" reversezone.pk %}">Edit</a> <a href="{% url "domains:reversezone-delete" reversezone.pk %}">Delete</a></td>
<td>
<a href="{% url "domains:reversezone-check" reversezone.pk %}">DNS-check</a>
<a href="{% url "domains:reversezone-edit" reversezone.pk %}">Edit</a>
<a href="{% url "domains:reversezone-delete" reversezone.pk %}">Delete</a></td>
</tr>
{% endfor %}
</table>