diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-25 20:28:58 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-09-25 20:28:58 +0000 |
commit | 7f04754f849bd98dc01d8bdeeb7952d6d03f1ff7 (patch) | |
tree | 3cc858d4334304512a7ef8ef4e0323c8cb765ddf /src | |
parent | 6bbc9d2f7053ff2dcd2a6b242db676752d3b320b (diff) |
Allow for multiple <http> 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
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_httpd.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
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<HttpSocket*> 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() |