[asterisk-commits] file: testsuite/asterisk/trunk r6467 - in /asterisk/trunk: lib/python/asteris...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 26 06:23:21 CST 2015
Author: file
Date: Thu Feb 26 06:23:07 2015
New Revision: 6467
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=6467
Log:
testsuite: Add DNS server pluggable module.
This change adds a pluggable module to the testsuite which
runs a DNS server using twisted-names. This is an authoritative
DNS server that responds with records which are specified in a
Python style zone file or a BIND style zone file. The DNS server
lives for the lifetime of the test. This is useful since it removes
any reliance on an external DNS server and reduces the work required
to test DNS.
Review: https://reviewboard.asterisk.org/r/4451/
Added:
asterisk/trunk/lib/python/asterisk/dns_server.py (with props)
asterisk/trunk/sample-yaml/dns-server-config.yaml (with props)
Added: asterisk/trunk/lib/python/asterisk/dns_server.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/dns_server.py?view=auto&rev=6467
==============================================================================
--- asterisk/trunk/lib/python/asterisk/dns_server.py (added)
+++ asterisk/trunk/lib/python/asterisk/dns_server.py Thu Feb 26 06:23:07 2015
@@ -1,0 +1,55 @@
+#!/usr/bin/env python
+""" Pluggable module for running an isolated configured DNS server
+
+Copyright (C) 2015, Digium, Inc.
+Joshua Colp <jcolp at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import logging
+
+from twisted.internet import reactor
+from twisted.names import server, authority, dns
+
+LOGGER = logging.getLogger(__name__)
+
+
+class DNSServer(object):
+ """Start a local DNS server instance using twisted-names with provided zones.
+
+ Configuration options include:
+ port: The port to listen for DNS requests on.
+ defaults to 10053.
+ python-zones: An array of Python zone files.
+ bind-zones: An array of BIND zone files.
+
+ Python zone files are defined using python source code. An example is present
+ at https://twistedmatrix.com/documents/current/names/howto/names.html
+
+ BIND zone files are defined in BIND-syntax style.
+ """
+ def __init__(self, config, test_obj):
+ """Initialize and configure the DNS object."""
+
+ zones = []
+ port = config.get('port', 10053)
+ pyzones = config.get('python-zones', [])
+ bindzones = config.get('bind-zones', [])
+
+ for pyzone in pyzones:
+ zones.append(authority.PySourceAuthority('%s/dns_zones/%s' % (test_obj.test_name, pyzone)))
+ LOGGER.info("Added Python zone file %s" % (pyzone))
+
+ for bindzone in bindzones:
+ zones.append(authority.BindAuthority('%s/dns_zones/%s' % (test_obj.test_name, bindzone)))
+ LOGGER.info("Added BIND zone file %s" % (bindzone))
+
+ factory = server.DNSServerFactory(authorities=zones)
+ protocol = dns.DNSDatagramProtocol(controller=factory)
+
+ reactor.listenUDP(port, protocol)
+ reactor.listenTCP(port, factory)
+
+ LOGGER.info("Started DNS server (UDP and TCP) on port %d" % (port))
Propchange: asterisk/trunk/lib/python/asterisk/dns_server.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/lib/python/asterisk/dns_server.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/lib/python/asterisk/dns_server.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/sample-yaml/dns-server-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/sample-yaml/dns-server-config.yaml?view=auto&rev=6467
==============================================================================
--- asterisk/trunk/sample-yaml/dns-server-config.yaml (added)
+++ asterisk/trunk/sample-yaml/dns-server-config.yaml Thu Feb 26 06:23:07 2015
@@ -1,0 +1,18 @@
+# Configuration sample for the DNS server pluggable module. The module will
+# start a local authoritative DNS server for provided zone files. This test
+# is useful for testing DNS related operations.
+
+dns-server-config:
+
+ # The port to listen on for DNS requests.
+ port: 10053
+
+ # Python style zone files.
+ python-zones:
+ -
+ example-domain.com
+
+ # BIND style zone files.
+ bind-zones:
+ -
+ another-example-domain.com
Propchange: asterisk/trunk/sample-yaml/dns-server-config.yaml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/sample-yaml/dns-server-config.yaml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/sample-yaml/dns-server-config.yaml
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list