]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
NOTE: our stuff for parsing multiple dns replies for dnsbl with an 'A record reply...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 Nov 2007 00:35:19 +0000 (00:35 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 Nov 2007 00:35:19 +0000 (00:35 +0000)
We will fix this at some later date. It was breaking other stuff

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8591 e03df62e-2008-0410-955e-edbf42e46eb7

src/configreader.cpp
src/dns.cpp
src/inspsocket.cpp
src/modules/m_http_client.cpp

index a726733633fd9fb24376e028c9776ffe7ff3e38c..31025290cd07a9350daf03ee22421cd6162baf8f 100644 (file)
@@ -1142,6 +1142,15 @@ void ServerConfig::Read(bool bail, User* user, int pass)
                 * at this point
                 */
 
+               if (pass == 0)
+               {
+                       if (isatty(0) && isatty(1) && isatty(2))
+                               printf("Downloading configuration ");
+
+                       TotalDownloaded = 0;
+                       FileErrors = 0;
+               }
+
                if (!ServerInstance->Res)
                        ServerInstance->Res = new DNS(ServerInstance);
                /** Note: This is safe, the method checks for user == NULL */
@@ -1261,6 +1270,7 @@ bool ServerConfig::Downloading()
 
 void ServerConfig::Complete(const std::string &filename, bool error)
 {
+       ServerInstance->Log(DEBUG,"Flag complete: %s %d", filename.c_str(), error);
        std::map<std::string, std::istream*>::iterator x = IncludedFiles.find(filename);
 
        if (x != IncludedFiles.end())
@@ -1272,15 +1282,6 @@ void ServerConfig::Complete(const std::string &filename, bool error)
                        x->second = NULL;
                        FileErrors++;
                }
-
-               /* We should parse the new file here and check it for another level of include files */
-               CompletedFiles[filename] = true;
-
-               if (!error)
-               {
-                       LoadConf(this->newconfig, filename, errstr, 0, x->second);
-                       StartDownloads();
-               }
        }
 
        return;
@@ -1288,24 +1289,11 @@ void ServerConfig::Complete(const std::string &filename, bool error)
 
 void ServerConfig::StartDownloads()
 {
-       if (IncludedFiles.empty())
-       {
-               if (isatty(0) && isatty(1) && isatty(2))
-                       printf("Downloading configuration ");
-
-               TotalDownloaded = 0;
-               FileErrors = 0;
-       }
+       ServerInstance->Log(DEBUG,"StartDownloads() size=%d", IncludedFiles.size());
 
        /* Reads all local files into the IncludedFiles map, then initiates sockets for the remote ones */
        for (std::map<std::string, std::istream*>::iterator x = IncludedFiles.begin(); x != IncludedFiles.end(); ++x)
        {
-               if (CompletedFiles.find(x->first) != CompletedFiles.end())
-               {
-                       ServerInstance->Log(DEBUG, "Already fetched: %s", x->first.c_str());
-                       continue;
-               }
-
                std::string file = x->first;
                if ((file[0] == '/') || (file.substr(0, 7) == "file://"))
                {
@@ -1346,9 +1334,6 @@ void ServerConfig::StartDownloads()
                                x->second = NULL;
                        }
                }
-
-               CompletedFiles[file] = true;
-               ServerInstance->Log(DEBUG, "Flagging as already fetched: %s", file.c_str());
        }
 }
 
@@ -1384,7 +1369,6 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                                errorstream << "File " << filename << " could not be opened." << std::endl;
                                return false;
                        }
-                       CompletedFiles[filename] = true;
                }
        }
        else
