* 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 */
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())
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;
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://"))
{
x->second = NULL;
}
}
-
- CompletedFiles[file] = true;
- ServerInstance->Log(DEBUG, "Flagging as already fetched: %s", file.c_str());
}
}
errorstream << "File " << filename << " could not be opened." << std::endl;
return false;
}
- CompletedFiles[filename] = true;
}
}
else
{
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
{
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;
}
}
/* 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;
}
}
}
- 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)
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");
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 */
}
j++;
}
+ Instance->Log(DEBUG,"nothing in the config to bind()!");
return true;
}
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
void OnError(ResolverError e, const string &errmsg)
{
- ServerInstance->Log(DEBUG,"HTTPResolver::OnError");
+ ServerInstance->Log(DEBUG,"!!!!!!!!!!!!!!!! HTTPResolver::OnError: %s", errmsg.c_str());
socket->OnClose();
}
};
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);