d_content = std::shared_ptr<DNSRecordContent>(DNSRecordContent::mastermake(d_type, rr.qclass, rr.content));
}
- void MOADNSParser::init(const char *packet, unsigned int len)
+// If you call this and you are not parsing a packet coming from a socket, you are doing it wrong.
+DNSResourceRecord DNSResourceRecord::fromWire(const DNSRecord& d) {
+ DNSResourceRecord rr;
+ rr.qname = d.d_name;
+ rr.qtype = QType(d.d_type);
+ rr.ttl = d.d_ttl;
+ rr.content = d.d_content->getZoneRepresentation(true);
+ rr.auth = false;
+ rr.qclass = d.d_class;
+ return rr;
+}
+
+ void MOADNSParser::init(bool query, const char *packet, unsigned int len)
{
if(len < sizeof(dnsheader))
throw MOADNSException("Packet shorter than minimal header");
DNSResourceRecord rr;
FindNS fns;
- di.backend->lookup(QType(QType::NS), di.zone);
- while(di.backend->get(rr))
- nsset.insert(rr.content);
-
- for(set<string>::const_iterator j=nsset.begin();j!=nsset.end();++j) {
- vector<string> nsips=fns.lookup(DNSName(*j), di.backend);
- if(nsips.empty())
- L<<Logger::Warning<<"Unable to queue notification of domain '"<<di.zone<<"': nameservers do not resolve!"<<endl;
- else
- for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) {
- const ComboAddress caIp(*k, 53);
- if(!d_preventSelfNotification || !AddressIsUs(caIp)) {
- if(!d_onlyNotify.match(&caIp))
- L<<Logger::Info<<"Skipped notification of domain '"<<di.zone<<"' to "<<*j<<" because it does not match only-notify."<<endl;
- else
- ips.insert(caIp.toStringWithPort());
++
+ if (d_onlyNotify.size()) {
+ B->lookup(QType(QType::NS),domain);
+ while(B->get(rr))
+ nsset.insert(rr.content);
+
+ for(set<string>::const_iterator j=nsset.begin();j!=nsset.end();++j) {
+ vector<string> nsips=fns.lookup(DNSName(*j), B);
+ if(nsips.empty())
+ L<<Logger::Warning<<"Unable to queue notification of domain '"<<domain<<"': nameservers do not resolve!"<<endl;
+ else
+ for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) {
+ const ComboAddress caIp(*k, 53);
+ if(!d_preventSelfNotification || !AddressIsUs(caIp)) {
+ if(!d_onlyNotify.match(&caIp))
+ L<<Logger::Info<<"Skipped notification of domain '"<<domain<<"' to "<<*j<<" because it does not match only-notify."<<endl;
+ else
+ ips.insert(caIp.toStringWithPort());
+ }
}
- }
- }
+ }
- for(set<string>::const_iterator j=ips.begin();j!=ips.end();++j) {
- L<<Logger::Warning<<"Queued notification of domain '"<<di.zone<<"' to "<<*j<<endl;
- d_nq.add(di.zone,*j);
- hasQueuedItem=true;
+ for(set<string>::const_iterator j=ips.begin();j!=ips.end();++j) {
+ L<<Logger::Warning<<"Queued notification of domain '"<<domain<<"' to "<<*j<<endl;
+ d_nq.add(domain,*j);
+ hasQueuedItem=true;
+ }
}
set<string> alsoNotify(d_alsoNotify);