if(P->d.qr)
continue;
- S.ringAccount("queries", P->qdomain+"/"+P->qtype.getName());
+ S.ringAccount("queries", P->qdomain.toString()+"/"+P->qtype.getName());
S.ringAccount("remotes",P->d_remote);
if(logDNSQueries) {
string remote;
remote = P->getRemote() + "<-" + P->getRealRemote().toString();
else
remote = P->getRemote();
- L << Logger::Notice<<"Remote "<< remote <<" wants '" << P->qdomain<<"|"<<P->qtype.getName() <<
+ L << Logger::Notice<<"Remote "<< remote <<" wants '" << P->qdomain.toString()<<"|"<<P->qtype.getName() <<
"', do = " <<P->d_dnssecOk <<", bufsize = "<< P->getMaxReplyLen()<<": ";
}
struct SuckRequest
{
- string domain;
+ DNSName domain;
string master;
bool operator<(const SuckRequest& b) const
{
class NotificationQueue
{
public:
- void add(const string &domain, const string &ip)
+ void add(const DNSName &domain, const string &ip)
{
const ComboAddress caIp(ip);
d_nqueue.push_back(nr);
}
- bool removeIf(const string &remote, uint16_t id, const string &domain)
+ bool removeIf(const string &remote, uint16_t id, const DNSName &domain)
{
ServiceTuple stRemote, stQueued;
parseService(remote, stRemote);
return false;
}
- bool getOne(string &domain, string &ip, uint16_t *id, bool &purged)
+ bool getOne(DNSName &domain, string &ip, uint16_t *id, bool &purged)
{
for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
if(i->next <= time(0)) {
private:
struct NotificationRequest
{
- string domain;
+ DNSName domain;
string ip;
int attempts;
uint16_t id;
void go();
- void drillHole(const string &domain, const string &ip);
- bool justNotified(const string &domain, const string &ip);
- void addSuckRequest(const string &domain, const string &master);
+ void drillHole(const DNSName &domain, const string &ip);
+ bool justNotified(const DNSName &domain, const string &ip);
+ void addSuckRequest(const DNSName &domain, const string &master);
void addSlaveCheckRequest(const DomainInfo& di, const ComboAddress& remote);
void addTrySuperMasterRequest(DNSPacket *p);
- void notify(const string &domain, const string &ip);
+ void notify(const DNSName &domain, const string &ip);
void mainloop();
void retrievalLoopThread();
- void sendNotification(int sock, const string &domain, const ComboAddress& remote, uint16_t id);
+ void sendNotification(int sock, const DNSName &domain, const ComboAddress& remote, uint16_t id);
static void *launchhelper(void *p)
{
static_cast<CommunicatorClass *>(p)->retrievalLoopThread();
return 0;
}
- bool notifyDomain(const string &domain);
+ bool notifyDomain(const DNSName &domain);
private:
void makeNotifySockets();
- void queueNotifyDomain(const string &domain, UeberBackend *B);
+ void queueNotifyDomain(const DNSName &domain, UeberBackend *B);
int d_nsock4, d_nsock6;
map<pair<string,string>,time_t>d_holes;
pthread_mutex_t d_holelock;
void launchRetrievalThreads();
- void suck(const string &domain, const string &remote);
+ void suck(const DNSName &domain, const string &remote);
void slaveRefresh(PacketHandler *P);
void masterUpdateCheck(PacketHandler *P);
pthread_mutex_t d_lock;
a->setRcode(RCode::ServFail);
S.inc("servfail-packets");
- S.ringAccount("servfail-queries",QD->Q->qdomain);
+ S.ringAccount("servfail-queries",QD->Q->qdomain.toString());
delete QD->Q;
}
a->setRcode(RCode::ServFail);
S.inc("servfail-packets");
- S.ringAccount("servfail-queries",QD->Q->qdomain);
+ S.ringAccount("servfail-queries",QD->Q->qdomain.toString());
delete QD->Q;
}
a=q->replyPacket();
a->setRcode(RCode::ServFail);
S.inc("servfail-packets");
- S.ringAccount("servfail-queries",q->qdomain);
+ S.ringAccount("servfail-queries",q->qdomain.toString());
}
catch(...) {
L<<Logger::Error<<"Caught unknown exception in Distributor thread "<<(unsigned long)pthread_self()<<endl;
a=q->replyPacket();
a->setRcode(RCode::ServFail);
S.inc("servfail-packets");
- S.ringAccount("servfail-queries",q->qdomain);
+ S.ringAccount("servfail-queries",q->qdomain.toString());
}
callback(a);
return 0;
bool isPartOf(const DNSName& rhs) const; //!< Are we part of the rhs name?
bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive)
+ bool operator!=(const DNSName& other) const { return !(*this == other); }
+
std::string toString() const; //!< Our human-friendly, escaped, representation
std::string toDNSString() const; //!< Our representation in DNS native format
void appendRawLabel(const std::string& str); //!< Append this unescaped label
if(p.qtype.getCode() != i->second.qtype || p.qdomain != i->second.qname) {
L<<Logger::Error<<"Discarding packet from recursor backend with id "<<(d.id^d_xor)<<
- ", qname or qtype mismatch ("<<p.qtype.getCode()<<" v " <<i->second.qtype<<", "<<p.qdomain<<" v "<<i->second.qname<<")"<<endl;
+ ", qname or qtype mismatch ("<<p.qtype.getCode()<<" v " <<i->second.qtype<<", "<<p.qdomain.toString()<<" v "<<i->second.qname.toString()<<")"<<endl;
continue;
}
ComboAddress remote;
int outsock;
time_t created;
- string qname;
+ DNSName qname;
uint16_t qtype;
DNSPacket* complete;
string aname;
#include "namespaces.hh"
-void CommunicatorClass::queueNotifyDomain(const string &domain, UeberBackend *B)
+void CommunicatorClass::queueNotifyDomain(const DNSName &domain, UeberBackend *B)
{
bool hasQueuedItem=false;
set<string> nsset, ips;
}
-bool CommunicatorClass::notifyDomain(const string &domain)
+bool CommunicatorClass::notifyDomain(const DNSName &domain)
{
DomainInfo di;
UeberBackend B;
}
if(p.d.rcode)
- L<<Logger::Warning<<"Received unsuccessful notification report for '"<<p.qdomain<<"' from "<<from.toStringWithPort()<<", error: "<<RCode::to_s(p.d.rcode)<<endl;
+ L<<Logger::Warning<<"Received unsuccessful notification report for '"<<p.qdomain.toString()<<"' from "<<from.toStringWithPort()<<", error: "<<RCode::to_s(p.d.rcode)<<endl;
if(d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
- L<<Logger::Warning<<"Removed from notification list: '"<<p.qdomain<<"' to "<<from.toStringWithPort()<<" "<< (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)")<<endl;
+ L<<Logger::Warning<<"Removed from notification list: '"<<p.qdomain.toString()<<"' to "<<from.toStringWithPort()<<" "<< (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)")<<endl;
else {
- L<<Logger::Warning<<"Received spurious notify answer for '"<<p.qdomain<<"' from "<< from.toStringWithPort()<<endl;
+ L<<Logger::Warning<<"Received spurious notify answer for '"<<p.qdomain.toString()<<"' from "<< from.toStringWithPort()<<endl;
//d_nq.dump();
}
}
}
}
-void CommunicatorClass::drillHole(const string &domain, const string &ip)
+void CommunicatorClass::drillHole(const DNSName &domain, const string &ip)
{
Lock l(&d_holelock);
d_holes[make_pair(domain,ip)]=time(0);
}
-bool CommunicatorClass::justNotified(const string &domain, const string &ip)
+bool CommunicatorClass::justNotified(const DNSName &domain, const string &ip)
{
Lock l(&d_holelock);
if(d_holes.find(make_pair(domain,ip))==d_holes.end()) // no hole
d_nsock6 = -1;
}
-void CommunicatorClass::notify(const string &domain, const string &ip)
+void CommunicatorClass::notify(const DNSName &domain, const string &ip)
{
d_nq.add(domain, ip);
d_any_sem.post();