X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdnsqueue.cpp;h=8be3ea99b0b742a3312866e5b5c80aca0f6cf6f3;hb=59b1a8955142935b02af6446005ab47fc7c3fc8c;hp=dee671aa16ca1e636108e16e74c5d27d3a07f884;hpb=653638c68684ec035fd58bc2d0d91c9bf9aa2ab9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp index dee671aa1..8be3ea99b 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]; @@ -69,11 +71,13 @@ public: Lookup() { *u = 0; + hostname = ""; } void Reset() { *u = 0; + hostname = ""; } ~Lookup() @@ -91,7 +95,7 @@ public: { return false; } - strlcpy(u,nick.c_str(),NICKMAX); + strlcpy(u,nick.c_str(),NICKMAX-1); /* ASSOCIATE WITH DNS LOOKUP LIST */ if (resolver1.GetFD() != -1) @@ -129,6 +133,13 @@ public: { strlcpy(usr->host,hostname.c_str(),MAXBUF); strlcpy(usr->dhost,hostname.c_str(),MAXBUF); + /*address_cache::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); + }*/ + WriteServ(usr->fd,"NOTICE Auth :*** Found your hostname"); } usr->dns_done = true; return true; @@ -168,6 +179,7 @@ public: { if ((usr->registered > 3) || (hostname == "")) { + WriteServ(usr->fd,"NOTICE Auth :*** Could not resolve your hostname -- Using your IP address instead"); usr->dns_done = true; return true; } @@ -201,6 +213,17 @@ bool lookup_dns(std::string nick) userrec* u = Find(nick); if (u) { + /* Check the cache */ + /*address_cache::iterator address = addrcache.find(u->ip4); + if (address != addrcache.end()) + { + 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