Browse Source

Added reverse DNS check

Sebastian Lohff 4 years ago
parent
commit
eda76052dd
6 changed files with 56 additions and 30 deletions
  1. 1
    1
      api/urls.py
  2. 3
    3
      api/views.py
  3. 1
    0
      domains/urls.py
  4. 20
    2
      domains/views.py
  5. 2
    2
      templates/domains/dns_check.html
  6. 29
    22
      templates/domains/overview.html

+ 1
- 1
api/urls.py View File

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

+ 3
- 3
api/views.py View File

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

+ 1
- 0
domains/urls.py View File

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

+ 20
- 2
domains/views.py View File

@@ -1,5 +1,5 @@
1 1
 from django.shortcuts import render
2
-from django.urls import reverse_lazy
2
+from django.urls import reverse_lazy, reverse
3 3
 from django.contrib.auth.decorators import login_required
4 4
 from django.views.generic import DetailView, CreateView, UpdateView
5 5
 from django.contrib.auth.mixins import LoginRequiredMixin
@@ -39,8 +39,15 @@ class DomainCheck(LoginRequiredMixin, DetailView):
39 39
 	slug_field = "name"
40 40
 	slug_url_kwarg = "domain"
41 41
 	context_object_name = "domain"
42
+	template_name = "domains/dns_check.html"
43
+
44
+	def get_context_data(self, **kwargs):
45
+		ctx = super(DomainCheck, self).get_context_data(**kwargs)
46
+		ctx["key"] = self.object.name
47
+		ctx["apiUrl"] = reverse("api:domain-check")
48
+
49
+		return ctx
42 50
 
43
-	template_name = "domains/domain_check.html"
44 51
 
45 52
 class DomainDetail(LoginRequiredMixin, DetailView):
46 53
 	model = Domain
@@ -116,6 +123,17 @@ class ReverseZoneCreate(LoginRequiredMixin, CreateView):
116 123
 		return kwargs
117 124
 
118 125
 
126
+class ReverseZoneCheck(LoginRequiredMixin, DetailView):
127
+	model = ReverseZone
128
+	template_name = "domains/dns_check.html"
129
+
130
+	def get_context_data(self, **kwargs):
131
+		ctx = super(ReverseZoneCheck, self).get_context_data(**kwargs)
132
+		ctx["key"] = self.object.id
133
+		ctx["apiUrl"] = reverse("api:reversezone-check")
134
+
135
+		return ctx
136
+
119 137
 class ReverseZoneDetail(LoginRequiredMixin, DetailView):
120 138
 	model = ReverseZone
121 139
 	template_name = "whoisdb/handle_show.html"

templates/domains/domain_check.html → templates/domains/dns_check.html View File

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

+ 29
- 22
templates/domains/overview.html View File

@@ -17,26 +17,6 @@
17 17
 			{% endif %}
18 18
 
19 19
 
20
-			<h4>Your Nameservers (<a href="{% url "domains:nameserver-create" %}">New nameserver</a>)</h4>
21
-			<table class="table">
22
-				<tr>
23
-					<th>Nameserver</th>
24
-					<th>Glue IPv4</th>
25
-					<th>Glue IPv6</th>
26
-					<th>MNTs</th>
27
-					<th></th>
28
-				</tr>
29
-			{% for nameserver in nameservers %}
30
-				<tr>
31
-					<td><a href="{% url "domains:nameserver-show" nameserver.getPK %}">{{ nameserver.name }}</a></td>
32
-					<td>{{ nameserver.glueIPv4|default:"-" }}</td>
33
-					<td>{{ nameserver.glueIPv6|default:"-" }}</td>
34
-					<td>{{ nameserver.mnt_by.all|linkObjects }}</td>
35
-					<td><a href="{% url "domains:nameserver-edit" nameserver.getPK %}">Edit</a> <a href="{% url "domains:nameserver-delete" nameserver.getPK %}">Delete</a></td>
36
-				</tr>
37
-			{% endfor %}
38
-			</table>
39
-
40 20
 			<h4>Your Domains (<a href="{% url "domains:domain-create" %}">New domain</a>)</h4>
41 21
 			<table class="table">
42 22
 				<tr>
@@ -56,7 +36,31 @@
56 36
 						</ul>
57 37
 					</td>
58 38
 					<td>{{ domain.mnt_by.all|linkObjects }}</td>
59
-					<td><a href="{% url "domains:domain-edit" domain.name %}">Edit</a> <a href="{% url "domains:domain-delete" domain.name %}">Delete</a></td>
39
+					<td>
40
+						<a href="{% url "domains:domain-check" domain.name %}">DNS-check</a>
41
+						<a href="{% url "domains:domain-edit" domain.name %}">Edit</a>
42
+						<a href="{% url "domains:domain-delete" domain.name %}">Delete</a>
43
+					</td>
44
+				</tr>
45
+			{% endfor %}
46
+			</table>
47
+
48
+			<h4>Your Nameservers (<a href="{% url "domains:nameserver-create" %}">New nameserver</a>)</h4>
49
+			<table class="table">
50
+				<tr>
51
+					<th>Nameserver</th>
52
+					<th>Glue IPv4</th>
53
+					<th>Glue IPv6</th>
54
+					<th>MNTs</th>
55
+					<th></th>
56
+				</tr>
57
+			{% for nameserver in nameservers %}
58
+				<tr>
59
+					<td><a href="{% url "domains:nameserver-show" nameserver.getPK %}">{{ nameserver.name }}</a></td>
60
+					<td>{{ nameserver.glueIPv4|default:"-" }}</td>
61
+					<td>{{ nameserver.glueIPv6|default:"-" }}</td>
62
+					<td>{{ nameserver.mnt_by.all|linkObjects }}</td>
63
+					<td><a href="{% url "domains:nameserver-edit" nameserver.getPK %}">Edit</a> <a href="{% url "domains:nameserver-delete" nameserver.getPK %}">Delete</a></td>
60 64
 				</tr>
61 65
 			{% endfor %}
62 66
 			</table>
@@ -80,7 +84,10 @@
80 84
 						{% endfor %}
81 85
 						</ul>
82 86
 					</td>
83
-					<td><a href="{% url "domains:reversezone-edit" reversezone.pk %}">Edit</a> <a href="{% url "domains:reversezone-delete" reversezone.pk %}">Delete</a></td>
87
+					<td>
88
+						<a href="{% url "domains:reversezone-check" reversezone.pk %}">DNS-check</a>
89
+						<a href="{% url "domains:reversezone-edit" reversezone.pk %}">Edit</a>
90
+						<a href="{% url "domains:reversezone-delete" reversezone.pk %}">Delete</a></td>
84 91
 				</tr>
85 92
 			{% endfor %}
86 93
 			</table>

Loading…
Cancel
Save