From: brain Date: Mon, 25 Sep 2006 20:28:58 +0000 (+0000) Subject: Allow for multiple tags, each with their own index and bound to their own ip X-Git-Tag: v2.0.23~7029 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=7f04754f849bd98dc01d8bdeeb7952d6d03f1ff7;p=user%2Fhenk%2Fcode%2Finspircd.git Allow for multiple tags, each with their own index and bound to their own ip git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5330 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index d6fcad9e1..df8106ccb 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -91,6 +91,11 @@ class HttpSocket : public InspSocket Instance->Timers->AddTimer(Timeout); } + FileReader* GetIndex() + { + return index; + } + ~HttpSocket() { if (Instance->Time() < Timeout->GetTimer()) @@ -357,43 +362,36 @@ void HTTPTimeout::Tick(time_t TIME) class ModuleHttp : public Module { - int port; - std::string host; - std::string bindip; - std::string indexfile; - - FileReader* index; - - HttpSocket* http; - + std::vector httpsocks; public: void ReadConfig() { + int port; + std::string host; + std::string bindip; + std::string indexfile; + FileReader* index; + HttpSocket* http; ConfigReader c(ServerInstance); - this->host = c.ReadValue("http", "host", 0); - this->bindip = c.ReadValue("http", "ip", 0); - this->port = c.ReadInteger("http", "port", 0, true); - this->indexfile = c.ReadValue("http", "index", 0); - if (index) + httpsocks.clear(); + + for (int i = 0; i < c.Enumerate("alias"); i++) { - delete index; - index = NULL; + host = c.ReadValue("http", "host", i); + bindip = c.ReadValue("http", "ip", i); + port = c.ReadInteger("http", "port", i, true); + indexfile = c.ReadValue("http", "index", i); + index = new FileReader(ServerInstance, indexfile); + http = new HttpSocket(ServerInstance, bindip, port, true, 0, index); + httpsocks.push_back(http); } - index = new FileReader(ServerInstance, this->indexfile); - } - - void CreateListener() - { - http = new HttpSocket(ServerInstance, this->bindip, this->port, true, 0, index); } ModuleHttp(InspIRCd* Me) : Module::Module(Me) { - index = NULL; ReadConfig(); - CreateListener(); } void OnEvent(Event* event) @@ -417,7 +415,12 @@ class ModuleHttp : public Module virtual ~ModuleHttp() { - ServerInstance->SE->DelFd(http); + for (size_t i = 0; i < httpsocks.size(); i++) + { + ServerInstance->SE->DelFd(httpsocks[i]); + delete httpsocks[i]->GetIndex(); + delete httpsocks[i]; + } } virtual Version GetVersion()