summaryrefslogtreecommitdiff
path: root/src/dnsqueue.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-03 14:31:55 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-03 14:31:55 +0000
commite401f5bf5bb6d774f66c7bdd978f87ddf0990bc2 (patch)
tree9a3d7c3bc3b4a5197b44049a0470cfd7131819c3 /src/dnsqueue.cpp
parent6ee0904855a75282d478c8e85b2f6381c6b33e7c (diff)
Added back ip->host caching now we can make it not be a performance hit (we write better code these days)
*TODO* - TTL git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3041 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dnsqueue.cpp')
-rw-r--r--src/dnsqueue.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index dee671aa1..cd6f696d6 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -53,6 +53,8 @@ using namespace std;
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
+address_cache addrcache;
+
class Lookup;
Lookup* dnslist[MAX_DESCRIPTORS];
@@ -129,6 +131,12 @@ public:
{
strlcpy(usr->host,hostname.c_str(),MAXBUF);
strlcpy(usr->dhost,hostname.c_str(),MAXBUF);
+ address_hash::iterator address = addrcache.find(usr->ip4);
+ if (address == addrcache.end())
+ {
+ log(DEBUG,"Caching hostname %s -> %s",(char*)inet_ntoa(usr->ip4),hostname.c_str());
+ addrcache[usr->ip4] = new std::string(hostname);
+ }
}
usr->dns_done = true;
return true;
@@ -201,6 +209,18 @@ bool lookup_dns(std::string nick)
userrec* u = Find(nick);
if (u)
{
+ /* Check the cache */
+ address_hash::iterator address = addrcache.find(u->ip4);
+ if (address != addrcache.end())
+ {
+ /* Theyre in the cache, dont waste a lookup */
+ WriteServ(u->fd,"NOTICE Auth :*** Found your hostname (cached)");
+ log(DEBUG,"Found cached host");
+ strlcpy(u->host,address->second->c_str(),MAXBUF);
+ strlcpy(u->dhost,address->second->c_str(),MAXBUF);
+ u->dns_done = true;
+ return true;
+ }
/* If the user exists, create a new
* lookup object, and associate it
* with the user. The lookup object