1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 08:03:13 +02:00

Fix m_httpd enabling ssl if m_ssl is loaded after it

This commit is contained in:
Adam
2013-08-22 22:45:20 -04:00
parent 5ac0c9a327
commit 2b1f75a313
+28 -14
View File
@@ -286,7 +286,9 @@ class MyHTTPProvider : public HTTPProvider, public Timer
std::list<Reference<MyHTTPClient> > clients;
public:
MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t) : Socket(-1, i.find(':') != Anope::string::npos), HTTPProvider(c, n, i, p), Timer(c, 10, Anope::CurTime, true), timeout(t) { }
bool ssl;
MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s) : Socket(-1, i.find(':') != Anope::string::npos), HTTPProvider(c, n, i, p), Timer(c, 10, Anope::CurTime, true), timeout(t), ssl(s) { }
void Tick(time_t) anope_override
{
@@ -329,7 +331,7 @@ class MyHTTPProvider : public HTTPProvider, public Timer
class HTTPD : public Module
{
ServiceReference<SSLService> sslref;
std::map<Anope::string, HTTPProvider *> providers;
std::map<Anope::string, MyHTTPProvider *> providers;
public:
HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sslref("SSLService", "ssl")
{
@@ -381,19 +383,13 @@ class HTTPD : public Module
continue;
}
if (ssl && !sslref)
{
Log(this) << "Could not enable SSL, is m_ssl loaded?";
ssl = false;
}
HTTPProvider *p;
MyHTTPProvider *p;
if (this->providers.count(hname) == 0)
{
try
{
p = new MyHTTPProvider(this, hname, ip, port, timeout);
if (ssl)
p = new MyHTTPProvider(this, hname, ip, port, timeout, ssl);
if (ssl && sslref)
sslref->Init(p);
}
catch (const SocketException &ex)
@@ -418,8 +414,8 @@ class HTTPD : public Module
try
{
p = new MyHTTPProvider(this, hname, ip, port, timeout);
if (ssl)
p = new MyHTTPProvider(this, hname, ip, port, timeout, ssl);
if (ssl && sslref)
sslref->Init(p);
}
catch (const SocketException &ex)
@@ -437,7 +433,7 @@ class HTTPD : public Module
spacesepstream(ext_header).GetTokens(p->ext_headers);
}
for (std::map<Anope::string, HTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;)
for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;)
{
HTTPProvider *p = it->second;
++it;
@@ -450,6 +446,24 @@ class HTTPD : public Module
}
}
}
void OnModuleLoad(User *u, Module *m) anope_override
{
if (m->name != "m_ssl")
return;
for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end; ++it)
{
MyHTTPProvider *p = it->second;
if (p->ssl && sslref)
try
{
sslref->Init(p);
}
catch (const CoreException &) { } // Throws on reinitialization
}
}
};
MODULE_INIT(HTTPD)