BIND 10 master, updated. 32007ad7c992f395895eb8f27343003cf4f94a20 [master] update xfrin to last API change
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Oct 10 13:18:25 UTC 2011
The branch, master has been updated
via 32007ad7c992f395895eb8f27343003cf4f94a20 (commit)
via d903fe92287645e9701890b0953bd84529665776 (commit)
via ecb3b76489bf838fe32030517e3c8b23000d59bd (commit)
via 64ba30803ae7a87f1c6bc21eb1a45c413fb6ce43 (commit)
via 6588fc2759e5901f61327f170bb9ce0ec3d0bfcd (commit)
via 35f2bd564e1e0311e3440f09bf81aac822d65a1c (commit)
via 0fd60764e65b270cafc1b3b573e5ac14b3c633d6 (commit)
via 1fe148279b130dc4c8c072ab3bd1006cdacfc9f6 (commit)
from df1298668ac3e758576b8b2bd6475c70cff7a57f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 32007ad7c992f395895eb8f27343003cf4f94a20
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Oct 10 15:18:12 2011 +0200
[master] update xfrin to last API change
-----------------------------------------------------------------------
Summary of changes:
src/bin/xfrin/xfrin.py.in | 7 ++-
src/lib/python/isc/datasrc/datasrc.cc | 83 ++++++++++++++-------
src/lib/python/isc/datasrc/finder_inc.cc | 22 ++++++
src/lib/python/isc/datasrc/finder_python.cc | 37 ++++++++--
src/lib/python/isc/datasrc/tests/datasrc_test.py | 33 +++++++++
src/lib/python/isc/datasrc/updater_python.cc | 45 ------------
6 files changed, 147 insertions(+), 80 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index dd75591..0effc40 100755
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -792,7 +792,12 @@ def process_xfrin(server, xfrin_recorder, zone_name, rrclass, db_file,
# this code will be much cleaner.
datasrc_client = None
if db_file is not None:
- datasrc_client = DataSourceClient(db_file)
+ # temporary hardcoded sqlite initialization. Once we decide on
+ # the config specification, we need to update this (TODO)
+ # this may depend on #1207, or any followup ticket created for #1207
+ datasrc_type = "sqlite3"
+ datasrc_config = "{ \"database_file\": \"" + db_file + "\"}"
+ datasrc_client = DataSourceClient(datasrc_type, datasrc_config)
# Create a TCP connection for the XFR session and perform the operation.
sock_map = {}
diff --git a/src/lib/python/isc/datasrc/datasrc.cc b/src/lib/python/isc/datasrc/datasrc.cc
index 4b0324a..7676104 100644
--- a/src/lib/python/isc/datasrc/datasrc.cc
+++ b/src/lib/python/isc/datasrc/datasrc.cc
@@ -77,14 +77,26 @@ initModulePart_DataSourceClient(PyObject* mod) {
}
Py_INCREF(&datasourceclient_type);
- addClassVariable(datasourceclient_type, "SUCCESS",
- Py_BuildValue("I", result::SUCCESS));
- addClassVariable(datasourceclient_type, "EXIST",
- Py_BuildValue("I", result::EXIST));
- addClassVariable(datasourceclient_type, "NOTFOUND",
- Py_BuildValue("I", result::NOTFOUND));
- addClassVariable(datasourceclient_type, "PARTIALMATCH",
- Py_BuildValue("I", result::PARTIALMATCH));
+ try {
+ installClassVariable(datasourceclient_type, "SUCCESS",
+ Py_BuildValue("I", result::SUCCESS));
+ installClassVariable(datasourceclient_type, "EXIST",
+ Py_BuildValue("I", result::EXIST));
+ installClassVariable(datasourceclient_type, "NOTFOUND",
+ Py_BuildValue("I", result::NOTFOUND));
+ installClassVariable(datasourceclient_type, "PARTIALMATCH",
+ Py_BuildValue("I", result::PARTIALMATCH));
+ } catch (const std::exception& ex) {
+ const std::string ex_what =
+ "Unexpected failure in DataSourceClient initialization: " +
+ std::string(ex.what());
+ PyErr_SetString(po_IscException, ex_what.c_str());
+ return (false);
+ } catch (...) {
+ PyErr_SetString(PyExc_SystemError,
+ "Unexpected failure in DataSourceClient initialization");
+ return (false);
+ }
return (true);
}
@@ -103,26 +115,41 @@ initModulePart_ZoneFinder(PyObject* mod) {
}
Py_INCREF(&zonefinder_type);
- addClassVariable(zonefinder_type, "SUCCESS",
- Py_BuildValue("I", ZoneFinder::SUCCESS));
- addClassVariable(zonefinder_type, "DELEGATION",
- Py_BuildValue("I", ZoneFinder::DELEGATION));
- addClassVariable(zonefinder_type, "NXDOMAIN",
- Py_BuildValue("I", ZoneFinder::NXDOMAIN));
- addClassVariable(zonefinder_type, "NXRRSET",
- Py_BuildValue("I", ZoneFinder::NXRRSET));
- addClassVariable(zonefinder_type, "CNAME",
- Py_BuildValue("I", ZoneFinder::CNAME));
- addClassVariable(zonefinder_type, "DNAME",
- Py_BuildValue("I", ZoneFinder::DNAME));
-
- addClassVariable(zonefinder_type, "FIND_DEFAULT",
- Py_BuildValue("I", ZoneFinder::FIND_DEFAULT));
- addClassVariable(zonefinder_type, "FIND_GLUE_OK",
- Py_BuildValue("I", ZoneFinder::FIND_GLUE_OK));
- addClassVariable(zonefinder_type, "FIND_DNSSEC",
- Py_BuildValue("I", ZoneFinder::FIND_DNSSEC));
-
+ try {
+ installClassVariable(zonefinder_type, "SUCCESS",
+ Py_BuildValue("I", ZoneFinder::SUCCESS));
+ installClassVariable(zonefinder_type, "DELEGATION",
+ Py_BuildValue("I", ZoneFinder::DELEGATION));
+ installClassVariable(zonefinder_type, "NXDOMAIN",
+ Py_BuildValue("I", ZoneFinder::NXDOMAIN));
+ installClassVariable(zonefinder_type, "NXRRSET",
+ Py_BuildValue("I", ZoneFinder::NXRRSET));
+ installClassVariable(zonefinder_type, "CNAME",
+ Py_BuildValue("I", ZoneFinder::CNAME));
+ installClassVariable(zonefinder_type, "DNAME",
+ Py_BuildValue("I", ZoneFinder::DNAME));
+ installClassVariable(zonefinder_type, "WILDCARD",
+ Py_BuildValue("I", ZoneFinder::WILDCARD));
+ installClassVariable(zonefinder_type, "WILDCARD_NXRRSET",
+ Py_BuildValue("I", ZoneFinder::WILDCARD_NXRRSET));
+
+ installClassVariable(zonefinder_type, "FIND_DEFAULT",
+ Py_BuildValue("I", ZoneFinder::FIND_DEFAULT));
+ installClassVariable(zonefinder_type, "FIND_GLUE_OK",
+ Py_BuildValue("I", ZoneFinder::FIND_GLUE_OK));
+ installClassVariable(zonefinder_type, "FIND_DNSSEC",
+ Py_BuildValue("I", ZoneFinder::FIND_DNSSEC));
+ } catch (const std::exception& ex) {
+ const std::string ex_what =
+ "Unexpected failure in ZoneFinder initialization: " +
+ std::string(ex.what());
+ PyErr_SetString(po_IscException, ex_what.c_str());
+ return (false);
+ } catch (...) {
+ PyErr_SetString(PyExc_SystemError,
+ "Unexpected failure in ZoneFinder initialization");
+ return (false);
+ }
return (true);
}
diff --git a/src/lib/python/isc/datasrc/finder_inc.cc b/src/lib/python/isc/datasrc/finder_inc.cc
index 2b47d02..bc8e62c 100644
--- a/src/lib/python/isc/datasrc/finder_inc.cc
+++ b/src/lib/python/isc/datasrc/finder_inc.cc
@@ -62,6 +62,10 @@ Search the zone for a given pair of domain name and RR type.\n\
and the code of SUCCESS will be returned.\n\
- If the search name matches a delegation point of DNAME, it returns\n\
the code of DNAME and that DNAME RR.\n\
+- If the result was synthesized by a wildcard match, it returns the\n\
+ code WILDCARD and the synthesized RRset\n\
+- If the query matched a wildcard name, but not its type, it returns the\n\
+ code WILDCARD_NXRRSET, and None\n\
- If the target is a list, all RRsets under the domain are inserted\n\
there and SUCCESS (or NXDOMAIN, in case of empty domain) is returned\n\
instead of normall processing. This is intended to handle ANY query.\n\
@@ -93,4 +97,22 @@ Parameters:\n\
Return Value(s): A tuple of a result code an a FindResult object enclosing\n\
the search result (see above).\n\
";
+
+const char* const ZoneFinder_find_previous_name_doc = "\
+find_previous_name(isc.dns.Name) -> isc.dns.Name\n\
+\n\
+Gets the previous name in the DNSSEC order. This can be used\n\
+to find the correct NSEC records for proving nonexistence\n\
+of domains.\n\
+\n\
+This method does not include under-zone-cut data (glue data).\n\
+\n\
+Raises isc.datasrc.NotImplemented in case the data source backend\n\
+doesn't support DNSSEC or there is no previous in the zone (NSEC\n\
+records might be missing in the DB, the queried name is less or\n\
+equal to the apex).\n\
+\n\
+Raises isc.datasrc.Error for low-level or internal datasource errors\n\
+(like broken connection to database, wrong data living there).\n\
+";
} // unnamed namespace
diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc
index 3a574ba..cb02724 100644
--- a/src/lib/python/isc/datasrc/finder_python.cc
+++ b/src/lib/python/isc/datasrc/finder_python.cc
@@ -169,6 +169,31 @@ ZoneFinder_find(PyObject* po_self, PyObject* args) {
return (isc_datasrc_internal::ZoneFinder_helper(self->cppobj.get(), args));
}
+PyObject*
+ZoneFinder_findPreviousName(PyObject* po_self, PyObject* args) {
+ s_ZoneFinder* const self = static_cast<s_ZoneFinder*>(po_self);
+ PyObject* name_obj;
+ if (PyArg_ParseTuple(args, "O!", &name_type, &name_obj)) {
+ try {
+ return (createNameObject(
+ self->cppobj->findPreviousName(PyName_ToName(name_obj))));
+ } catch (const isc::NotImplemented& nie) {
+ PyErr_SetString(getDataSourceException("NotImplemented"),
+ nie.what());
+ return (NULL);
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unexpected exception");
+ return (NULL);
+ }
+ } else {
+ return (NULL);
+ }
+}
+
// This list contains the actual set of functions we have in
// python. Each entry has
// 1. Python method name
@@ -176,12 +201,12 @@ ZoneFinder_find(PyObject* po_self, PyObject* args) {
// 3. Argument type
// 4. Documentation
PyMethodDef ZoneFinder_methods[] = {
- { "get_origin", reinterpret_cast<PyCFunction>(ZoneFinder_getOrigin),
- METH_NOARGS, ZoneFinder_getOrigin_doc },
- { "get_class", reinterpret_cast<PyCFunction>(ZoneFinder_getClass),
- METH_NOARGS, ZoneFinder_getClass_doc },
- { "find", reinterpret_cast<PyCFunction>(ZoneFinder_find), METH_VARARGS,
- ZoneFinder_find_doc },
+ { "get_origin", ZoneFinder_getOrigin, METH_NOARGS,
+ ZoneFinder_getOrigin_doc },
+ { "get_class", ZoneFinder_getClass, METH_NOARGS, ZoneFinder_getClass_doc },
+ { "find", ZoneFinder_find, METH_VARARGS, ZoneFinder_find_doc },
+ { "find_previous_name", ZoneFinder_findPreviousName, METH_VARARGS,
+ ZoneFinder_find_previous_name_doc },
{ NULL, NULL, 0, NULL }
};
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index 0e7e284..f65cfa0 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -246,6 +246,21 @@ class DataSrcClient(unittest.TestCase):
"cname-ext.example.com. 3600 IN CNAME www.sql1.example.com.\n",
rrset.to_text())
+ result, rrset = finder.find(isc.dns.Name("foo.wild.example.com"),
+ isc.dns.RRType.A(),
+ None,
+ finder.FIND_DEFAULT)
+ self.assertEqual(finder.WILDCARD, result)
+ self.assertEqual("foo.wild.example.com. 3600 IN A 192.0.2.255\n",
+ rrset.to_text())
+
+ result, rrset = finder.find(isc.dns.Name("foo.wild.example.com"),
+ isc.dns.RRType.TXT(),
+ None,
+ finder.FIND_DEFAULT)
+ self.assertEqual(finder.WILDCARD_NXRRSET, result)
+ self.assertEqual(None, rrset)
+
self.assertRaises(TypeError, finder.find,
"foo",
isc.dns.RRType.A(),
@@ -262,6 +277,24 @@ class DataSrcClient(unittest.TestCase):
None,
"foo")
+ def test_find_previous(self):
+ dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
+
+ result, finder = dsc.find_zone(isc.dns.Name("example.com"))
+ self.assertEqual(finder.SUCCESS, result)
+
+ prev = finder.find_previous_name(isc.dns.Name("bbb.example.com"))
+ self.assertEqual("example.com.", prev.to_text())
+
+ prev = finder.find_previous_name(isc.dns.Name("zzz.example.com"))
+ self.assertEqual("www.example.com.", prev.to_text())
+
+ prev = finder.find_previous_name(prev)
+ self.assertEqual("*.wild.example.com.", prev.to_text())
+
+ self.assertRaises(isc.datasrc.NotImplemented,
+ finder.find_previous_name,
+ isc.dns.Name("com"))
class DataSrcUpdater(unittest.TestCase):
diff --git a/src/lib/python/isc/datasrc/updater_python.cc b/src/lib/python/isc/datasrc/updater_python.cc
index 8060e8f..e447622 100644
--- a/src/lib/python/isc/datasrc/updater_python.cc
+++ b/src/lib/python/isc/datasrc/updater_python.cc
@@ -185,51 +185,6 @@ ZoneUpdater_find(PyObject* po_self, PyObject* args) {
args));
}
-PyObject*
-AZoneUpdater_find(PyObject* po_self, PyObject* args) {
- s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
- PyObject *name;
- PyObject *rrtype;
- PyObject *target;
- int options_int;
- if (PyArg_ParseTuple(args, "O!O!OI", &name_type, &name,
- &rrtype_type, &rrtype,
- &target, &options_int)) {
- try {
- ZoneFinder::FindOptions options =
- static_cast<ZoneFinder::FindOptions>(options_int);
- ZoneFinder::FindResult find_result(
- self->cppobj->getFinder().find(PyName_ToName(name),
- PyRRType_ToRRType(rrtype),
- NULL,
- options
- ));
- ZoneFinder::Result r = find_result.code;
- isc::dns::ConstRRsetPtr rrsp = find_result.rrset;
- if (rrsp) {
- // Use N instead of O so the refcount isn't increased twice
- return Py_BuildValue("IN", r, createRRsetObject(*rrsp));
- } else {
- return Py_BuildValue("IO", r, Py_None);
- }
- } catch (const DataSourceError& dse) {
- PyErr_SetString(getDataSourceException("Error"), dse.what());
- return (NULL);
- } catch (const std::exception& exc) {
- PyErr_SetString(getDataSourceException("Error"), exc.what());
- return (NULL);
- } catch (...) {
- PyErr_SetString(getDataSourceException("Error"),
- "Unexpected exception");
- return (NULL);
- }
- } else {
- return (NULL);
- }
- return Py_BuildValue("I", 1);
-}
-
-
// This list contains the actual set of functions we have in
// python. Each entry has
// 1. Python method name
More information about the bind10-changes
mailing list