X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdnsqueue.cpp;h=73d80d11d02804b3fc526979d49dc7e560a7dc60;hb=84a19a9ab6129deb71cdc24b216b74dd8eb80978;hp=eb3160ec4abc3e6bfb94a27955d9135a2912a566;hpb=0465fd1da7a7504f31e0c96fa1b77190ec658c32;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp index eb3160ec4..73d80d11d 100644 --- a/src/dnsqueue.cpp +++ b/src/dnsqueue.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -14,48 +14,30 @@ * --------------------------------------------------- */ -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 SocketEngine* SE; extern ServerConfig* Config; +extern InspIRCd* ServerInstance; class Lookup; -Lookup* dnslist[65535]; +Lookup* dnslist[MAX_DESCRIPTORS]; //enum LookupState { reverse, forward }; @@ -68,12 +50,14 @@ private: public: Lookup() { - strcpy(u,""); + *u = 0; + hostname = ""; } void Reset() { - strcpy(u,""); + *u = 0; + hostname = ""; } ~Lookup() @@ -91,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) @@ -125,10 +109,17 @@ public: } if ((hostname != "") && (usr->registered != 7)) { - if (std::string(usr->ip) == 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); + 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 +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; } @@ -195,12 +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); + 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 @@ -225,7 +228,7 @@ bool lookup_dns(std::string nick) void dns_poll(int fdcheck) { /* Check the given file descriptor is in valid range */ - if ((fdcheck < 0) || (fdcheck > 65535)) + if ((fdcheck < 0) || (fdcheck > MAX_DESCRIPTORS)) return; /* Try and find the file descriptor in our list of @@ -264,6 +267,6 @@ void dns_poll(int fdcheck) * just to be safe so we dont get any more events * about it. */ - SE->DelFd(fdcheck); + if (ServerInstance && ServerInstance->SE) + ServerInstance->SE->DelFd(fdcheck); } -