X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdnsqueue.cpp;h=975884796f7dd24f9963c58dfb98cc77b9257077;hb=8f9d0a68cd77b6a78eccfa7df9c1045d453ce581;hp=71f227567540f33b8c0389ce318f7334d5217665;hpb=5a17e1b8bd690a573c91e5c69f2c150fe0516f7a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp index 71f227567..975884796 100644 --- a/src/dnsqueue.cpp +++ b/src/dnsqueue.cpp @@ -14,47 +14,27 @@ * --------------------------------------------------- */ -using namespace std; - #include "inspircd_config.h" #include "inspircd.h" -#include "inspircd_io.h" +#include "configreader.h" #include #include #include #include -#include -#include #include -#ifdef GCC3 -#include -#else -#include -#endif -#include -#include -#include -#include #include "users.h" #include "globals.h" #include "inspstring.h" #include "dnsqueue.h" -#include -#include -#include -#include -#include -#include #include "dns.h" #include "helperfuncs.h" #include "hashcomp.h" #include "socketengine.h" +#include "socket.h" extern ServerConfig* Config; extern InspIRCd* ServerInstance; -address_cache addrcache; - class Lookup; Lookup* dnslist[MAX_DESCRIPTORS]; @@ -71,11 +51,13 @@ public: Lookup() { *u = 0; + hostname = ""; } void Reset() { *u = 0; + hostname = ""; } ~Lookup() @@ -93,7 +75,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) @@ -127,16 +109,17 @@ public: } if ((hostname != "") && (usr->registered != 7)) { - if (std::string((char*)inet_ntoa(usr->ip4)) == ip) + if ((std::string((char*)inet_ntoa(usr->ip4)) == ip) && (hostname.length() < 65)) { - strlcpy(usr->host,hostname.c_str(),MAXBUF); - strlcpy(usr->dhost,hostname.c_str(),MAXBUF); - address_cache::iterator address = addrcache.find(usr->ip4); + strlcpy(usr->host,hostname.c_str(),64); + strlcpy(usr->dhost,hostname.c_str(),64); + /*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; @@ -176,6 +159,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; } @@ -203,24 +187,23 @@ public: } }; -bool lookup_dns(std::string nick) +bool lookup_dns(const std::string &nick) { /* First attempt to find the nickname */ userrec* u = Find(nick); if (u) { /* Check the cache */ - address_cache::iterator address = addrcache.find(u->ip4); + /*address_cache::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 @@ -264,7 +247,7 @@ void dns_poll(int fdcheck) * from the socket engine, as dns.cpp tracks it * for us if we are in single-threaded country. */ - delete x; + DELETE(x); } } else @@ -272,7 +255,7 @@ void dns_poll(int fdcheck) /* its fd is dodgy, the dns code probably * bashed it due to error. Free the class. */ - delete x; + DELETE(x); } /* If we got down here, the dns lookup was valid, BUT, * its still in progress. Be patient, and wait for @@ -287,4 +270,3 @@ void dns_poll(int fdcheck) if (ServerInstance && ServerInstance->SE) ServerInstance->SE->DelFd(fdcheck); } -