diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_abbreviation.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_dccallow.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_globalload.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_hideoper.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_httpd.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_md5.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 51 |
12 files changed, 104 insertions, 10 deletions
diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index 77d86cb31..d2fa09c4e 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -67,7 +67,7 @@ class ModuleAbbreviation : public Module /* Ambiguous command, list the matches */ if (!matchlist.empty()) { - user->WriteNumeric(420, ":Ambiguous abbreviation, posssible matches: %s%s", foundcommand.c_str(), matchlist.c_str()); + user->WriteNumeric(420, ":Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str()); return MOD_RES_DENY; } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 8ae30bfed..6f9c32fb1 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -73,8 +73,10 @@ class CommandCheck : public Command { char timebuf[60]; struct tm *mytime = gmtime(&time); - strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (%s)", mytime); - return std::string(timebuf); + strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (", mytime); + std::string ret(timebuf); + ret.append(ConvToStr(time)).push_back(')'); + return ret; } void dumpExt(User* user, const std::string& checkstr, Extensible* ext) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 2b8d1306c..f011fa449 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -318,6 +318,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"); @@ -325,6 +328,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_globalload.cpp b/src/modules/m_globalload.cpp index 8ee8472e6..a3f3242f0 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -155,7 +155,7 @@ class CommandGreloadmodule : public Command if (m) { GReloadModuleWorker* worker = NULL; - if (m != creator) + if ((m != creator) && (!creator->dying)) worker = new GReloadModuleWorker(user->nick, user->uuid, parameters[0]); ServerInstance->Modules->Reload(m, worker); } diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 5b226f3b8..81b9b888f 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -68,7 +68,11 @@ class ModuleHideOper : public Module if (user->IsModeSet(hm) && !source->HasPrivPermission("users/auspex")) { // hide the "*" that marks the user as an oper from the /WHO line - std::string::size_type pos = line.find("*"); + std::string::size_type spcolon = line.find(" :"); + if (spcolon == std::string::npos) + return; // Another module hid the user completely + std::string::size_type sp = line.rfind(' ', spcolon-1); + std::string::size_type pos = line.find('*', sp); if (pos != std::string::npos) line.erase(pos, 1); // hide the line completely if doing a "/who * o" query diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index e09ca3fa2..aa83b120c 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -407,6 +407,20 @@ class ModuleHttpServer : public Module return MOD_RES_ALLOW; } + void OnUnloadModule(Module* mod) + { + for (insp::intrusive_list<HttpServerSocket>::const_iterator i = sockets.begin(); i != sockets.end(); ++i) + { + HttpServerSocket* sock = *i; + ++i; + if (sock->GetIOHook() && sock->GetIOHook()->prov->creator == mod) + { + sock->cull(); + delete sock; + } + } + } + CullResult cull() CXX11_OVERRIDE { for (insp::intrusive_list<HttpServerSocket>::const_iterator i = sockets.begin(); i != sockets.end(); ++i) diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index 6e6f5006f..6cec05a18 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -154,7 +154,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_operprefix.cpp b/src/modules/m_operprefix.cpp index 4c63e53d1..51281a528 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -72,6 +72,20 @@ class ModuleOperPrefixMode : public Module return MOD_RES_PASSTHRU; } + void OnPostJoin(Membership* memb) + { + if ((!IS_LOCAL(memb->user)) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode))) + return; + + if (memb->hasMode(opm.GetModeChar())) + return; + + // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now. + Modes::ChangeList changelist; + changelist.push_add(&opm, memb->user->nick); + ServerInstance->Modes.Process(ServerInstance->FakeClient, memb->chan, NULL, changelist); + } + void SetOperPrefix(User* user, bool add) { Modes::ChangeList changelist; diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index c96b87034..341b3aea7 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -96,6 +96,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") @@ -285,7 +288,7 @@ class ModuleSASL : public Module Version GetVersion() CXX11_OVERRIDE { - 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); } }; diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 25c1f6678..e29aa09d7 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -129,8 +129,8 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) time_t ourTS = chan->age; if (TS != ourTS) { - ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %lu", - chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS)); + ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %ld", + chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (long)(ourTS - TS)); /* If our TS is less than theirs, we dont accept their modes */ if (ourTS < TS) { diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index d0c6401cd..afd86c0ce 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -40,7 +40,7 @@ TreeServer::TreeServer() , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), isdead(false) , pingtimer(this) , ServerUser(ServerInstance->FakeClient) - , age(ServerInstance->Time()), UserCount(ServerInstance->Users.GetLocalUsers().size()) + , age(ServerInstance->Time()), UserCount(ServerInstance->Users.LocalUserCount()) , OperCount(0), rtt(0), StartBurst(0), Hidden(false) { AddHashEntry(); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 803156446..8196d37ba 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -21,6 +21,7 @@ #include "inspircd.h" +#include "listmode.h" /** Holds a timed ban */ @@ -30,6 +31,7 @@ class TimedBan std::string channel; std::string mask; time_t expire; + Channel* chan; }; typedef std::vector<TimedBan> timedbans; @@ -39,8 +41,28 @@ timedbans TimedBanList; */ class CommandTban : public Command { + ChanModeReference banmode; + + bool IsBanSet(Channel* chan, const std::string& mask) + { + ListModeBase* banlm = static_cast<ListModeBase*>(*banmode); + const ListModeBase::ModeList* bans = banlm->GetList(chan); + if (bans) + { + for (ListModeBase::ModeList::const_iterator i = bans->begin(); i != bans->end(); ++i) + { + const ListModeBase::ListItem& ban = *i; + if (!strcasecmp(ban.mask.c_str(), mask.c_str())) + return true; + } + } + + return false; + } + public: CommandTban(Module* Creator) : Command(Creator,"TBAN", 3) + , banmode(Creator, "ban") { syntax = "<channel> <duration> <banmask>"; } @@ -75,6 +97,12 @@ class CommandTban : public Command if (!isextban && !InspIRCd::IsValidMask(mask)) mask.append("!*@*"); + if (IsBanSet(channel, mask)) + { + user->WriteNotice("Ban already set"); + return CMD_FAILURE; + } + Modes::ChangeList setban; setban.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask); // Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to @@ -90,6 +118,7 @@ class CommandTban : public Command 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 @@ -134,6 +163,22 @@ class BanWatcher : public ModeWatcher } }; +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; @@ -179,6 +224,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()); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Adds timed bans", VF_COMMON | VF_VENDOR); |