//! configure how often this domain should be checked for changes (on disk)
void setCheckInterval(time_t seconds);
- string d_name; //!< actual name of the domain
- bool d_loaded; //!< if a domain is loaded
- string d_status; //!< message describing status of a domain, for human consumption
- mutable bool d_checknow; //!< if this domain has been flagged for a check
- time_t d_ctime; //!< last known ctime of the file on disk
+ DNSName d_name; //!< actual name of the domain
string d_filename; //!< full absolute filename of the zone on disk
- unsigned int d_id; //!< internal id of the domain
- time_t d_lastcheck; //!< last time domain was checked for freshness
+ string d_status; //!< message describing status of a domain, for human consumption
vector<string> d_masters; //!< IP address of the master of this domain
set<string> d_also_notify; //!< IP list of hosts to also notify
-
+ LookButDontTouch<recordstorage_t> d_records; //!< the actual records belonging to this domain
+ time_t d_ctime; //!< last known ctime of the file on disk
+ time_t d_lastcheck; //!< last time domain was checked for freshness
uint32_t d_lastnotified; //!< Last serial number we notified our slaves of
+ unsigned int d_id; //!< internal id of the domain
+ mutable bool d_checknow; //!< if this domain has been flagged for a check
+ bool d_loaded; //!< if a domain is loaded
- LookButDontTouch<recordstorage_t> d_records; //!< the actual records belonging to this domain
private:
time_t getCtime();
time_t d_checkinterval;
void release(SSqlStatement**);
static bool safeGetBBDomainInfo(int id, BB2DomainInfo* bbd);
static void safePutBBDomainInfo(const BB2DomainInfo& bbd);
- static bool safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd);
- static bool safeRemoveBBDomainInfo(const std::string& name);
+ static bool safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd);
+ static bool safeRemoveBBDomainInfo(const DNSName& name);
bool GetBBDomainInfo(int id, BB2DomainInfo** bbd);
shared_ptr<SSQLite3> d_dnssecdb;
- bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p);
- bool d_hybrid;
+ bool getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* ns3p);
class handle
{
public:
recordstorage_t::const_iterator d_iter, d_end_iter;
recordstorage_t::const_iterator d_qname_iter;
recordstorage_t::const_iterator d_qname_end;
- string qname;
- string domain;
-
- bool d_list;
- int id;
-
+ DNSName qname;
+ DNSName domain;
+
+ int id;
QType qtype;
+ bool d_list;
bool mustlog;
private:
handle(const handle &);
};
- static int s_first; //!< this is raised on construction to prevent multiple instances of us being generated
- static bool s_ignore_broken_records;
+ SSqlStatement* d_getAllDomainMetadataQuery_stmt;
+ SSqlStatement* d_getDomainMetadataQuery_stmt;
+ SSqlStatement* d_deleteDomainMetadataQuery_stmt;
+ SSqlStatement* d_insertDomainMetadataQuery_stmt;
+ SSqlStatement* d_getDomainKeysQuery_stmt;
+ SSqlStatement* d_deleteDomainKeyQuery_stmt;
+ SSqlStatement* d_insertDomainKeyQuery_stmt;
+ SSqlStatement* d_activateDomainKeyQuery_stmt;
+ SSqlStatement* d_deactivateDomainKeyQuery_stmt;
+ SSqlStatement* d_getTSIGKeyQuery_stmt;
+ SSqlStatement* d_setTSIGKeyQuery_stmt;
+ SSqlStatement* d_deleteTSIGKeyQuery_stmt;
+ SSqlStatement* d_getTSIGKeysQuery_stmt;
- static string s_binddirectory; //!< this is used to store the 'directory' setting of the bind configuration
+ string d_transaction_tmpname;
string d_logprefix;
-
set<string> alsoNotify; //!< this is used to store the also-notify list of interested peers.
-
- BB2DomainInfo createDomainEntry(const DNSName& domain, const string &filename); //!< does not insert in s_state
-
- int d_transaction_id;
- string d_transaction_tmpname;
-
ofstream *d_of;
handle d_handle;
- BB2DomainInfo createDomainEntry(const string &domain, const string &filename); //!< does not insert in s_state
+ static string s_binddirectory; //!< this is used to store the 'directory' setting of the bind configuration
+ static int s_first; //!< this is raised on construction to prevent multiple instances of us being generated
+ int d_transaction_id;
+ static bool s_ignore_broken_records;
+ bool d_hybrid;
+
++ BB2DomainInfo createDomainEntry(const DNSName& domain, const string &filename); //!< does not insert in s_state
void queueReloadAndStore(unsigned int id);
- bool findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const std::string& qname, std::string& unhashed, std::string& before, std::string& after);
+ bool findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const DNSName& qname, DNSName& unhashed, string& before, string& after);
void reload();
static string DLDomStatusHandler(const vector<string>&parts, Utility::pid_t ppid);
static string DLListRejectsHandler(const vector<string>&parts, Utility::pid_t ppid);
set<string> & getAlsoNotify() { return this->alsoNotify; }
private:
string d_dir;
- typedef map<string,string> zonedomain_t;
- bool d_verbose;
+ typedef map<DNSName,string> zonedomain_t;
set<string> alsoNotify;
vector<BindDomainInfo> d_zonedomains;
+ bool d_verbose;
};
#endif /* BINDPARSER_HH */
private:
struct NotificationRequest
{
- string domain;
+ DNSName domain;
string ip;
+ time_t next;
int attempts;
uint16_t id;
- time_t next;
};
typedef std::list<NotificationRequest> d_nqueue_t;
struct SOAData
{
- SOAData() : ttl(0), serial(0), refresh(0), retry(0), expire(0), domain_id(-1), db(0), scopeMask(0) {};
+ SOAData() : ttl(0), serial(0), refresh(0), retry(0), expire(0), db(0), domain_id(-1), scopeMask(0) {};
- string qname;
- string nameserver;
- string hostmaster;
+ DNSName qname;
+ DNSName nameserver;
+ DNSName hostmaster;
uint32_t ttl;
uint32_t serial;
uint32_t refresh;
string getZoneRepresentation() const;
// data
- string qname; //!< the name of this record, for example: www.powerdns.com
- string wildcardname;
-
- QType qtype; //!< qtype of this record, ie A, CNAME, MX etc
- uint16_t qclass; //!< class of this record
+ DNSName qname; //!< the name of this record, for example: www.powerdns.com
+ DNSName wildcardname;
string content; //!< what this record points to. Example: 10.1.2.3
+
+ // Aligned on 8-byte boundries on systems where time_t is 8 bytes and int
+ // is 4 bytes, aka modern linux on x86_64
+ time_t last_modified; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
+
uint32_t ttl; //!< Time To Live of this record
uint32_t signttl; //!< If non-zero, use this TTL as original TTL in the RRSIG
+
int domain_id; //!< If a backend implements this, the domain_id of the zone this record is in
- time_t last_modified; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
- enum Place {QUESTION=0, ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //!< Type describing the positioning of a DNSResourceRecord within, say, a DNSPacket
- Place d_place; //!< This specifies where a record goes within the packet
+ QType qtype; //!< qtype of this record, ie A, CNAME, MX etc
+ uint16_t qclass; //!< class of this record
+ Place d_place; //!< This specifies where a record goes within the packet
+ uint8_t scopeMask;
bool auth;
bool disabled;
- uint8_t scopeMask;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
struct DomainInfo
{
DomainInfo() : backend(0) {}
- uint32_t id;
+
- string zone;
+ DNSName zone;
- vector<string> masters;
- uint32_t notified_serial;
- uint32_t serial;
time_t last_check;
string account;
- enum DomainKind { Master, Slave, Native } kind;
+ vector<string> masters;
DNSBackend *backend;
+
+ uint32_t id;
+ uint32_t notified_serial;
+
+ uint32_t serial;
+ enum DomainKind : uint8_t { Master, Slave, Native } kind;
bool operator<(const DomainInfo& rhs) const
{
virtual void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) { }
/** Determines if we are authoritative for a zone, and at what level */
- virtual bool getAuth(DNSPacket *p, SOAData *sd, const string &target, const int best_match_len);
+ virtual bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target, const int best_match_len);
struct KeyData {
+ std::string content;
unsigned int id;
unsigned int flags;
bool active;
- std::string content;
};
- virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys) { return false;}
- virtual bool removeDomainKey(const string& name, unsigned int id) { return false; }
- virtual int addDomainKey(const string& name, const KeyData& key){ return -1; }
- virtual bool activateDomainKey(const string& name, unsigned int id) { return false; }
- virtual bool deactivateDomainKey(const string& name, unsigned int id) { return false; }
+ virtual bool getDomainKeys(const DNSName& name, unsigned int kind, std::vector<KeyData>& keys) { return false;}
+ virtual bool removeDomainKey(const DNSName& name, unsigned int id) { return false; }
+ virtual int addDomainKey(const DNSName& name, const KeyData& key){ return -1; }
+ virtual bool activateDomainKey(const DNSName& name, unsigned int id) { return false; }
+ virtual bool deactivateDomainKey(const DNSName& name, unsigned int id) { return false; }
- virtual bool getTSIGKey(const string& name, string* algorithm, string* content) { return false; }
- virtual bool setTSIGKey(const string& name, const string& algorithm, const string& content) { return false; }
- virtual bool deleteTSIGKey(const string& name) { return false; }
+ virtual bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content) { return false; }
+ virtual bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) { return false; }
+ virtual bool deleteTSIGKey(const DNSName& name) { return false; }
virtual bool getTSIGKeys(std::vector< struct TSIGKey > &keys) { return false; }
- virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after)
+ virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const string& qname, DNSName& unhashed, string& before, string& after)
{
std::cerr<<"Default beforeAndAfterAbsolute called!"<<std::endl;
abort();
bool hasEDNS();
//////// DATA !
- string qdomain; //!< qname of the question 4 - unsure how this is used
- string qdomainwild; //!< wildcard matched by qname, used by LuaPolicyEngine
- string qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
- ComboAddress d_remote;
- uint16_t qclass; //!< class of the question - should always be INternet 2
- struct dnsheader d; //!< dnsheader at the start of the databuffer 12
-
- QType qtype; //!< type of the question 8
-
+ DNSName qdomain; //!< qname of the question 4 - unsure how this is used
+ DNSName qdomainwild; //!< wildcard matched by qname, used by LuaPolicyEngine
+ DNSName qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
+ string d_peer_principal;
+ struct dnsheader d; //!< dnsheader at the start of the databuffer 12
+
+ uint16_t qclass; //!< class of the question - should always be INternet 2
+ QType qtype; //!< type of the question 2
+
+ TSIGRecordContent d_trc; //72
+
+ ComboAddress d_remote; //28
+ TSIGHashEnum d_tsig_algo; //4
+
bool d_tcp;
bool d_dnssecOk;
bool d_havetsig;
- bool getTSIGDetails(TSIGRecordContent* tr, string* keyname, string* message) const;
- void setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly=false);
- bool getTKEYRecord(TKEYRecordContent* tr, string* keyname) const;
- string d_peer_principal;
- TSIGHashEnum d_tsig_algo;
-
+ bool getTSIGDetails(TSIGRecordContent* tr, DNSName* keyname, string* message) const;
+ void setTSIGDetails(const TSIGRecordContent& tr, const DNSName& keyname, const string& secret, const string& previous, bool timersonly=false);
+ bool getTKEYRecord(TKEYRecordContent* tr, DNSName* keyname) const;
vector<DNSResourceRecord>& getRRS() { return d_rrs; }
- TSIGRecordContent d_trc;
static bool s_doEDNSSubnetProcessing;
- static uint16_t s_udpTruncationThreshold;
+ static uint16_t s_udpTruncationThreshold; //2
private:
void pasteQ(const char *question, int length); //!< set the question of this packet, useful for crafting replies
bool d_wrapped; // 1
- bool d_compress; // 1
- uint16_t d_qlen; // length of the question (including class & type) in this packet 2
-
int d_socket; // 4
- string d_rawpacket; // this is where everything lives 4
- int d_maxreplylen;
- string d_ednsping;
- bool d_wantsnsid;
- bool d_haveednssubnet;
- bool d_haveednssection;
- EDNSSubnetOpts d_eso;
string d_tsigsecret;
- string d_tsigkeyname;
+ DNSName d_tsigkeyname;
string d_tsigprevious;
- bool d_tsigtimersonly;
- vector<DNSResourceRecord> d_rrs; // 4
+ vector<DNSResourceRecord> d_rrs; // 8
+ string d_rawpacket; // this is where everything lives 8
+ string d_ednsping;
+ EDNSSubnetOpts d_eso;
+
+ int d_maxreplylen;
+ uint16_t d_qlen; // length of the question (including class & type) in this packet 2
+
+ bool d_compress; // 1
+ bool d_tsigtimersonly;
+ bool d_wantsnsid;
+ bool d_haveednssubnet;
+ bool d_haveednssection;
};
struct DNSRecord
{
- std::string d_label;
+ DNSName d_label; //FIXME rename
+ std::shared_ptr<DNSRecordContent> d_content;
uint16_t d_type;
uint16_t d_class;
uint32_t d_ttl;
init(packet, len);
}
- string d_qname;
- dnsheader d_header;
+ DNSName d_qname;
uint16_t d_qclass, d_qtype;
//uint8_t d_rcode;
+ dnsheader d_header;
typedef vector<pair<DNSRecord, uint16_t > > answers_t;
}
bool recurseFor(DNSPacket* p);
private:
- NetmaskGroup d_ng;
- int d_sock;
- AtomicCounter* d_resanswers;
- AtomicCounter* d_udpanswers;
- AtomicCounter* d_resquestions;
- pthread_mutex_t d_lock;
- uint16_t d_xor;
- int getID_locked();
struct ConntrackEntry
{
- uint16_t id;
- ComboAddress remote;
- int outsock;
time_t created;
- string qname;
+ boost::optional<ComboAddress> anyLocal;
- uint16_t qtype;
+ DNSName qname;
DNSPacket* complete;
- string aname;
+ DNSName aname;
- boost::optional<ComboAddress> anyLocal;
+ ComboAddress remote;
+ uint16_t id;
+ uint16_t qtype;
+ int outsock;
};
typedef map<int,ConntrackEntry> map_t;
)
- SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target)
+ SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const DNSName& target)
-: DNSRecordContent(QType::SRV), d_preference(preference), d_weight(weight), d_port(port), d_target(target)
+: DNSRecordContent(QType::SRV), d_weight(weight), d_port(port), d_target(target), d_preference(preference)
{}
boilerplate_conv(SRV, QType::SRV,
includeboilerplate(IPSECKEY)
private:
- uint8_t d_preference, d_gatewaytype, d_algorithm;
+ uint32_t d_ip4;
- string d_gateway, d_publickey;
+ DNSName d_gateway;
+ string d_publickey;
- uint32_t d_ip4;
string d_ip6;
+ uint8_t d_preference, d_gatewaytype, d_algorithm;
};
class DHCIDRecordContent : public DNSRecordContent
includeboilerplate(SRV)
- uint16_t d_preference, d_weight, d_port;
+ uint16_t d_weight, d_port;
- string d_target;
+ DNSName d_target;
+ uint16_t d_preference;
};
class TSIGRecordContent : public DNSRecordContent
includeboilerplate(TSIG)
TSIGRecordContent() : DNSRecordContent(QType::TSIG) {}
- DNSName d_algoName;
- uint64_t d_time; // 48 bits
+ uint16_t d_origID;
uint16_t d_fudge;
- // uint16_t d_macSize;
+
- string d_algoName;
++ DNSName d_algoName;
string d_mac;
- uint16_t d_origID;
+ string d_otherData;
+ uint64_t d_time;
+ // uint16_t d_macSize;
uint16_t d_eRcode;
// uint16_t d_otherLen
- string d_otherData;
};
includeboilerplate(RRSIG)
uint16_t d_type;
- uint8_t d_algorithm, d_labels;
- uint32_t d_originalttl, d_sigexpire, d_siginception;
uint16_t d_tag;
- string d_signer, d_signature;
+ DNSName d_signer;
+ string d_signature;
+ uint32_t d_originalttl, d_sigexpire, d_siginception;
+ uint8_t d_algorithm, d_labels;
};
-
-
//namespace {
struct soatimes
{
{
public:
includeboilerplate(SOA)
- SOARecordContent(const string& mname, const string& rname, const struct soatimes& st);
+ SOARecordContent(const DNSName& mname, const DNSName& rname, const struct soatimes& st);
- string d_mname;
- string d_rname;
+ struct soatimes d_st;
- struct soatimes d_st;
+ DNSName d_mname;
+ DNSName d_rname;
};
class NSECRecordContent : public DNSRecordContent
includeboilerplate(TKEY)
// storage for the bytes
- DNSName d_algo;
+ uint16_t d_othersize;
+ uint16_t d_mode;
uint32_t d_inception;
uint32_t d_expiration;
- uint16_t d_mode;
- uint16_t d_error;
- uint16_t d_keysize;
+
- string d_algo;
++ DNSName d_algo;
string d_key;
- uint16_t d_othersize;
string d_other;
+
+ uint16_t d_error;
+ uint16_t d_keysize;
private:
};
return d_ttd;
}
- string d_domain;
+ DNSName d_domain;
- unsigned int d_ttd;
mutable keys_t d_keys;
+ unsigned int d_ttd;
};
struct METACacheEntry
return d_ttd;
}
- string d_domain;
+ DNSName d_domain;
+ mutable std::string d_key, d_value;
unsigned int d_ttd;
- mutable std::string d_key, d_value;
};
}
}
- DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& lmap, const string& label)
+ /* FIXME400: check that this beats a map */
-DNSPacketWriter::nmap_t::iterator find(DNSPacketWriter::nmap_t& nmap, const DNSName& name)
++DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& nmap, const DNSName& name)
{
- DNSPacketWriter::nmap_t::iterator ret;
+ DNSPacketWriter::lmap_t::iterator ret;
- for(ret=lmap.begin(); ret != lmap.end(); ++ret)
- if(pdns_iequals(ret->first ,label))
+ for(ret=nmap.begin(); ret != nmap.end(); ++ret)
+ if(pdns_iequals(ret->first ,name))
break;
return ret;
}
unsigned int startRecordSize=d_record.size();
unsigned int startPos;
- for(labelparts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) {
- if(deDot)
- chopped.assign(label.c_str() + i->first, labellen - i->first -1);
- else
- chopped.assign(label.c_str() + i->first);
+ DNSName towrite = name;
+ /* FIXME400: if we are not compressing, there is no reason to work per-label */
+ for(auto &label: parts) {
+ if(d_lowerCase) label=toLower(label);
+ //cerr<<"xfrName labelpart ["<<label<<"], left to write ["<<towrite.toString()<<"]"<<endl;
- lmap_t::iterator li=d_labelmap.end();
- auto li=d_namemap.end();
++ auto li=d_labelmap.end();
// see if we've written out this domain before
- // cerr<<"Searching for compression pointer to '"<<chopped<<"', "<<d_labelmap.size()<<" cmp-records"<<endl;
- if(compress && (li=find(d_labelmap, chopped))!=d_labelmap.end()) {
- // cerr<<"\tFound a compression pointer to '"<<chopped<<"': "<<li->second<<endl;
- if (d_record.size() - startRecordSize + chopped.size() > 253) // chopped does not include a length octet for the first label and the root label
- //cerr<<"compress="<<compress<<", searching? for compression pointer to '"<<towrite.toString()<<"', "<<d_namemap.size()<<" cmp-records"<<endl;
- if(compress && (li=find(d_namemap, towrite))!=d_namemap.end()) {
++ //cerr<<"compress="<<compress<<", searching? for compression pointer to '"<<towrite.toString()<<"', "<<d_labelmap.size()<<" cmp-records"<<endl;
++ if(compress && (li=find(d_labelmap, towrite))!=d_labelmap.end()) {
+ //cerr<<"doing compression, my label=["<<label<<"] found match ["<<li->first.toString()<<"]"<<endl;
+ //cerr<<"\tFound a compression pointer to '"<<towrite.toString()<<"': "<<li->second<<endl;
+ if (d_record.size() - startRecordSize + label.size() > 253) // chopped does not include a length octet for the first label and the root label
throw MOADNSException("DNSPacketWriter::xfrName() found overly large (compressed) name");
uint16_t offset=li->second;
offset|=0xc000;
goto out; // skip trailing 0 in case of compression
}
- if(li==d_namemap.end() && pos< 16384) {
+ if(li==d_labelmap.end() && pos< 16384) {
// cerr<<"\tStoring a compression pointer to '"<<chopped<<"': "<<pos<<endl;
- d_labelmap.push_back(make_pair(chopped, pos)); // if untrue, we need to count - also, don't store offsets > 16384, won't work
- d_namemap.push_back(make_pair(towrite, pos)); // if untrue, we need to count - also, don't store offsets > 16384, won't work
++ d_labelmap.push_back(make_pair(towrite, pos)); // if untrue, we need to count - also, don't store offsets > 16384, won't work
+ //cerr<<"stored ["<<towrite.toString()<<"] at pos "<<pos<<endl;
}
startPos=pos;
{
public:
- typedef vector<pair<string, uint16_t> > lmap_t;
- typedef vector<pair<DNSName, uint16_t> > nmap_t;
- enum Place {ANSWER=1, AUTHORITY=2, ADDITIONAL=3};
++ typedef vector<pair<DNSName, uint16_t> > lmap_t;
+ enum Place : uint8_t {ANSWER=1, AUTHORITY=2, ADDITIONAL=3};
//! Start a DNS Packet in the vector passed, with question qname, qtype and qclass
- DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t qtype, uint16_t qclass=QClass::IN, uint8_t opcode=0);
-
- /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order -
+ DNSPacketWriter(vector<uint8_t>& content, const DNSName& qname, uint16_t qtype, uint16_t qclass=QClass::IN, uint8_t opcode=0);
+
+ /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order -
ANSWER, AUTHORITY, ADDITIONAL */
- void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true);
+ void startRecord(const DNSName& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true);
/** Shorthand way to add an Opt-record, for example for EDNS0 purposes */
typedef vector<pair<uint16_t,std::string> > optvect_t;
bool eof() { return true; } // we don't know how long the record should be
private:
+ // We declare 1 uint_16 in the public section, these 3 align on a 8-byte boundry
+ uint16_t d_stuff;
+ uint16_t d_sor;
+ uint16_t d_rollbackmarker; // start of last complete packet, for rollback
+
vector <uint8_t>& d_content;
vector <uint8_t> d_record;
- string d_qname;
- string d_recordqname;
+ DNSName d_qname;
+ DNSName d_recordqname;
- uint16_t d_recordqtype, d_recordqclass;
+ lmap_t d_labelmap;
+
uint32_t d_recordttl;
- nmap_t d_namemap;
- uint16_t d_stuff;
- uint16_t d_sor;
- uint16_t d_rollbackmarker; // start of last complete packet, for rollback
+ uint16_t d_recordqtype, d_recordqclass;
+
uint16_t d_truncatemarker; // end of header, for truncate
Place d_recordplace;
bool d_canonic, d_lowerCase;
return 0;
}
- ChunkedSigningPipe::ChunkedSigningPipe(const string& signerName, bool mustSign, const string& servers, unsigned int workers)
-ChunkedSigningPipe::ChunkedSigningPipe(const DNSName& signerName, bool mustSign, const string& servers, unsigned int workers)
- : d_queued(0), d_outstanding(0), d_signer(signerName), d_maxchunkrecords(100), d_numworkers(workers), d_tids(d_numworkers),
- d_mustSign(mustSign), d_final(false), d_submitted(0)
++ChunkedSigningPipe::ChunkedSigningPipe(const DNSName& signerName, bool mustSign, const string& servers, unsigned int workers)
+ : d_queued(0), d_outstanding(0), d_numworkers(workers), d_submitted(0), d_signer(signerName),
+ d_maxchunkrecords(100), d_tids(d_numworkers), d_mustSign(mustSign), d_final(false)
{
d_rrsetToSign = new rrset_t;
d_chunks.push_back(vector<DNSResourceRecord>()); // load an empty chunk
void worker(int n, int fd);
static void* helperWorker(void* p);
+
+ unsigned int d_numworkers;
+ int d_submitted;
+
rrset_t* d_rrsetToSign;
std::deque< std::vector<DNSResourceRecord> > d_chunks;
- string d_signer;
+ DNSName d_signer;
chunk_t::size_type d_maxchunkrecords;
//! The current real backend, which is answering questions
DNSBackend *d_hinterBackend;
- //! Index of the current backend within the backends vector
- unsigned int i;
-
//! DNSPacket who asked this question
DNSPacket *pkt_p;
- string qname;
+ DNSName qname;
+
+ //! Index of the current backend within the backends vector
+ unsigned int i;
QType qtype;
+
private:
static AtomicCounter instances;
void rediscover(string* status=0);
void reload();
private:
- unsigned int d_cache_ttl, d_negcache_ttl;
-
pthread_t tid;
handle d_handle;
- bool d_negcached;
- bool d_cached;
+ vector<DNSResourceRecord> d_answers;
+ vector<DNSResourceRecord>::const_iterator d_cachehandleiter;
+
+ static pthread_mutex_t d_mut;
+ static pthread_cond_t d_cond;
+ static sem_t d_dynserialize;
+
struct Question
{
- string qname;
- QType qtype;
+ DNSName qname;
int zoneId;
+ QType qtype;
}d_question;
- vector<DNSResourceRecord> d_answers;
- vector<DNSResourceRecord>::const_iterator d_cachehandleiter;
+
+ unsigned int d_cache_ttl, d_negcache_ttl;
+ int domain_id;
+ int d_ancount;
+
+ bool d_negcached;
+ bool d_cached;
+ static bool d_go;
+ bool stale;
int cacheHas(const Question &q, vector<DNSResourceRecord> &rrs);
void addNegCache(const Question &q);
void stackFile(const std::string& fname);
unsigned makeTTLFromZone(const std::string& str);
string getLineOfFile();
+ struct filestate {
+ filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
+ FILE *d_fp;
+ string d_filename;
+ int d_lineno;
+ };
+
string d_reldir;
string d_line;
- string d_prevqname;
- string d_zonename;
+ DNSName d_prevqname;
+ DNSName d_zonename;
+ string d_templateline;
vector<string> d_zonedata;
vector<string>::iterator d_zonedataline;
+ std::stack<filestate> d_filestates;
+ parts_t d_templateparts;
int d_defaultttl;
+ uint32_t d_templatecounter, d_templatestop, d_templatestep;
bool d_havedollarttl;
bool d_fromfile;
- uint32_t d_templatecounter, d_templatestop, d_templatestep;
- string d_templateline;
- parts_t d_templateparts;
-
- struct filestate {
- filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
- FILE *d_fp;
- string d_filename;
- int d_lineno;
- };
- std::stack<filestate> d_filestates;
};
#endif