* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
};
/* Allocate the processing buffer */
-DNSRequest::DNSRequest(InspIRCd* Instance, DNS* dns, int id, const std::string &original) : dnsobj(dns), ServerInstance(Instance)
+DNSRequest::DNSRequest(InspIRCd* Instance, DNS* dns, int rid, const std::string &original) : dnsobj(dns), ServerInstance(Instance)
{
res = new unsigned char[512];
*res = 0;
orig = original;
- RequestTimeout* RT = new RequestTimeout(Instance->Config->dns_timeout ? Instance->Config->dns_timeout : 5, Instance, this, id);
+ RequestTimeout* RT = new RequestTimeout(Instance->Config->dns_timeout ? Instance->Config->dns_timeout : 5, Instance, this, rid);
Instance->Timers->AddTimer(RT); /* The timer manager frees this */
}
break;
}
if ((unsigned int)curanswer == header.ancount)
- return std::make_pair((unsigned char*)NULL,"No more records");
+ return std::make_pair((unsigned char*)NULL,"No more answers (" + ConvToStr(header.ancount) + " answers, wanted #" + ConvToStr(result_we_want) + ")");
if (i + rr.rdlength > (unsigned int)length)
return std::make_pair((unsigned char*)NULL,"Resource record larger than stated");
DNSResult res(0,"",0,"");
res.id = 0;
ServerInstance->Log(DEBUG,"Handle DNS event");
- while ((res.id & ERROR_MASK) == 0)
- {
- res = this->GetResult(resultnum);
- ServerInstance->Log(DEBUG,"Result %d id %d", resultnum, res.id);
+ res = this->GetResult(resultnum);
+
+ ServerInstance->Log(DEBUG,"Result %d id %d", resultnum, res.id);
- /* Is there a usable request id? */
- if (res.id != -1)
+ /* Is there a usable request id? */
+ if (res.id != -1)
+ {
+ /* Its an error reply */
+ if (res.id & ERROR_MASK)
{
- /* Its an error reply */
- if (res.id & ERROR_MASK)
+ /* Mask off the error bit */
+ res.id -= ERROR_MASK;
+ /* Marshall the error to the correct class */
+ if (Classes[res.id])
{
- /* Mask off the error bit */
- res.id -= ERROR_MASK;
- /* Marshall the error to the correct class */
- if (Classes[res.id])
- {
- if (ServerInstance && ServerInstance->stats)
- ServerInstance->stats->statsDnsBad++;
- Classes[res.id]->OnError(RESOLVER_NXDOMAIN, res.result);
- delete Classes[res.id];
- Classes[res.id] = NULL;
- }
- break;
+ if (ServerInstance && ServerInstance->stats)
+ ServerInstance->stats->statsDnsBad++;
+ Classes[res.id]->OnError(RESOLVER_NXDOMAIN, res.result);
+ delete Classes[res.id];
+ Classes[res.id] = NULL;
}
- else
+ return;
+ }
+ else
+ {
+ /* It is a non-error result, marshall the result to the correct class */
+ if (Classes[res.id])
{
- /* It is a non-error result, marshall the result to the correct class */
- if (Classes[res.id])
- {
- if (ServerInstance && ServerInstance->stats)
- ServerInstance->stats->statsDnsGood++;
-
- if (!this->GetCache(res.original.c_str()))
- this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl)));
+ if (ServerInstance && ServerInstance->stats)
+ ServerInstance->stats->statsDnsGood++;
- Classes[res.id]->OnLookupComplete(res.result, res.ttl, false, resultnum);
- delete Classes[res.id];
- Classes[res.id] = NULL;
- }
+ if (!this->GetCache(res.original.c_str()))
+ this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl)));
+
+ Classes[res.id]->OnLookupComplete(res.result, res.ttl, false, resultnum);
+ delete Classes[res.id];
+ Classes[res.id] = NULL;
}
-
- if (ServerInstance && ServerInstance->stats)
- ServerInstance->stats->statsDns++;
}
-
- resultnum++;
+
+ if (ServerInstance && ServerInstance->stats)
+ ServerInstance->stats->statsDns++;
}
+
+ resultnum++;
}
/** Add a derived Resolver to the working set */