From 02099fe810774f7d9a1fdb0dfd28af1243640749 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 29 Sep 2013 23:43:41 +0200 Subject: [PATCH 1/3] prepare using multipe nameservers / basedomains currently lookup is from a dict with just the values from settings. --- nsupdate/main/dnstools.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index 17903fc..0249ddc 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -106,7 +106,7 @@ def update(fqdn, ipaddr, ttl=60): raise SameIpError -def query_ns(qname, rdtype): +def query_ns(qname, rdtype, origin=None): """ query a dns name from our master server @@ -116,11 +116,14 @@ def query_ns(qname, rdtype): :type rdtype: int or str :return: IP (as str) """ + origin, name = parse_name(qname, origin) + origin_str = str(origin) + nameserver = get_ns_info(origin_str)[0] resolver = dns.resolver.Resolver(configure=False) # we do not configure it from resolv.conf, but patch in the values we # want into the documented attributes: - resolver.nameservers = [settings.SERVER, ] - resolver.search = [dns.name.from_text(settings.BASEDOMAIN), ] + resolver.nameservers = [nameserver, ] + resolver.search = [] # was: [dns.name.from_text(settings.BASEDOMAIN), ] answer = resolver.query(qname, rdtype) return str(list(answer)[0]) @@ -145,6 +148,21 @@ def parse_name(fqdn, origin=None): return origin, rel_name +def get_ns_info(origin): + """ + Get the master nameserver for the zone, the key needed + to update the zone and the key algorithm used. + + :param origin: zone we are dealing with, must be with trailing dot + :return: master nameserver, update key + """ + # later look this up from Domain model: domain+'.': nameserver_ip, nameserver_update_key + ns_info = { + settings.BASEDOMAIN + '.': (settings.SERVER, settings.UPDATE_KEY, settings.UPDATE_ALGO), + } + return ns_info[origin] + + def update_ns(fqdn, rdtype='A', ipaddr=None, origin=None, action='upd', ttl=60): """ update our master server @@ -159,9 +177,11 @@ def update_ns(fqdn, rdtype='A', ipaddr=None, origin=None, action='upd', ttl=60): """ assert action in ['add', 'del', 'upd', ] origin, name = parse_name(fqdn, origin) + origin_str = str(origin) + nameserver, key, algo = get_ns_info(origin_str) upd = dns.update.Update(origin, - keyring=dns.tsigkeyring.from_text({settings.BASEDOMAIN + '.': settings.UPDATE_KEY}), - keyalgorithm=settings.UPDATE_ALGO) + keyring=dns.tsigkeyring.from_text({origin_str: key}), + keyalgorithm=algo) if action == 'add': assert ipaddr is not None upd.add(name, ttl, rdtype, ipaddr) @@ -170,5 +190,5 @@ def update_ns(fqdn, rdtype='A', ipaddr=None, origin=None, action='upd', ttl=60): elif action == 'upd': assert ipaddr is not None upd.replace(name, ttl, rdtype, ipaddr) - response = dns.query.tcp(upd, settings.SERVER) + response = dns.query.tcp(upd, nameserver) return response From 1729b6f35df3e9ac8dae54a708b9fd19abe991ae Mon Sep 17 00:00:00 2001 From: Arne Schauf Date: Mon, 30 Sep 2013 00:53:25 +0200 Subject: [PATCH 2/3] missing li --- .../templates/main/includes/tabbed_router_configuration.html | 1 + 1 file changed, 1 insertion(+) diff --git a/nsupdate/main/templates/main/includes/tabbed_router_configuration.html b/nsupdate/main/templates/main/includes/tabbed_router_configuration.html index cac7e9d..db1efef 100644 --- a/nsupdate/main/templates/main/includes/tabbed_router_configuration.html +++ b/nsupdate/main/templates/main/includes/tabbed_router_configuration.html @@ -34,6 +34,7 @@
  • "nochg <your ip>" IP accepted, but did not change since last update
  • Code 401: Authorization Required Incorrect or no authentication data
  • + For routers or other dyndns2 compatible clients:
      From dbe328c6a456c862922a538baa963fa5d18ecc62 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 30 Sep 2013 01:08:37 +0200 Subject: [PATCH 3/3] updated requirements.d/all.txt with pip freeze + manual cleanup --- requirements.d/all.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/requirements.d/all.txt b/requirements.d/all.txt index a88ba2f..aec9f12 100644 --- a/requirements.d/all.txt +++ b/requirements.d/all.txt @@ -1,4 +1,10 @@ -django==1.5.4 -south -django-bootstrap-form -django-registration +dnspython==1.11.1 +Django==1.5.4 +django-bootstrap-form==3.0 +django-debug-toolbar==0.9.4 +django-registration==1.0 +South==0.8.2 +pytest==2.3.5 +pytest-django==2.3.1 +pytest-pep8==1.0.4 +Sphinx==1.1.3