diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-12 00:35:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-12 00:35:19 +0000 |
commit | c68ed91549574705fa5f3c0971e5d0878d56fac7 (patch) | |
tree | dd2379d10bdab057e7d22c617f12c5401c6afd9d | |
parent | bedbe6480de4af64c0e752bc5ed09d0d7a9aa72c (diff) |
NOTE: our stuff for parsing multiple dns replies for dnsbl with an 'A record reply' is broken.
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
-rw-r--r-- | src/configreader.cpp | 63 | ||||
-rw-r--r-- | src/dns.cpp | 76 | ||||
-rw-r--r-- | src/inspsocket.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_http_client.cpp | 8 |
4 files changed, 61 insertions, 87 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index a72673363..31025290c 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -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) diff --git a/src/dns.cpp b/src/dns.cpp index 8a274577e..2179440c0 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -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 */ diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 24f9af3a2..6277dccf4 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -236,6 +236,7 @@ bool BufferedSocket::BindAddr(const std::string &ip) } j++; } + Instance->Log(DEBUG,"nothing in the config to bind()!"); return true; } diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp index a25e014f6..a75cfd1b2 100644 --- a/src/modules/m_http_client.cpp +++ b/src/modules/m_http_client.cpp @@ -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); |