From b4496213b13108f53ecfeaeea0cd96cf5b4ccb53 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 15 Nov 2020 11:55:41 -0500 Subject: [PATCH] Move zonefile download to the external dns page, fix filename, response format --- management/daemon.py | 7 +++- management/dns_update.py | 4 +-- management/templates/custom-dns.html | 46 +++----------------------- management/templates/external-dns.html | 41 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 44 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index ceabd3a9..83368374 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -1,3 +1,5 @@ +#!/usr/local/lib/mailinabox/env/bin/python3 + import os, os.path, re, json, time import multiprocessing.pool, subprocess @@ -342,7 +344,10 @@ def dns_get_dump(): @authorized_personnel_only def dns_get_zonefile(zone): from dns_update import get_dns_zonefile - return json_response(get_dns_zonefile(zone, env)) + zonefile = get_dns_zonefile(zone, env) + response = make_response(zonefile, 200) + response.mimetype = "text/plain" + return response # SSL diff --git a/management/dns_update.py b/management/dns_update.py index 01d81121..ccca69cd 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -569,9 +569,9 @@ def get_dns_zonefile(zone, env): if zone == domain: break else: - raise ValueError("%s is not a domain name or a subdomain of a domain name managed by this box." % zone) + raise ValueError("%s is not a domain name that corresponds to a zone." % zone) - nsd_zonefile = "/etc/nsd/zones/" + zone + ".txt" + nsd_zonefile = "/etc/nsd/zones/" + fn with open(nsd_zonefile, "r") as f: return f.read() diff --git a/management/templates/custom-dns.html b/management/templates/custom-dns.html index 224fa3d3..b1b98b9b 100644 --- a/management/templates/custom-dns.html +++ b/management/templates/custom-dns.html @@ -99,23 +99,6 @@ -

Download zonefile

- -

You can download your zonefiles here, for example if you want to host your DNS somewhere else.

- -
-
- -
- -
-
-
-
- -
-
-

Custom DNS API

@@ -189,13 +172,10 @@ function show_custom_dns() { "GET", { }, function(data) { - var selects = ['#customdnsZone', '#downloadZonefile'] - for (var i = 0; i < selects.length; i++) { - $(selects[i]).text(''); - for (var j = 0; j < data.length; j++) { - $(selects[i]).append($('