summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp9
-rw-r--r--src/modules/m_dccallow.cpp6
-rw-r--r--src/modules/m_md5.cpp2
-rw-r--r--src/modules/m_nationalchars.cpp19
-rw-r--r--src/modules/m_restrictmsg.cpp12
-rw-r--r--src/modules/m_sasl.cpp5
-rw-r--r--src/modules/m_timedbans.cpp51
7 files changed, 88 insertions, 16 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 3b67a6180..59ac1acb3 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -316,7 +316,7 @@ class ModuleSSLGnuTLS : public Module
ServerInstance->GenRandom = &randhandler;
Implementation eventlist[] = { I_On005Numeric, I_OnRehash, I_OnModuleRehash, I_OnUserConnect,
- I_OnEvent, I_OnHookIO };
+ I_OnEvent, I_OnHookIO, I_OnCheckReady };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
ServerInstance->Modules->AddService(iohook);
@@ -974,6 +974,13 @@ info_done_dealloc:
if (starttls.enabled)
capHandler.HandleEvent(ev);
}
+
+ ModResult OnCheckReady(LocalUser* user)
+ {
+ if ((user->eh.GetIOHook() == this) && (sessions[user->eh.GetFd()].status != ISSL_HANDSHAKEN))
+ return MOD_RES_DENY;
+ return MOD_RES_PASSTHRU;
+ }
};
MODULE_INIT(ModuleSSLGnuTLS)
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index b42d12968..829c1d337 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -339,6 +339,9 @@ class ModuleDCCAllow : public Module
while (ss >> buf)
tokens.push_back(buf);
+ if (tokens.size() < 2)
+ return MOD_RES_PASSTHRU;
+
irc::string type = tokens[1].c_str();
ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow");
@@ -346,6 +349,9 @@ class ModuleDCCAllow : public Module
if (type == "SEND")
{
+ if (tokens.size() < 3)
+ return MOD_RES_PASSTHRU;
+
std::string defaultaction = conftag->getString("action");
std::string filename = tokens[2];
diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp
index 14ccf16a8..c902ee3cb 100644
--- a/src/modules/m_md5.cpp
+++ b/src/modules/m_md5.cpp
@@ -163,7 +163,7 @@ class MD5Provider : public HashProvider
void MD5Transform(word32 buf[4], word32 const in[16])
{
- register word32 a, b, c, d;
+ word32 a, b, c, d;
a = buf[0];
b = buf[1];
diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp
index bf95f0f9f..bc90c9fad 100644
--- a/src/modules/m_nationalchars.cpp
+++ b/src/modules/m_nationalchars.cpp
@@ -284,11 +284,19 @@ class ModuleNationalChars : public Module
{
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
charset = tag->getString("file");
- casemapping = tag->getString("casemapping", charset);
+ casemapping = tag->getString("casemapping", ServerConfig::CleanFilename(charset.c_str()));
+ if (casemapping.find(' ') != std::string::npos)
+ throw ModuleException("<nationalchars:casemapping> must not contain any spaces!");
+#if defined _WIN32
+ if (!ServerInstance->Config->StartsWithWindowsDriveLetter(charset))
+ charset.insert(0, "./locales/");
+#else
if(charset[0] != '/')
charset.insert(0, "../locales/");
+#endif
unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
- loadtables(charset, tables, 8, 5);
+ if (!loadtables(charset, tables, 8, 5))
+ throw ModuleException("The locale file failed to load. Check your log file for more information.");
forcequit = tag->getBool("forcequit");
CheckForceQuit("National character set changed");
CheckRehash();
@@ -330,13 +338,13 @@ class ModuleNationalChars : public Module
}
/*so Bynets Unreal distribution stuff*/
- void loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
+ bool loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
{
std::ifstream ifs(filename.c_str());
if (ifs.fail())
{
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for missing file: %s", filename.c_str());
- return;
+ return false;
}
for (unsigned char n=0; n< cnt; n++)
@@ -351,11 +359,12 @@ class ModuleNationalChars : public Module
if (loadtable(ifs, tables[n], 255) && (n < faillimit))
{
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
- return;
+ return false;
}
}
makereverse(m_additional, m_reverse_additional, sizeof(m_additional));
+ return true;
}
unsigned char symtoi(const char *t,unsigned char base)
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
index e814f3b16..2a9f1dc93 100644
--- a/src/modules/m_restrictmsg.cpp
+++ b/src/modules/m_restrictmsg.cpp
@@ -26,15 +26,22 @@
class ModuleRestrictMsg : public Module
{
+ private:
+ bool uline;
public:
void init()
{
- Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
+ OnRehash(NULL);
+ Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
+ void OnRehash(User*)
+ {
+ uline = ServerInstance->Config->ConfValue("restrictmsg")->getBool("uline", false);
+ }
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
@@ -45,8 +52,9 @@ class ModuleRestrictMsg : public Module
// message allowed if:
// (1) the sender is opered
// (2) the recipient is opered
+ // (3) the recipient is on a ulined server
// anything else, blocked.
- if (IS_OPER(u) || IS_OPER(user))
+ if (IS_OPER(u) || IS_OPER(user) || (uline && ServerInstance->ULine(u->server)))
{
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 66efcfe4e..32c9afc79 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -99,6 +99,9 @@ class SaslAuthenticator
if (msg[0] != this->agent)
return this->state;
+ if (msg.size() < 4)
+ return this->state;
+
if (msg[2] == "C")
this->user->Write("AUTHENTICATE %s", msg[3].c_str());
else if (msg[2] == "D")
@@ -290,7 +293,7 @@ class ModuleSASL : public Module
Version GetVersion()
{
- return Version("Provides support for IRC Authentication Layer (aka: atheme SASL) via AUTHENTICATE.",VF_VENDOR);
+ return Version("Provides support for IRC Authentication Layer (aka: SASL) via AUTHENTICATE.", VF_VENDOR);
}
void OnEvent(Event &ev)
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 497ac2569..b47327704 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -32,6 +32,7 @@ class TimedBan
std::string channel;
std::string mask;
time_t expire;
+ Channel* chan;
};
typedef std::vector<TimedBan> timedbans;
@@ -41,6 +42,16 @@ timedbans TimedBanList;
*/
class CommandTban : public Command
{
+ static bool IsBanSet(Channel* chan, const std::string& mask)
+ {
+ for (BanList::const_iterator i = chan->bans.begin(); i != chan->bans.end(); ++i)
+ {
+ if (!strcasecmp(i->data.c_str(), mask.c_str()))
+ return true;
+ }
+ return false;
+ }
+
public:
CommandTban(Module* Creator) : Command(Creator,"TBAN", 3)
{
@@ -85,19 +96,25 @@ class CommandTban : public Command
user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask");
return CMD_FAILURE;
}
+
+ if (IsBanSet(channel, mask))
+ {
+ user->WriteServ("NOTICE %s :Ban already set", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+
setban.push_back(mask);
// use CallHandler to make it so that the user sets the mode
// themselves
ServerInstance->Parser->CallHandler("MODE",setban,user);
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- if (!strcasecmp(i->data.c_str(), mask.c_str()))
- goto found;
- return CMD_FAILURE;
-found:
+ if (!IsBanSet(channel, mask))
+ return CMD_FAILURE;
+
CUList tmp;
T.channel = channelname;
T.mask = mask;
T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
+ T.chan = channel;
TimedBanList.push_back(T);
// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
@@ -114,6 +131,22 @@ found:
}
};
+class ChannelMatcher
+{
+ Channel* const chan;
+
+ public:
+ ChannelMatcher(Channel* ch)
+ : chan(ch)
+ {
+ }
+
+ bool operator()(const TimedBan& tb) const
+ {
+ return (tb.chan == chan);
+ }
+};
+
class ModuleTimedBans : public Module
{
CommandTban cmd;
@@ -126,7 +159,7 @@ class ModuleTimedBans : public Module
void init()
{
ServerInstance->Modules->AddService(cmd);
- Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer };
+ Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer, I_OnChannelDelete };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
@@ -183,6 +216,12 @@ class ModuleTimedBans : public Module
}
}
+ void OnChannelDelete(Channel* chan)
+ {
+ // Remove all timed bans affecting the channel from internal bookkeeping
+ TimedBanList.erase(std::remove_if(TimedBanList.begin(), TimedBanList.end(), ChannelMatcher(chan)), TimedBanList.end());
+ }
+
virtual Version GetVersion()
{
return Version("Adds timed bans", VF_COMMON | VF_VENDOR);