#include <errno.h>
#include <string>
-#include <map>
#include <set>
#include <sys/types.h>
#include <sys/stat.h>
#include <fstream>
#include <fcntl.h>
#include <sstream>
-#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include "pdns/dnsseckeeper.hh"
d_ctime=buf.st_ctime;
}
+bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd)
+{
+ ReadLock rl(&s_state_lock);
+ state_t::const_iterator iter = s_state.find(id);
+ if(iter == s_state.end())
+ return false;
+ *bbd=*iter;
+ return true;
+}
+
+bool Bind2Backend::safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd)
+{
+ ReadLock rl(&s_state_lock);
+ typedef state_t::index<NameTag>::type nameindex_t;
+ nameindex_t& nameindex = boost::multi_index::get<NameTag>(s_state);
+
+ nameindex_t::const_iterator iter = nameindex.find(name);
+ if(iter == nameindex.end())
+ return false;
+ *bbd=*iter;
+ return true;
+}
+
+void Bind2Backend::safePutBBDomainInfo(const BB2DomainInfo& bbd)
+{
+ WriteLock rl(&s_state_lock);
+ replacing_insert(s_state, bbd);
+}
+
void Bind2Backend::setNotified(uint32_t id, uint32_t serial)
{
BB2DomainInfo bbd;
return false;
}
-bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd)
-{
- ReadLock rl(&s_state_lock);
- state_t::const_iterator iter = s_state.find(id);
- if(iter == s_state.end())
- return false;
- *bbd=*iter;
- return true;
-}
-
-bool Bind2Backend::safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd)
-{
- ReadLock rl(&s_state_lock);
- typedef state_t::index<NameTag>::type nameindex_t;
- nameindex_t& nameindex = boost::multi_index::get<NameTag>(s_state);
-
- nameindex_t::const_iterator iter = nameindex.find(name);
- if(iter == nameindex.end())
- return false;
- *bbd=*iter;
- return true;
-}
-
-void Bind2Backend::safePutBBDomainInfo(const BB2DomainInfo& bbd)
-{
- WriteLock rl(&s_state_lock);
- replacing_insert(s_state, bbd);
-}
-
bool Bind2Backend::commitTransaction()
{
if(d_transaction_id < 0)
void Bind2Backend::alsoNotifies(const string &domain, set<string> *ips)
{
- ReadLock rl(&s_state_lock);
// combine global list with local list
for(set<string>::iterator i = this->alsoNotify.begin(); i != this->alsoNotify.end(); i++) {
(*ips).insert(*i);
}
+ ReadLock rl(&s_state_lock);
for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
if(pdns_iequals(i->d_name,domain)) {
for(set<string>::iterator it = i->d_also_notify.begin(); it != i->d_also_notify.end(); it++) {
}
}
-void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
+// only parses, does NOT add to s_state!
+void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
{
NSEC3PARAMRecordContent ns3pr;
bool nsec3zone=getNSEC3PARAM(bbd->d_name, &ns3pr);
else
hashed="";
}
- insert(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
+ insertRecord(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
}
fixupAuth(bbd->d_records.getWRITABLE());
/** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching
Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
-void Bind2Backend::insert(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
+void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
{
Bind2DNSRecord bdr;
shared_ptr<recordstorage_t> records = bb2.d_records.getWRITABLE();
string Bind2Backend::DLListRejectsHandler(const vector<string>&parts, Utility::pid_t ppid)
{
- ReadLock rl(&s_state_lock);
ostringstream ret;
+ ReadLock rl(&s_state_lock);
for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
if(!i->d_loaded)
ret<<i->d_name<<"\t"<<i->d_status<<endl;
-
}
return ret.str();
}
rr.qname=nt.first+"."+bbd.d_name+".";
if(nsec3zone)
hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname));
- insert(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
+ insertRecord(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
}
}
{
BB2DomainInfo bbold;
try {
-
if(!safeGetBBDomainInfo(id, &bbold))
return;
parseZoneFile(&bbold);
void getUpdatedMasters(vector<DomainInfo> *changedDomains);
bool getDomainInfo(const string &domain, DomainInfo &di);
time_t getCtime(const string &fname);
- // DNSSEC
+ // DNSSEC
virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after);
void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1);
bool list(const string &target, int id, bool include_disabled=false);
void setFresh(uint32_t domain_id);
void setNotified(uint32_t id, uint32_t serial);
bool startTransaction(const string &qname, int id);
- // bool Bind2Backend::stopTransaction(const string &qname, int id);
bool feedRecord(const DNSResourceRecord &r, string *ordername=0);
bool commitTransaction();
bool abortTransaction();
static pthread_rwlock_t s_state_lock;
void parseZoneFile(BB2DomainInfo *bbd);
- static void insert(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
+ void insertRecord(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
void rediscover(string *status=0);
bool isMaster(const string &name, const string &ip);
static string DLReloadNowHandler(const vector<string>&parts, Utility::pid_t ppid);
static string DLAddDomainHandler(const vector<string>&parts, Utility::pid_t ppid);
static void fixupAuth(shared_ptr<recordstorage_t> records);
- static void doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3PARAMRecordContent ns3pr);
+ void doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3PARAMRecordContent ns3pr);
void loadConfig(string *status=0);
static void nukeZoneRecords(BB2DomainInfo *bbd);
};