getNamemap()[make_pair(cl,ty)]=name;
}
+ static void unregist(uint16_t cl, uint16_t ty)
+ {
+ pair<uint16_t, uint16_t> key=make_pair(cl, ty);
+ getTypemap().erase(key);
+ getZmakermap().erase(key);
+ }
+
static uint16_t TypeToNumber(const string& name)
{
for(namemap_t::const_iterator i=getNamemap().begin(); i!=getNamemap().end();++i)
SRVRecordContent::report();
PTRRecordContent::report();
DNSRecordContent::regist(3, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT");
+ TXTRecordContent::report();
DNSRecordContent::regist(1, 255, 0, 0, "ANY");
}
CERTRecordContent::report();
NSECRecordContent::report();
OPTRecordContent::report();
- TXTRecordContent::report();
}
void reportAllTypes()
#define includeboilerplate(RNAME) RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr); \
RNAME##RecordContent(const string& zoneData); \
static void report(void); \
+ static void unreport(void); \
static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); \
static DNSRecordContent* make(const string& zonedata); \
string getZoneRepresentation() const; \
void RNAME##RecordContent::report(void) \
{ \
regist(1, RTYPE, &RNAME##RecordContent::make, &RNAME##RecordContent::make, #RNAME); \
+} \
+void RNAME##RecordContent::unreport(void) \
+{ \
+ unregist(1, RTYPE); \
} \
\
RNAME##RecordContent::RNAME##RecordContent(const string& zoneData) : DNSRecordContent(RTYPE) \
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>reload-zones</term>
+ <listitem>
+ <para>
+ Reload data about all authoritative and forward zones. The configuration file is also scanned
+ to see if the <command>auth-domain</command>, <command>forward-domain</command> and <command>export-etc-hosts</command>
+ statements have changed, and if so, these changes are incorporated.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term>top-remotes</term>
<listitem>
<para>
<warning>
<para>
- Ubunty Breezy ships a version of Boost that has problems with this command! Either refrain from
- using wipe-cache or download a more recent Boost into the PowerDNS source directory, as explained in the
- <filename>README</filename>
+ In PowerDNS versions 3.0.0 and 3.0.1 this command is slightly buggy and might cause your nameserver to crash if the first
+ query after wiping the cache is for the domain you just wiped.
</para>
</warning>
<warning>
-REC_CONTROL(1)\r
-==============\r
-bert hubert <bert.hubert@netherlabs.nl>\r
-v3.0, 19 April 2006\r
-\r
-NAME\r
-----\r
-rec_control - control pdns_recursor\r
-\r
-SYNOPSIS\r
---------\r
-'rec_control' [--help] [--socket-dir] [--socket-pid] command ..\r
-\r
-DESCRIPTION\r
------------\r
-rec_control(1) allows the operator to control a running instance\r
-of the pdns_recursor.\r
-\r
-The commands that can be passed to the recursor are described on\r
-http://doc.powerdns.com/rec-control.html\r
-
-EXAMPLES\r
---------\r
-\r
+REC_CONTROL(1)
+==============
+bert hubert <bert.hubert@netherlabs.nl>
+v3.0, 19 April 2006
+
+NAME
+----
+rec_control - control pdns_recursor
+
+SYNOPSIS
+--------
+'rec_control' [--help] [--socket-dir] [--socket-pid] command ..
+
+DESCRIPTION
+-----------
+rec_control(1) allows the operator to control a running instance
+of the pdns_recursor.
+
+The commands that can be passed to the recursor are described on
+http://doc.powerdns.com/rec-control.html
+
+EXAMPLES
+--------
+
To stop the recursor by hand, run:
# rec_control quit
-To dump the cache to disk, execute:\r
-\r
- # rec_control dump-cache /tmp/the-cache\r
-\r
-OPTIONS\r
--------\r
-\r
+To dump the cache to disk, execute:
+
+ # rec_control dump-cache /tmp/the-cache
+
+OPTIONS
+-------
+
--help::
provide this helpful message
--socket-dir::
Where the controlsocket will live
-\r
+
--socket-pid::
When running in SMP mode, pid of pdns_recursor to control
-\r
-COMMANDS\r
---------\r
-dump-cache filename::\r
- Dumps the entire cache to the filename mentioned. This file should\r
- not exist already, PowerDNS will refuse to overwrite it. While\r
- dumping, the recursor will not answer questions.\r
-\r
-get statistic::\r
- Retrieve a statistic. For items that can be queried, see\r
- http://doc.powerdns.com/recursor-stats.html\r
-\r
-ping::\r
- Check if server is alive.\r
-\r
-quit::\r
- Request shutdown of the recursor\r
-\r
-top-remotes::\r
- Shows the top-20 most active remote hosts. Statistics are over the\r
- last 'remotes-ringbuffer-entries' queries, which defaults to 0.\r
-\r
-wipe-cache domain0 [domain1]::\r
- Wipe entries from the cache. This is useful if, for example, an\r
- important server has a new IP address, but the TTL has not yet\r
- expired. Multiple domain names can be passed. Note that you must\r
- terminate a domain with a .! So to wipe powerdns.org, issue\r
- 'rec_control wipe-cache powerdns.org.'.\r
+
+COMMANDS
+--------
+dump-cache filename::
+ Dumps the entire cache to the filename mentioned. This file should
+ not exist already, PowerDNS will refuse to overwrite it. While
+ dumping, the recursor will not answer questions.
+
+get statistic::
+ Retrieve a statistic. For items that can be queried, see
+ http://doc.powerdns.com/recursor-stats.html
+
+ping::
+ Check if server is alive.
+
+quit::
+ Request shutdown of the recursor
+
+reload-zones::
+ Reload authoritative and forward zones. Retains current configuration
+ in case of errors.
+
+top-remotes::
+ Shows the top-20 most active remote hosts. Statistics are over the
+ last 'remotes-ringbuffer-entries' queries, which defaults to 0.
+
+wipe-cache domain0 [domain1]::
+ Wipe entries from the cache. This is useful if, for example, an
+ important server has a new IP address, but the TTL has not yet
+ expired. Multiple domain names can be passed. Note that you must
+ terminate a domain with a .! So to wipe powerdns.org, issue
+ 'rec_control wipe-cache powerdns.org.'.
Versions beyond 3.1 don't need the trailing dot. Consider not only
wiping 'www.domain.com.' but also 'domain.com.', as the cached nameservers
or target of CNAME may continue to be undesired.
-BUGS\r
-----\r
-None known. File new ones at http://wiki.powerdns.com.\r
-\r
-AUTHOR\r
-------\r
-Written by PowerDNS.COM BV, bert hubert, <bert.hubert@netherlabs.nl>\r
-\r
-RESOURCES\r
----------\r
-Website: http://wiki.powerdns.com, http://www.powerdns.com\r
-\r
-SEE ALSO\r
---------\r
-pdns_recursor(1)\r
-\r
-COPYING\r
--------\r
-Copyright (C) 2006 PowerDNS.COM BV. Free use of this software\r
-is granted under the terms of the GNU General Public License (GPL) version\r
-2.\r
-\r
+BUGS
+----
+None known. File new ones at http://wiki.powerdns.com.
+
+AUTHOR
+------
+Written by PowerDNS.COM BV, bert hubert, <bert.hubert@netherlabs.nl>
+
+RESOURCES
+---------
+Website: http://wiki.powerdns.com, http://www.powerdns.com
+
+SEE ALSO
+--------
+pdns_recursor(1)
+
+COPYING
+-------
+Copyright (C) 2006 PowerDNS.COM BV. Free use of this software
+is granted under the terms of the GNU General Public License (GPL) version
+2.
+
}
}
+
+void parseAuthAndForwards();
+
+string reloadAuthAndForwards()
+{
+ SyncRes::domainmap_t original=SyncRes::s_domainmap;
+
+ try {
+ L<<Logger::Warning<<"Reloading zones, purging data from cache"<<endl;
+
+ for(SyncRes::domainmap_t::const_iterator i = SyncRes::s_domainmap.begin(); i != SyncRes::s_domainmap.end(); ++i) {
+ for(SyncRes::AuthDomain::records_t::const_iterator j = i->second.d_records.begin(); j != i->second.d_records.end(); ++j)
+ RC.doWipeCache(j->qname);
+ }
+
+ string configname=::arg()["config-dir"]+"/recursor.conf";
+ cleanSlashes(configname);
+
+ if(!::arg().preParseFile(configname.c_str(), "forward-zones"))
+ L<<Logger::Warning<<"Unable to re-parse configuration file '"<<configname<<"'"<<endl;
+
+ ::arg().preParseFile(configname.c_str(), "auth-zones");
+ ::arg().preParseFile(configname.c_str(), "export-etc-hosts");
+ ::arg().preParseFile(configname.c_str(), "serve-rfc1918");
+
+ parseAuthAndForwards();
+
+ // purge again - new zones need to blank out the cache
+ for(SyncRes::domainmap_t::const_iterator i = SyncRes::s_domainmap.begin(); i != SyncRes::s_domainmap.end(); ++i) {
+ for(SyncRes::AuthDomain::records_t::const_iterator j = i->second.d_records.begin(); j != i->second.d_records.end(); ++j)
+ RC.doWipeCache(j->qname);
+ }
+
+ // this is pretty blunt
+ SyncRes::s_negcache.clear();
+ return "ok\n";
+ }
+ catch(exception& e) {
+ L<<Logger::Error<<"Had error reloading zones, keeping original data: "<<e.what()<<endl;
+ }
+ catch(AhuException& ae) {
+ L<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<ae.reason<<endl;
+ }
+ catch(...) {
+ L<<Logger::Error<<"Encountered unknown error reloading zones, keeping original data"<<endl;
+ }
+ SyncRes::s_domainmap.swap(original);
+ return "reloading failed, see log\n";
+}
+
void parseAuthAndForwards()
{
SyncRes::s_domainmap.clear(); // this makes us idempotent
+ TXTRecordContent::report();
+
typedef vector<string> parts_t;
parts_t parts;
for(int n=0; n < 2 ; ++n ) {
ZoneParserTNG zpt(headers.second, headers.first);
DNSResourceRecord rr;
while(zpt.get(rr)) {
+ try {
+ string tmp=DNSRR2String(rr);
+ rr=String2DNSRR(rr.qname, rr.qtype, tmp, 3600);
+ }
+ catch(exception &e) {
+ throw AhuException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"': "+e.what());
+ }
+ catch(...) {
+ throw AhuException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"'");
+ }
+
ad.d_records.insert(rr);
+
}
}
else {
if(cmd=="ping")
return "pong\n";
-
- return "Unknown command '"+cmd+"'\n";
+ if(cmd=="reload-zones") {
+ return reloadAuthAndForwards();
+ }
+
+ return "Unknown command '"+cmd+"'\n";
}
string d_cachedqname;
bool d_cachecachevalid;
};
-
+string DNSRR2String(const DNSResourceRecord& rr);
+DNSResourceRecord String2DNSRR(const string& qname, const QType& qt, const string& serial, uint32_t ttd);
#endif
return res;
}
+
+std::string reloadAuthAndForwards();
#endif