summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp54
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp56
2 files changed, 91 insertions, 19 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 6fdc5d3b4..fafb646e1 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -117,17 +117,53 @@ class ModuleSSLGnuTLS : public Module
if(((Conf->ReadValue("bind", "type", i) == "") || (Conf->ReadValue("bind", "type", i) == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "gnutls"))
{
// Get the port we're meant to be listening on with SSL
- unsigned int port = Conf->ReadInteger("bind", "port", i, true);
- if (ServerInstance->Config->AddIOHook(port, this))
+ std::string port = Conf->ReadValue("bind", "port", i);
+ irc::commasepstream portrange(port);
+ std::string portno = "*";
+ while ((portno = portrange.GetToken()) != "")
{
- // We keep a record of which ports we're listening on with SSL
- listenports.push_back(port);
+ std::string::size_type dash = portno.rfind('-');
+ if (dash != std::string::npos)
+ {
+ std::string sbegin = portno.substr(0, dash);
+ std::string send = portno.substr(dash+1, portno.length());
+ long begin = atoi(sbegin.c_str());
+ long end = atoi(send.c_str());
+ if ((begin < 0) || (end < 0) || (begin > 65535) || (end > 65535) || (begin >= end))
+ {
+ ServerInstance->Log(DEFAULT,"WARNING: Port range \"%d-%d\" discarded. begin >= end, or begin/end out of range.", begin, end);
+ }
+ else
+ {
+ for (int portval = begin; portval <= end; ++portval)
+ {
+ if (ServerInstance->Config->AddIOHook(portval, this))
+ {
+ listenports.push_back(portval);
+ ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %d", portval);
+ }
+ else
+ {
+ ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?",
+ portval);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (ServerInstance->Config->AddIOHook(atoi(portno.c_str()), this))
+ {
+ // We keep a record of which ports we're listening on with SSL
+ listenports.push_back(atoi(portno.c_str()));
- ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %d", port);
- }
- else
- {
- ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", port);
+ ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %s", portno.c_str());
+ }
+ else
+ {
+ ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %s, maybe you have another ssl or similar module loaded?", portno.c_str());
+ }
+ }
}
}
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 077ae03a6..2acd78d0e 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -142,17 +142,53 @@ class ModuleSSLOpenSSL : public Module
if(((Conf->ReadValue("bind", "type", i) == "") || (Conf->ReadValue("bind", "type", i) == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "openssl"))
{
// Get the port we're meant to be listening on with SSL
- unsigned int port = Conf->ReadInteger("bind", "port", i, true);
- if (ServerInstance->Config->AddIOHook(port, this))
+ std::string port = Conf->ReadValue("bind", "port", i);
+ irc::commasepstream portrange(port);
+ std::string portno = "*";
+ while ((portno = portrange.GetToken()) != "")
{
- // We keep a record of which ports we're listening on with SSL
- listenports.push_back(port);
-
- ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", port);
- }
- else
- {
- ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", port);
+ std::string::size_type dash = portno.rfind('-');
+ if (dash != std::string::npos)
+ {
+ std::string sbegin = portno.substr(0, dash);
+ std::string send = portno.substr(dash+1, portno.length());
+ long begin = atoi(sbegin.c_str());
+ long end = atoi(send.c_str());
+ if ((begin < 0) || (end < 0) || (begin > 65535) || (end > 65535) || (begin >= end))
+ {
+ ServerInstance->Log(DEFAULT,"WARNING: Port range \"%d-%d\" discarded. begin >= end, or begin/end out of range.", begin, end);
+ }
+ else
+ {
+ for (int portval = begin; portval <= end; ++portval)
+ {
+ if (ServerInstance->Config->AddIOHook(portval, this))
+ {
+ listenports.push_back(portval);
+ ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", portval);
+ }
+ else
+ {
+ ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?",
+ portval);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (ServerInstance->Config->AddIOHook(atoi(portno.c_str()), this))
+ {
+ // We keep a record of which ports we're listening on with SSL
+ listenports.push_back(atoi(portno.c_str()));
+
+ ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %s", portno.c_str());
+ }
+ else
+ {
+ ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %s, maybe you have another ssl or similar module loaded?", portno.c_str());
+ }
+ }
}
}
}