Commit 13a3fcfa authored by Jelte Jansen's avatar Jelte Jansen

[trac471] set listen on to localhost if nothing is set

(on the initial configuration)

also added a special case for the 'version' config element in the configuration checker (this caused the configuration to be rejected, while for the purposes of validation it should either be ignored or cause a different validation path)
parent f1bb311e
......@@ -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);
......@@ -573,6 +584,11 @@ Resolver::updateConfig(ConstElementPtr config) {
}
}
void
Resolver::setConfigured() {
configured_ = true;
}
void
Resolver::setForwardAddresses(const AddressList& addresses)
{
......
......@@ -118,6 +118,13 @@ public:
/// \brief Return pointer to the Checkin callback function
asiolink::SimpleCallback* getCheckinProvider() { return (checkin_); }
/**
* \brief Tell the Resolver that is should has already been
* configured (used by updateConfig() and tests, so
* that it will only set some defaults the first time
*/
void setConfigured();
/**
* \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,9 +372,14 @@ 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) {
found = true;
} else {
BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
if (cur_spec_el->get("item_name")->stringValue().compare(m.first) == 0) {
found = true;
}
}
}
if (!found) {
......
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