Commit 1960b5be authored by Jelte Jansen's avatar Jelte Jansen
Browse files

Merge branch 'trac471'

parents f0b271b9 87f24fca
......@@ -333,7 +333,8 @@ Resolver::Resolver() :
impl_(new ResolverImpl()),
checkin_(new ConfigCheck(this)),
dns_lookup_(new MessageLookup(this)),
dns_answer_(new MessageAnswer)
dns_answer_(new MessageAnswer),
configured_(false)
{}
Resolver::~Resolver() {
......@@ -548,6 +549,15 @@ Resolver::updateConfig(ConstElementPtr config) {
if (listenAddressesE) {
setListenAddresses(listenAddresses);
need_query_restart = true;
} else {
if (!configured_) {
// TODO: ModuleSpec needs getDefault()
AddressList initial_addresses;
initial_addresses.push_back(AddressPair("127.0.0.1", 53));
initial_addresses.push_back(AddressPair("::1", 53));
setListenAddresses(initial_addresses);
need_query_restart = true;
}
}
if (forwardAddressesE) {
setForwardAddresses(forwardAddresses);
......@@ -566,6 +576,7 @@ Resolver::updateConfig(ConstElementPtr config) {
impl_->queryShutdown();
impl_->querySetup(*dnss_, *nsas_, *cache_);
}
setConfigured();
return (isc::config::createAnswer());
} catch (const isc::Exception& error) {
dlog(string("error in config: ") + error.what(),true);
......
......@@ -118,6 +118,13 @@ public:
/// \brief Return pointer to the Checkin callback function
asiolink::SimpleCallback* getCheckinProvider() { return (checkin_); }
/**
* \brief Tell the Resolver that is has already been configured
* so that it will only set some defaults the first time
* (used by updateConfig() and tests)
*/
void setConfigured() { configured_ = true; };
/**
* \brief Specify the list of upstream servers.
*
......@@ -229,6 +236,10 @@ private:
asiolink::DNSAnswer* dns_answer_;
isc::nsas::NameserverAddressStore* nsas_;
isc::cache::ResolverCache* cache_;
// This value is initally false, and will be set to true
// when the initial configuration is done (updateConfig
// should act a tiny bit different on the very first call)
bool configured_;
};
#endif // __RESOLVER_H
......
......@@ -42,6 +42,7 @@ class ResolverConfig : public ::testing::Test {
dnss(ios, NULL, NULL, NULL)
{
server.setDNSService(dnss);
server.setConfigured();
}
void invalidTest(const string &JSON, const string& name);
};
......
......@@ -372,15 +372,18 @@ ModuleSpec::validateSpecList(ConstElementPtr spec, ConstElementPtr data,
BOOST_FOREACH(maptype m, data->mapValue()) {
bool found = false;
BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
if (cur_spec_el->get("item_name")->stringValue().compare(m.first) == 0) {
found = true;
// Ignore 'version' as a config element
if (m.first.compare("version") != 0) {
BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
if (cur_spec_el->get("item_name")->stringValue().compare(m.first) == 0) {
found = true;
}
}
}
if (!found) {
validated = false;
if (errors) {
errors->add(Element::create("Unknown item " + m.first));
if (!found) {
validated = false;
if (errors) {
errors->add(Element::create("Unknown item " + m.first));
}
}
}
}
......
......@@ -162,6 +162,10 @@ TEST(ModuleSpec, DataValidation) {
EXPECT_FALSE(dataTest(dd, "data22_8.data"));
EXPECT_FALSE(dataTest(dd, "data22_9.data"));
// Test if "version" is allowed in config data
// (same data as 22_7, but added "version")
EXPECT_TRUE(dataTest(dd, "data22_10.data"));
ElementPtr errors = Element::createList();
EXPECT_FALSE(dataTestWithErrors(dd, "data22_8.data", errors));
EXPECT_EQ("[ \"Type mismatch\" ]", errors->str());
......
{
"version": 123,
"value1": 1,
"value2": 2.3,
"value3": true,
"value4": "foo",
"value5": [ 1, 2, 3 ],
"value6": { "v61": "bar", "v62": true },
"value8": [ { "a": "d" }, { "a": "e" } ],
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment