From 5a3af9525a099137c5281a2c3758e8140651dbff Mon Sep 17 00:00:00 2001 From: Bernard `Guyzmo` Pratz Date: Fri, 29 Jan 2016 20:31:21 +0100 Subject: [PATCH] Added support for custom DNS-only zones - Updated dropdown list for domains, - Added free text input for writing down domain addresses, - Updated backend with support of custom zones Signed-off-by: Bernard `Guyzmo` Pratz --- management/dns_update.py | 24 ++++----- management/templates/custom-dns.html | 73 ++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 15 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index c978a834..ac4a3f7d 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -22,7 +22,9 @@ def get_dns_domains(env): def get_dns_zones(env): # What domains should we create DNS zones for? Never create a zone for # a domain & a subdomain of that domain. - domains = get_dns_domains(env) + domains_mail = get_dns_domains(env) + domains_custom = set([n for n, *_ in get_custom_dns_config(env)]) + domains = domains_mail | domains_custom # Exclude domains that are subdomains of other domains we know. Proceed # by looking at shorter domains first. @@ -727,16 +729,16 @@ def write_custom_dns_config(config, env): f.write(config_yaml) def set_custom_dns_record(qname, rtype, value, action, env): - # validate qname - for zone, fn in get_dns_zones(env): - # It must match a zone apex or be a subdomain of a zone - # that we are otherwise hosting. - if qname == zone or qname.endswith("."+zone): - break - else: - # No match. - if qname != "_secondary_nameserver": - raise ValueError("%s is not a domain name or a subdomain of a domain name managed by this box." % qname) + # # validate qname + # for zone, fn in get_dns_zones(env): + # # It must match a zone apex or be a subdomain of a zone + # # that we are otherwise hosting. + # if qname == zone or qname.endswith("."+zone): + # break + # else: + # # No match. + # if qname != "_secondary_nameserver": + # raise ValueError("%s is not a domain name or a subdomain of a domain name managed by this box." % qname) # validate rtype rtype = rtype.upper() diff --git a/management/templates/custom-dns.html b/management/templates/custom-dns.html index f1244810..30ad5af9 100644 --- a/management/templates/custom-dns.html +++ b/management/templates/custom-dns.html @@ -23,6 +23,13 @@ . +
+ + + + +
+
Leave the left field blank to set a record on the chosen domain name, or enter a subdomain.
@@ -163,19 +170,69 @@ function show_custom_dns() { $('#secondarydns-clear-instructions').toggle(data.hostnames.length > 0); }); + $('#customdnsZone').text(''); + var dns_list_domains = $('').attr('label', 'Domains'); + var dns_list_customs = $('').attr('label', 'Custom'); + var dns_list_advanced = $('').attr('label', 'Advanced'); + + $('#customdnsZone').append(dns_list_domains); + $('#customdnsZone').append(dns_list_customs); + $('#customdnsZone').append(dns_list_advanced); + + dns_list_advanced.append($('