@@ -1394,13 +1378,10 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                {
                        if (pass == 0)
                        {
-                               if (CompletedFiles.find(filename) == CompletedFiles.end())
-                               {
-                                       ServerInstance->Log(DEBUG,"Push include file %s onto map", filename);
-                                       /* First pass, we insert the file into a map, and just return true */
-                                       IncludedFiles.insert(std::make_pair(filename,new std::stringstream));
-                                       return true;
-                               }
+                               ServerInstance->Log(DEBUG,"Push include file %s onto map", filename);
+                               /* First pass, we insert the file into a map, and just return true */
+                               IncludedFiles.insert(std::make_pair(filename,new std::stringstream));
+                               return true;
                        }
                        else
                        {
@@ -1713,14 +1694,7 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &li
                                                got_key = false;
 
                                                if ((tagname == "include") && (current_key == "file"))
-                                               {
-                                                       if (scan_for_includes_only && (CompletedFiles.find(current_key) != CompletedFiles.end()))
-                                                       {
-                                                               current_key.clear();
-                                                               current_value.clear();
-                                                               continue;
-                                                       }
-                                                       
+                                               {       
                                                        if (!this->DoInclude(target, current_value, errorstream, pass, scan_for_includes_only))
                                                                return false;
                                                }
@@ -1741,7 +1715,8 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &li
        }
 
        /* Finished parsing the tag, add it to the config hash */
-       target.insert(std::pair<std::string, KeyValList > (tagname, results));
+       if (!scan_for_includes_only)
+               target.insert(std::pair<std::string, KeyValList > (tagname, results));
 
        return true;
 }
@@ -1772,7 +1747,7 @@ bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, st
                }
        }
 
-       return LoadConf(target, newfile, errorstream, pass);
+       return LoadConf(target, newfile, errorstream, pass, scan_for_includes_only);
 }
 
 bool ServerConfig::ConfValue(ConfigDataHash &target, const char* tag, const char* var, int index, char* result, int length, bool allow_linefeeds)
index 8a274577e5b95cd46e552921820a06e26ca84d11..2179440c0495275920aef061109439d18f727f16 100644 (file)
@@ -868,7 +868,7 @@ DNSInfo DNSRequest::ResultIsReady(DNSHeader &header, int length, int result_we_w
                break;
        }
        if ((unsigned int)curanswer == header.ancount)
-               return std::make_pair((unsigned char*)NULL,"No more records");
+               return std::make_pair((unsigned char*)NULL,"No more answers (" + ConvToStr(header.ancount) + " answers, wanted #" + ConvToStr(result_we_want) + ")");
 
        if (i + rr.rdlength > (unsigned int)length)
                return std::make_pair((unsigned char*)NULL,"Resource record larger than stated");
@@ -1065,54 +1065,52 @@ void DNS::HandleEvent(EventType, int)
        DNSResult res(0,"",0,"");
        res.id = 0;
        ServerInstance->Log(DEBUG,"Handle DNS event");
