BIND 10 trac1976, updated. f7de4b58b26e102920ce67597be8dfa8908f1a1e [1976] Let the auth server hold multiple lists
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 19 09:26:08 UTC 2012
The branch, trac1976 has been updated
via f7de4b58b26e102920ce67597be8dfa8908f1a1e (commit)
from 8fa13ec3115f58573bc2fd6213a99be1c8435462 (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 f7de4b58b26e102920ce67597be8dfa8908f1a1e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Jun 19 11:13:01 2012 +0200
[1976] Let the auth server hold multiple lists
There are multiple lists, for multiple classes.
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_srv.cc | 39 +++++++++++++++++++---------
src/bin/auth/auth_srv.h | 30 ++++++++++++++-------
src/bin/auth/tests/auth_srv_unittest.cc | 43 +++++++++++++++++++------------
3 files changed, 74 insertions(+), 38 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index c066429..dc53f3c 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -46,7 +46,6 @@
#include <datasrc/memory_datasrc.h>
#include <datasrc/static_datasrc.h>
#include <datasrc/sqlite3_datasrc.h>
-#include <datasrc/client_list.h>
#include <xfr/xfrout_client.h>
@@ -268,7 +267,7 @@ public:
const boost::shared_ptr<TSIGKeyRing>* keyring_;
/// The client list
- boost::shared_ptr<ClientList> client_list_;
+ map<RRClass, boost::shared_ptr<ClientList> > client_lists_;
/// Bind the ModuleSpec object in config_session_ with
/// isc:config::ModuleSpec::validateStatistics.
@@ -335,9 +334,6 @@ AuthSrvImpl::AuthSrvImpl(const bool use_cache,
// enable or disable the cache
cache_.setEnabled(use_cache);
-
- // Create the (yet empty) data source list
- client_list_.reset(new ConfigurableClientList());
}
AuthSrvImpl::~AuthSrvImpl() {
@@ -1033,14 +1029,33 @@ AuthSrv::setTSIGKeyRing(const boost::shared_ptr<TSIGKeyRing>* keyring) {
}
void
-AuthSrv::setClientList(const boost::shared_ptr<ClientList>& list) {
- if (!list) {
- isc_throw(BadValue, "The client list must not be NULL");
+AuthSrv::setClientList(const RRClass& rrclass,
+ const boost::shared_ptr<ClientList>& list) {
+ if (list) {
+ impl_->client_lists_[rrclass] = list;
+ } else {
+ impl_->client_lists_.erase(rrclass);
}
- impl_->client_list_ = list;
}
-const ClientList&
-AuthSrv::getClientList() const {
- return (*impl_->client_list_);
+boost::shared_ptr<const ClientList>
+AuthSrv::getClientList(const RRClass& rrclass) const {
+ const map<RRClass, boost::shared_ptr<ClientList> >::const_iterator
+ it(impl_->client_lists_.find(rrclass));
+ if (it == impl_->client_lists_.end()) {
+ return (boost::shared_ptr<const ClientList>());
+ } else {
+ return (it->second);
+ }
+}
+
+vector<RRClass>
+AuthSrv::getClientListClasses() const {
+ vector<RRClass> result;
+ for (map<RRClass, boost::shared_ptr<ClientList> >::const_iterator
+ it(impl_->client_lists_.begin()); it != impl_->client_lists_.end();
+ ++ it) {
+ result.push_back(it->first);
+ }
+ return (result);
}
diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h
index 59955b0..9be51a5 100644
--- a/src/bin/auth/auth_srv.h
+++ b/src/bin/auth/auth_srv.h
@@ -419,21 +419,31 @@ public:
void setTSIGKeyRing(const boost::shared_ptr<isc::dns::TSIGKeyRing>*
keyring);
- /// \brief Replaces the current client list with a different one.
+ /// \brief Sets the currently used list for data sources of given
+ /// class.
///
- /// Replaces the internally used client list with a new one.
- //
- /// \param list Shared pointer to the client list. Must not be NULL.
+ /// Replaces the internally used client list with a new one. Other
+ /// classes are not changed.
///
- /// \throw BadValue if it is NULL.
- void setClientList(const boost::shared_ptr<isc::datasrc::ClientList>&
+ /// \param rrclass The class to modify.
+ /// \param list Shared pointer to the client list. If it is NULL,
+ /// the list is removed instead.
+ void setClientList(const isc::dns::RRClass& rrclass,
+ const boost::shared_ptr<isc::datasrc::ClientList>&
list);
- /// \brief Returns the currently used client list.
+ /// \brief Returns the currently used client list for the class.
///
- /// Note that the server is constructed with an empty one, so this
- /// is always valid, even before calling setClientList.
- const isc::datasrc::ClientList& getClientList() const;
+ /// \param rrclass The class for which to get the list.
+ /// \return The list, or NULL if no list is set for the class.
+ boost::shared_ptr<const isc::datasrc::ClientList>
+ getClientList(const isc::dns::RRClass& rrclass) const;
+
+ /// \brief Returns a list of classes that have a client list.
+ ///
+ /// \return List of classes for which a non-NULL client list
+ /// has been set by setClientList.
+ std::vector<isc::dns::RRClass> getClientListClasses() const;
private:
AuthSrvImpl* impl_;
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index e6ebad4..bb2028b 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -1647,23 +1647,34 @@ TEST_F(AuthSrvTest, DDNSForwardClose) {
// Check the client list accessors
TEST_F(AuthSrvTest, clientList) {
- // The server is created with a working client list. So calling the
- // function will not crash.
- server.getClientList();
- // It is the correct type
- EXPECT_NO_THROW(dynamic_cast<const isc::datasrc::ConfigurableClientList&>(
- server.getClientList())) << "The client list has a wrong type";
- // Now prepare a new client list and replace it
- boost::shared_ptr<isc::datasrc::ConfigurableClientList>
+ // The lists don't exist. Therefore, the list of RRClasses is empty.
+ // We also have no IN list.
+ EXPECT_TRUE(server.getClientListClasses().empty());
+ EXPECT_EQ(boost::shared_ptr<const isc::datasrc::ClientList>(),
+ server.getClientList(RRClass::IN()));
+ // Put something in.
+ const boost::shared_ptr<isc::datasrc::ConfigurableClientList>
list(new isc::datasrc::ConfigurableClientList());
- server.setClientList(list);
- // And it is kept there.
- EXPECT_EQ(list.get(), &server.getClientList());
- // But putting NULL there would not work and the original is preserved
- EXPECT_THROW(server.setClientList(
- boost::shared_ptr<isc::datasrc::ConfigurableClientList>()),
- isc::BadValue);
- EXPECT_EQ(list.get(), &server.getClientList());
+ const boost::shared_ptr<isc::datasrc::ConfigurableClientList>
+ list2(new isc::datasrc::ConfigurableClientList());
+ server.setClientList(RRClass::IN(), list);
+ server.setClientList(RRClass::CH(), list2);
+ // There are two things in the list and they are IN and CH
+ vector<RRClass> classes(server.getClientListClasses());
+ ASSERT_EQ(2, classes.size());
+ EXPECT_EQ(RRClass::IN(), classes[0]);
+ EXPECT_EQ(RRClass::CH(), classes[1]);
+ // And the lists can be retrieved.
+ EXPECT_EQ(list, server.getClientList(RRClass::IN()));
+ EXPECT_EQ(list2, server.getClientList(RRClass::CH()));
+ // Remove one of them
+ server.setClientList(RRClass::CH(),
+ boost::shared_ptr<isc::datasrc::ConfigurableClientList>());
+ // This really got deleted, including the class.
+ classes = server.getClientListClasses();
+ ASSERT_EQ(1, classes.size());
+ EXPECT_EQ(RRClass::IN(), classes[0]);
+ EXPECT_EQ(list, server.getClientList(RRClass::IN()));
}
}
More information about the bind10-changes
mailing list