+CachedQuery::CachedQuery(const std::string &res, QueryType qt, unsigned int ttl) : data(res), type(qt)
+{
+ expires = ServerInstance->Time() + ttl;
+}
+
+int CachedQuery::CalcTTLRemaining()
+{
+ int n = expires - ServerInstance->Time();
+ return (n < 0 ? 0 : n);
+}
+
+/* Allocate the processing buffer */
+DNSRequest::DNSRequest(DNS* dns, int rid, const std::string &original) : dnsobj(dns)
+{
+ /* hardening against overflow here: make our work buffer twice the theoretical
+ * maximum size so that hostile input doesn't screw us over.
+ */
+ res = new unsigned char[sizeof(DNSHeader) * 2];
+ *res = 0;
+ orig = original;
+ RequestTimeout* RT = new RequestTimeout(ServerInstance->Config->dns_timeout ? ServerInstance->Config->dns_timeout : 5, this, rid);
+ ServerInstance->Timers->AddTimer(RT); /* The timer manager frees this */
+}
+
+/* Deallocate the processing buffer */
+DNSRequest::~DNSRequest()
+{
+ delete[] res;
+}
+
+/** Fill a ResourceRecord class based on raw data input */