-       while ((res.id & ERROR_MASK) == 0)
-       {
-               res = this->GetResult(resultnum);
 
-               ServerInstance->Log(DEBUG,"Result %d id %d", resultnum, res.id);
+       res = this->GetResult(resultnum);
+
+       ServerInstance->Log(DEBUG,"Result %d id %d", resultnum, res.id);
        
-               /* Is there a usable request id? */
-               if (res.id != -1)
+       /* Is there a usable request id? */
+       if (res.id != -1)
+       {
+               /* Its an error reply */
+               if (res.id & ERROR_MASK)
                {
-                       /* Its an error reply */
-                       if (res.id & ERROR_MASK)
+                       /* Mask off the error bit */
+                       res.id -= ERROR_MASK;
+                       /* Marshall the error to the correct class */
+                       if (Classes[res.id])
                        {
-                               /* Mask off the error bit */
-                               res.id -= ERROR_MASK;
-                               /* Marshall the error to the correct class */
-                               if (Classes[res.id])
-                               {
-                                       if (ServerInstance && ServerInstance->stats)
-                                               ServerInstance->stats->statsDnsBad++;
-                                       Classes[res.id]->OnError(RESOLVER_NXDOMAIN, res.result);
-                                       delete Classes[res.id];
-                                       Classes[res.id] = NULL;
-                               }
-                               break;
+                               if (ServerInstance && ServerInstance->stats)
+                                       ServerInstance->stats->statsDnsBad++;
+                               Classes[res.id]->OnError(RESOLVER_NXDOMAIN, res.result);
+                               delete Classes[res.id];
+                               Classes[res.id] = NULL;
                        }
-                       else
+                       return;
+               }
+               else
+               {
+                       /* It is a non-error result, marshall the result to the correct class */
+                       if (Classes[res.id])
                        {
-                               /* It is a non-error result, marshall the result to the correct class */
-                               if (Classes[res.id])
-                               {
-                                       if (ServerInstance && ServerInstance->stats)
-                                               ServerInstance->stats->statsDnsGood++;
-       
-                                       if (!this->GetCache(res.original.c_str()))
-                                               this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl)));
+                               if (ServerInstance && ServerInstance->stats)
+                                       ServerInstance->stats->statsDnsGood++;
        
-                                       Classes[res.id]->OnLookupComplete(res.result, res.ttl, false, resultnum);
-                                       delete Classes[res.id];
-                                       Classes[res.id] = NULL;
-                               }
+                               if (!this->GetCache(res.original.c_str()))
+                                       this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl)));
+
+                               Classes[res.id]->OnLookupComplete(res.result, res.ttl, false, resultnum);
+                               delete Classes[res.id];
+                               Classes[res.id] = NULL;
                        }
-       
-                       if (ServerInstance && ServerInstance->stats)
-                               ServerInstance->stats->statsDns++;
                }
-
-               resultnum++;
+       
+               if (ServerInstance && ServerInstance->stats)
+                       ServerInstance->stats->statsDns++;
        }
+
+       resultnum++;
 }
        
 /** Add a derived Resolver to the working set */
index 24f9af3a234de00856f37497d4466e4a39473679..6277dccf4a82b8dac4f2327bcce67ba9c429b84d 100644 (file)
@@ -236,6 +236,7 @@ bool BufferedSocket::BindAddr(const std::string &ip)
                }
                j++;
        }
+       Instance->Log(DEBUG,"nothing in the config to bind()!");
        return true;
 }
 
index a25e014f6842904b19e6d82a98b8ecc5759c8e21..a75cfd1b2cb6d0daaea0fb80848488cd9bbab5cd 100644 (file)
@@ -56,13 +56,13 @@ class HTTPResolver : public Resolver
  public:
        HTTPResolver(HTTPSocket *s, InspIRCd *Instance, const string &hostname, bool &cached, Module* me) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), socket(s)
        {
-               ServerInstance->Log(DEBUG,"HTTPResolver::HTTPResolver");
+               ServerInstance->Log(DEBUG,">>>>>>>>>>>>>>>>>> HTTPResolver::HTTPResolver <<<<<<<<<<<<<<<");
                orig = hostname;
        }
        
        void OnLookupComplete(const string &result, unsigned int ttl, bool cached, int resultnum = 0)
        {
-               ServerInstance->Log(DEBUG,"HTTPResolver::OnLookupComplete");
+               ServerInstance->Log(DEBUG,"************* HTTPResolver::OnLookupComplete ***************");
                if (!resultnum)
                        socket->Connect(result);
                else
@@ -71,7 +71,7 @@ class HTTPResolver : public Resolver
        
        void OnError(ResolverError e, const string &errmsg)
        {
-               ServerInstance->Log(DEBUG,"HTTPResolver::OnError");
+               ServerInstance->Log(DEBUG,"!!!!!!!!!!!!!!!! HTTPResolver::OnError: %s", errmsg.c_str());
                socket->OnClose();
        }
 };
@@ -164,7 +164,7 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
                bool cached;
                HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
                Instance->AddResolver(r, cached);
-               Instance->Log(DEBUG,"Resolver added");
+               Instance->Log(DEBUG,"Resolver added, cached=%d", cached);
        }
        else
                Connect(url.domain);