summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ldapoper.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp11
-rw-r--r--src/modules/m_alltime.cpp2
-rw-r--r--src/modules/m_blockamsg.cpp4
-rw-r--r--src/modules/m_blockcolor.cpp4
-rw-r--r--src/modules/m_botmode.cpp4
-rw-r--r--src/modules/m_callerid.cpp91
-rw-r--r--src/modules/m_cap.cpp32
-rw-r--r--src/modules/m_cap.h45
-rw-r--r--src/modules/m_chanhistory.cpp65
-rw-r--r--src/modules/m_chanlog.cpp20
-rw-r--r--src/modules/m_chgname.cpp10
-rw-r--r--src/modules/m_commonchans.cpp26
-rw-r--r--src/modules/m_dccallow.cpp21
-rw-r--r--src/modules/m_deaf.cpp4
-rw-r--r--src/modules/m_delaymsg.cpp20
-rw-r--r--src/modules/m_dnsbl.cpp22
-rw-r--r--src/modules/m_globops.cpp8
-rw-r--r--src/modules/m_halfop.cpp5
-rw-r--r--src/modules/m_helpop.cpp30
-rw-r--r--src/modules/m_hidechans.cpp26
-rw-r--r--src/modules/m_hideoper.cpp26
-rw-r--r--src/modules/m_ident.cpp23
-rw-r--r--src/modules/m_inviteexception.cpp22
-rw-r--r--src/modules/m_lockserv.cpp22
-rw-r--r--src/modules/m_mlock.cpp14
-rw-r--r--src/modules/m_noctcp.cpp49
-rw-r--r--src/modules/m_nonicks.cpp26
-rw-r--r--src/modules/m_nonotice.cpp4
-rw-r--r--src/modules/m_operchans.cpp25
-rw-r--r--src/modules/m_operlevels.cpp13
-rw-r--r--src/modules/m_opermodes.cpp27
-rw-r--r--src/modules/m_override.cpp4
-rw-r--r--src/modules/m_redirect.cpp50
-rw-r--r--src/modules/m_sajoin.cpp4
-rw-r--r--src/modules/m_samode.cpp4
-rw-r--r--src/modules/m_satopic.cpp3
-rw-r--r--src/modules/m_services_account.cpp11
-rw-r--r--src/modules/m_setname.cpp5
-rw-r--r--src/modules/m_showwhois.cpp26
-rw-r--r--src/modules/m_shun.cpp2
-rw-r--r--src/modules/m_spanningtree/addline.cpp2
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp1
-rw-r--r--src/modules/m_spanningtree/svspart.cpp16
-rw-r--r--src/modules/m_spanningtree/treesocket.h4
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp7
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
-rw-r--r--src/modules/m_sslmodes.cpp4
-rw-r--r--src/modules/m_stripcolor.cpp19
-rw-r--r--src/modules/m_swhois.cpp7
-rw-r--r--src/modules/m_xline_db.cpp2
52 files changed, 366 insertions, 516 deletions
diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp
index 6bd834dc8..6eade1fbd 100644
--- a/src/modules/extra/m_ldapoper.cpp
+++ b/src/modules/extra/m_ldapoper.cpp
@@ -32,7 +32,7 @@
# pragma comment(lib, "lber.lib")
#endif
-/* $ModDesc: Allow/Deny connections based upon answer from LDAP server */
+/* $ModDesc: Adds the ability to authenticate opers via LDAP */
/* $LinkerFlags: -lldap */
class ModuleLDAPAuth : public Module
@@ -181,7 +181,7 @@ public:
virtual Version GetVersion()
{
- return Version("Allow/Deny connections based upon answer from LDAP server", VF_VENDOR);
+ return Version("Adds the ability to authenticate opers via LDAP", VF_VENDOR);
}
};
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 6ca876d4c..c631642ce 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -28,6 +28,17 @@
#include "ssl.h"
#include "m_cap.h"
+#ifdef WINDOWS
+# pragma comment(lib, "libgnutls.lib")
+# pragma comment(lib, "libgcrypt.lib")
+# pragma comment(lib, "libgpg-error.lib")
+# pragma comment(lib, "user32.lib")
+# pragma comment(lib, "advapi32.lib")
+# pragma comment(lib, "libgcc.lib")
+# pragma comment(lib, "libmingwex.lib")
+# pragma comment(lib, "gdi32.lib")
+#endif
+
/* $ModDesc: Provides SSL support for clients */
/* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") */
/* $LinkerFlags: rpath("pkg-config --libs gnutls") pkgconflibs("gnutls","/libgnutls.so","-lgnutls") -lgcrypt */
diff --git a/src/modules/m_alltime.cpp b/src/modules/m_alltime.cpp
index aba8fe7fe..7012fde7e 100644
--- a/src/modules/m_alltime.cpp
+++ b/src/modules/m_alltime.cpp
@@ -38,7 +38,7 @@ class CommandAlltime : public Command
time_t now = ServerInstance->Time();
strftime(fmtdate, sizeof(fmtdate), "%Y-%m-%d %H:%M:%S", gmtime(&now));
- std::string msg = ":" + std::string(ServerInstance->Config->ServerName.c_str()) + " NOTICE " + user->nick + " :System time is " + fmtdate + "(" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
+ std::string msg = ":" + std::string(ServerInstance->Config->ServerName.c_str()) + " NOTICE " + user->nick + " :System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
user->SendText(msg);
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 1d26b7639..8160fcf54 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -98,8 +98,8 @@ class ModuleBlockAmsg : public Module
virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
{
- // Don't do anything with unregistered users, or remote ones.
- if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
+ // Don't do anything with unregistered users
+ if (user->registered != REG_ALL)
return MOD_RES_PASSTHRU;
// We want case insensitive command comparison.
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index f2ba0603f..19b5c9231 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -23,7 +23,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style channel mode +c */
+/* $ModDesc: Provides channel mode +c to block color */
/** Handles the +c channel mode
*/
@@ -95,7 +95,7 @@ class ModuleBlockColor : public Module
virtual Version GetVersion()
{
- return Version("Provides support for unreal-style channel mode +c",VF_VENDOR);
+ return Version("Provides channel mode +c to block color",VF_VENDOR);
}
};
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp
index c7a51beb9..5871b9227 100644
--- a/src/modules/m_botmode.cpp
+++ b/src/modules/m_botmode.cpp
@@ -21,7 +21,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style umode +B */
+/* $ModDesc: Provides user mode +B to mark the user as a bot */
/** Handles user mode +B
*/
@@ -51,7 +51,7 @@ class ModuleBotMode : public Module
virtual Version GetVersion()
{
- return Version("Provides support for unreal-style umode +B",VF_VENDOR);
+ return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR);
}
virtual void OnWhois(User* src, User* dst)
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 416ede9a1..f24c38b65 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -21,11 +21,8 @@
#include "inspircd.h"
-#include <set>
-#include <sstream>
-#include <algorithm>
-/* $ModDesc: Implementation of callerid (umode +g & /accept, ala hybrid etc) */
+/* $ModDesc: Implementation of callerid, usermode +g, /accept */
class callerid_data
{
@@ -57,11 +54,8 @@ class callerid_data
}
User *u = ServerInstance->FindNick(tok);
- if (!u)
- {
- continue;
- }
- accepting.insert(u);
+ if ((u) && (u->registered == REG_ALL) && (!u->quitting) && (!IS_SERVER(u)))
+ accepting.insert(u);
}
}
@@ -121,14 +115,9 @@ struct CallerIDExtInfo : public ExtensionItem
if (!targ)
continue; // shouldn't happen, but oh well.
- for (std::list<callerid_data *>::iterator it2 = targ->wholistsme.begin(); it2 != targ->wholistsme.end(); it2++)
- {
- if (*it2 == dat)
- {
- targ->wholistsme.erase(it2);
- break;
- }
- }
+ std::list<callerid_data*>::iterator it2 = std::find(targ->wholistsme.begin(), targ->wholistsme.end(), dat);
+ if (it2 != targ->wholistsme.end())
+ targ->wholistsme.erase(it2);
}
}
};
@@ -173,18 +162,12 @@ public:
tok.erase(0, 1); // Remove the dash.
}
User* u = ServerInstance->FindNick(tok);
- if (u)
- {
- if (dash)
- out.append("-");
- out.append(u->uuid);
- }
- else
- {
- if (dash)
- out.append("-");
- out.append(tok);
- }
+ if ((!u) || (u->registered != REG_ALL) || (u->quitting) || (IS_SERVER(u)))
+ continue;
+
+ if (dash)
+ out.append("-");
+ out.append(u->uuid);
}
parameter = out;
}
@@ -213,15 +196,15 @@ public:
{
User* whotoremove = ServerInstance->FindNick(tok.substr(1));
if (whotoremove)
- return (RemoveAccept(user, whotoremove, false) ? CMD_SUCCESS : CMD_FAILURE);
+ return (RemoveAccept(user, whotoremove) ? CMD_SUCCESS : CMD_FAILURE);
else
return CMD_FAILURE;
}
else
{
User* whotoadd = ServerInstance->FindNick(tok[0] == '+' ? tok.substr(1) : tok);
- if (whotoadd)
- return (AddAccept(user, whotoadd, false) ? CMD_SUCCESS : CMD_FAILURE);
+ if ((whotoadd) && (whotoadd->registered == REG_ALL) && (!whotoadd->quitting) && (!IS_SERVER(whotoadd)))
+ return (AddAccept(user, whotoadd) ? CMD_SUCCESS : CMD_FAILURE);
else
{
user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), tok.c_str());
@@ -246,22 +229,18 @@ public:
user->WriteNumeric(282, "%s :End of ACCEPT list", user->nick.c_str());
}
- bool AddAccept(User* user, User* whotoadd, bool quiet)
+ bool AddAccept(User* user, User* whotoadd)
{
// Add this user to my accept list first, so look me up..
callerid_data* dat = extInfo.get(user, true);
if (dat->accepting.size() >= maxaccepts)
{
- if (!quiet)
- user->WriteNumeric(456, "%s :Accept list is full (limit is %d)", user->nick.c_str(), maxaccepts);
-
+ user->WriteNumeric(456, "%s :Accept list is full (limit is %d)", user->nick.c_str(), maxaccepts);
return false;
}
if (!dat->accepting.insert(whotoadd).second)
{
- if (!quiet)
- user->WriteNumeric(457, "%s %s :is already on your accept list", user->nick.c_str(), whotoadd->nick.c_str());
-
+ user->WriteNumeric(457, "%s %s :is already on your accept list", user->nick.c_str(), whotoadd->nick.c_str());
return false;
}
@@ -273,23 +252,19 @@ public:
return true;
}
- bool RemoveAccept(User* user, User* whotoremove, bool quiet)
+ bool RemoveAccept(User* user, User* whotoremove)
{
// Remove them from my list, so look up my list..
callerid_data* dat = extInfo.get(user, false);
if (!dat)
{
- if (!quiet)
- user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
-
+ user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
return false;
}
std::set<User*>::iterator i = dat->accepting.find(whotoremove);
if (i == dat->accepting.end())
{
- if (!quiet)
- user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
-
+ user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
return false;
}
@@ -303,15 +278,10 @@ public:
return false;
}
- for (std::list<callerid_data *>::iterator it = dat2->wholistsme.begin(); it != dat2->wholistsme.end(); it++)
- {
+ std::list<callerid_data*>::iterator it = std::find(dat2->wholistsme.begin(), dat2->wholistsme.end(), dat);
+ if (it != dat2->wholistsme.end())
// Found me!
- if (*it == dat)
- {
- dat2->wholistsme.erase(it);
- break;
- }
- }
+ dat2->wholistsme.erase(it);
user->WriteServ("NOTICE %s :%s is no longer on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
return true;
@@ -367,7 +337,7 @@ public:
ServerInstance->Modules->AddService(cmd);
ServerInstance->Modules->AddService(cmd.extInfo);
- Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
+ Implementation eventlist[] = { I_OnRehash, I_OnUserPostNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
@@ -377,7 +347,7 @@ public:
virtual Version GetVersion()
{
- return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR);
+ return Version("Implementation of callerid, usermode +g, /accept", VF_COMMON | VF_VENDOR);
}
virtual void On005Numeric(std::string& output)
@@ -385,7 +355,7 @@ public:
output += " CALLERID=g";
}
- ModResult PreText(User* user, User* dest, std::string& text, bool notice)
+ ModResult PreText(User* user, User* dest, std::string& text)
{
if (!dest->IsModeSet('g'))
return MOD_RES_PASSTHRU;
@@ -416,7 +386,7 @@ public:
virtual ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list)
{
if (IS_LOCAL(user) && target_type == TYPE_USER)
- return PreText(user, (User*)dest, text, true);
+ return PreText(user, (User*)dest, text);
return MOD_RES_PASSTHRU;
}
@@ -424,16 +394,15 @@ public:
virtual ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list)
{
if (IS_LOCAL(user) && target_type == TYPE_USER)
- return PreText(user, (User*)dest, text, true);
+ return PreText(user, (User*)dest, text);
return MOD_RES_PASSTHRU;
}
- ModResult OnUserPreNick(User* user, const std::string& newnick)
+ void OnUserPostNick(User* user, const std::string& oldnick)
{
if (!tracknick)
RemoveFromAllAccepts(user);
- return MOD_RES_PASSTHRU;
}
void OnUserQuit(User* user, const std::string& message, const std::string& oper_message)
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index 36674b9c5..662e128a4 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -55,19 +55,14 @@ class CommandCAP : public Command
if (subcommand == "REQ")
{
- CapEvent Data(creator, "cap_req");
-
- Data.type = subcommand;
- Data.user = user;
- Data.creator = this->creator;
-
if (parameters.size() < 2)
return CMD_FAILURE;
+ CapEvent Data(creator, user, CapEvent::CAPEVENT_REQ);
+
// tokenize the input into a nice list of requested caps
- std::string param = parameters[1];
std::string cap_;
- irc::spacesepstream cap_stream(param);
+ irc::spacesepstream cap_stream(parameters[1]);
while (cap_stream.GetToken(cap_))
{
@@ -95,11 +90,7 @@ class CommandCAP : public Command
}
else if ((subcommand == "LS") || (subcommand == "LIST"))
{
- CapEvent Data(creator, subcommand == "LS" ? "cap_ls" : "cap_list");
-
- Data.type = subcommand;
- Data.user = user;
- Data.creator = this->creator;
+ CapEvent Data(creator, user, subcommand == "LS" ? CapEvent::CAPEVENT_LS : CapEvent::CAPEVENT_LIST);
reghold.set(user, 1);
Data.Send();
@@ -107,31 +98,28 @@ class CommandCAP : public Command
std::string Result;
if (Data.wanted.size() > 0)
Result = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
- else
- Result = "";
user->WriteServ("CAP %s %s :%s", user->nick.c_str(), subcommand.c_str(), Result.c_str());
}
else if (subcommand == "CLEAR")
{
- CapEvent Data(creator, "cap_clear");
-
- Data.type = subcommand;
- Data.user = user;
- Data.creator = this->creator;
+ CapEvent Data(creator, user, CapEvent::CAPEVENT_CLEAR);
reghold.set(user, 1);
Data.Send();
- std::string Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+ std::string Result;
+ if (!Data.ack.empty())
+ Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), Result.c_str());
}
else
{
user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.c_str());
+ return CMD_FAILURE;
}
- return CMD_FAILURE;
+ return CMD_SUCCESS;
}
};
diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h
index 604fdb0ef..ce7e7f394 100644
--- a/src/modules/m_cap.h
+++ b/src/modules/m_cap.h
@@ -21,18 +21,22 @@
#ifndef M_CAP_H
#define M_CAP_H
-#include <map>
-#include <string>
-
class CapEvent : public Event
{
public:
- irc::string type;
+ enum CapEventType
+ {
+ CAPEVENT_REQ,
+ CAPEVENT_LS,
+ CAPEVENT_LIST,
+ CAPEVENT_CLEAR
+ };
+
+ CapEventType type;
std::vector<std::string> wanted;
std::vector<std::string> ack;
User* user;
- Module* creator;
- CapEvent(Module* sender, const std::string& t) : Event(sender, t) {}
+ CapEvent(Module* sender, User* u, CapEventType capevtype) : Event(sender, "cap_request"), type(capevtype), user(u) {}
};
class GenericCap
@@ -47,28 +51,37 @@ class GenericCap
void HandleEvent(Event& ev)
{
+ if (ev.id != "cap_request")
+ return;
+
CapEvent *data = static_cast<CapEvent*>(&ev);
- if (ev.id == "cap_req")
+ if (data->type == CapEvent::CAPEVENT_REQ)
{
- std::vector<std::string>::iterator it;
- if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end())
+ for (std::vector<std::string>::iterator it = data->wanted.begin(); it != data->wanted.end(); ++it)
{
- // we can handle this, so ACK it, and remove it from the wanted list
- data->ack.push_back(*it);
- data->wanted.erase(it);
- ext.set(data->user, 1);
+ if (it->empty())
+ continue;
+ bool enablecap = ((*it)[0] != '-');
+ if (((enablecap) && (*it == cap)) || (*it == "-" + cap))
+ {
+ // we can handle this, so ACK it, and remove it from the wanted list
+ data->ack.push_back(*it);
+ data->wanted.erase(it);
+ ext.set(data->user, enablecap ? 1 : 0);
+ break;
+ }
}
}
- else if (ev.id == "cap_ls")
+ else if (data->type == CapEvent::CAPEVENT_LS)
{
data->wanted.push_back(cap);
}
- else if (ev.id == "cap_list")
+ else if (data->type == CapEvent::CAPEVENT_LIST)
{
if (ext.get(data->user))
data->wanted.push_back(cap);
}
- else if (ev.id == "cap_clear")
+ else if (data->type == CapEvent::CAPEVENT_CLEAR)
{
data->ack.push_back("-" + cap);
ext.set(data->user, 0);
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index 9275152ea..16eba953f 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -37,9 +37,23 @@ struct HistoryList
class HistoryMode : public ModeHandler
{
+ bool IsValidDuration(const std::string duration)
+ {
+ for (std::string::const_iterator i = duration.begin(); i != duration.end(); ++i)
+ {
+ unsigned char c = *i;
+ if (((c >= '0') && (c <= '9')) || (c == 's') || (c != 'S'))
+ continue;
+
+ if (duration_multi[c] == 1)
+ return false;
+ }
+ return true;
+ }
+
public:
SimpleExtItem<HistoryList> ext;
- int maxlines;
+ unsigned int maxlines;
HistoryMode(Module* Creator) : ModeHandler(Creator, "history", 'H', PARAM_SETONLY, MODETYPE_CHANNEL),
ext("history", Creator) { }
@@ -50,9 +64,14 @@ class HistoryMode : public ModeHandler
std::string::size_type colon = parameter.find(':');
if (colon == std::string::npos)
return MODEACTION_DENY;
- int len = atoi(parameter.substr(0, colon).c_str());
- int time = ServerInstance->Duration(parameter.substr(colon+1));
- if (len <= 0 || time < 0)
+
+ std::string duration = parameter.substr(colon+1);
+ if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!IsValidDuration(duration))))
+ return MODEACTION_DENY;
+
+ unsigned int len = ConvToInt(parameter.substr(0, colon));
+ int time = ServerInstance->Duration(duration);
+ if (len == 0 || time < 0)
return MODEACTION_DENY;
if (len > maxlines && IS_LOCAL(source))
return MODEACTION_DENY;
@@ -60,7 +79,21 @@ class HistoryMode : public ModeHandler
len = maxlines;
if (parameter == channel->GetModeParameter(this))
return MODEACTION_DENY;
- ext.set(channel, new HistoryList(len, time));
+
+ HistoryList* history = ext.get(channel);
+ if (history)
+ {
+ // Shrink the list if the new line number limit is lower than the old one
+ if (len < history->lines.size())
+ history->lines.erase(history->lines.begin(), history->lines.begin() + (history->lines.size() - len));
+
+ history->maxlen = len;
+ history->maxtime = time;
+ }
+ else
+ {
+ ext.set(channel, new HistoryList(len, time));
+ }
channel->SetModeParam('H', parameter);
}
else
@@ -77,6 +110,7 @@ class HistoryMode : public ModeHandler
class ModuleChanHistory : public Module
{
HistoryMode m;
+ bool sendnotice;
public:
ModuleChanHistory() : m(this)
{
@@ -93,12 +127,9 @@ class ModuleChanHistory : public Module
void OnRehash(User*)
{
- m.maxlines = ServerInstance->Config->ConfValue("chanhistory")->getInt("maxlines", 50);
- }
-
- ~ModuleChanHistory()
- {
- ServerInstance->Modes->DelMode(&m);
+ ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory");
+ m.maxlines = tag->getInt("maxlines", 50);
+ sendnotice = tag->getBool("notice", true);
}
void OnUserMessage(User* user,void* dest,int target_type, const std::string &text, char status, const CUList&)
@@ -121,14 +152,22 @@ class ModuleChanHistory : public Module
void OnPostJoin(Membership* memb)
{
+ if (IS_REMOTE(memb->user))
+ return;
+
HistoryList* list = m.ext.get(memb->chan);
if (!list)
return;
time_t mintime = 0;
if (list->maxtime)
mintime = ServerInstance->Time() - list->maxtime;
- memb->user->WriteServ("NOTICE %s :Replaying up to %d lines of pre-join history spanning up to %d seconds",
- memb->chan->name.c_str(), list->maxlen, list->maxtime);
+
+ if (sendnotice)
+ {
+ memb->user->WriteServ("NOTICE %s :Replaying up to %d lines of pre-join history spanning up to %d seconds",
+ memb->chan->name.c_str(), list->maxlen, list->maxtime);
+ }
+
for(std::deque<HistoryItem>::iterator i = list->lines.begin(); i != list->lines.end(); ++i)
{
if (i->ts >= mintime)
diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp
index ed5063fad..29385b8e2 100644
--- a/src/modules/m_chanlog.cpp
+++ b/src/modules/m_chanlog.cpp
@@ -28,7 +28,8 @@ class ModuleChanLog : public Module
/*
* Multimap so people can redirect a snomask to multiple channels.
*/
- std::multimap<char, std::string> logstreams;
+ typedef std::multimap<char, std::string> ChanLogTargets;
+ ChanLogTargets logstreams;
public:
ModuleChanLog() {
@@ -72,30 +73,21 @@ class ModuleChanLog : public Module
virtual ModResult OnSendSnotice(char &sno, std::string &desc, const std::string &msg)
{
- std::multimap<char, std::string>::const_iterator it = logstreams.find(sno);
- char buf[MAXBUF];
-
- if (it == logstreams.end())
+ std::pair<ChanLogTargets::const_iterator, ChanLogTargets::const_iterator> itpair = logstreams.equal_range(sno);
+ if (itpair.first == itpair.second)
return MOD_RES_PASSTHRU;
+ char buf[MAXBUF];
snprintf(buf, MAXBUF, "\2%s\2: %s", desc.c_str(), msg.c_str());
- while (it != logstreams.end())
+ for (ChanLogTargets::const_iterator it = itpair.first; it != itpair.second; ++it)
{
- if (it->first != sno)
- {
- it++;
- continue;
- }
-
Channel *c = ServerInstance->FindChan(it->second);
if (c)
{
c->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "PRIVMSG %s :%s", c->name.c_str(), buf);
ServerInstance->PI->SendChannelPrivmsg(c, 0, buf);
}
-
- it++;
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp
index 194ecf80e..2ac24c5d5 100644
--- a/src/modules/m_chgname.cpp
+++ b/src/modules/m_chgname.cpp
@@ -44,16 +44,22 @@ class CommandChgname : public Command
return CMD_FAILURE;
}
+ if (parameters[1].empty())
+ {
+ user->WriteServ("NOTICE %s :*** CHGNAME: GECOS must be specified", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+
if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
{
- user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str());
+ user->WriteServ("NOTICE %s :*** CHGNAME: GECOS too long", user->nick.c_str());
return CMD_FAILURE;
}
if (IS_LOCAL(dest))
{
dest->ChangeName(parameters[1].c_str());
- ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's real name to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
+ ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's GECOS to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
}
return CMD_SUCCESS;
diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp
index ac8a7ba29..877ba87d7 100644
--- a/src/modules/m_commonchans.cpp
+++ b/src/modules/m_commonchans.cpp
@@ -23,32 +23,10 @@
/** Handles user mode +c
*/
-class PrivacyMode : public ModeHandler
+class PrivacyMode : public SimpleUserModeHandler
{
public:
- PrivacyMode(Module* Creator) : ModeHandler(Creator, "deaf_commonchan", 'c', PARAM_NONE, MODETYPE_USER) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!dest->IsModeSet('c'))
- {
- dest->SetMode('c',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (dest->IsModeSet('c'))
- {
- dest->SetMode('c',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
+ PrivacyMode(Module* Creator) : SimpleUserModeHandler(Creator, "deaf_commonchan", 'c') { }
};
class ModulePrivacyMode : public Module
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 8c2a5f73e..0cea96154 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -102,7 +102,7 @@ class CommandDccallow : public Command
std::string nick = parameters[0].substr(1);
User *target = ServerInstance->FindNickOnly(nick);
- if (target)
+ if ((target) && (!IS_SERVER(target)) && (!target->quitting) && (target->registered == REG_ALL))
{
if (action == '-')
@@ -257,7 +257,7 @@ class ModuleDCCAllow : public Module
ServerInstance->Extensions.Register(ext);
ServerInstance->AddCommand(&cmd);
ReadFileConf();
- Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash };
+ Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPostNick, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -274,7 +274,9 @@ class ModuleDCCAllow : public Module
// remove their DCCALLOW list if they have one
if (udl)
{
- RemoveFromUserlist(user);
+ userlist::iterator it = std::find(ul.begin(), ul.end(), user);
+ if (it != ul.end())
+ ul.erase(it);
}
// remove them from any DCCALLOW lists
@@ -282,10 +284,9 @@ class ModuleDCCAllow : public Module
RemoveNick(user);
}
- virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
+ virtual void OnUserPostNick(User* user, const std::string &oldnick)
{
RemoveNick(user);
- return MOD_RES_PASSTHRU;
}
virtual ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
@@ -381,7 +382,7 @@ class ModuleDCCAllow : public Module
void Expire()
{
- for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
+ for (userlist::iterator iter = ul.begin(); iter != ul.end();)
{
User* u = (User*)(*iter);
dl = ext->get(u);
@@ -403,10 +404,11 @@ class ModuleDCCAllow : public Module
}
}
}
+ ++iter;
}
else
{
- RemoveFromUserlist(u);
+ iter = ul.erase(iter);
}
}
}
@@ -414,7 +416,7 @@ class ModuleDCCAllow : public Module
void RemoveNick(User* user)
{
/* Iterate through all DCCALLOW lists and remove user */
- for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
+ for (userlist::iterator iter = ul.begin(); iter != ul.end();)
{
User *u = (User*)(*iter);
dl = ext->get(u);
@@ -434,10 +436,11 @@ class ModuleDCCAllow : public Module
}
}
}
+ ++iter;
}
else
{
- RemoveFromUserlist(u);
+ iter = ul.erase(iter);
}
}
}
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 0a002bd07..3e0d205ba 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -21,7 +21,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for ircu style usermode +d (deaf to channel messages and channel notices) */
+/* $ModDesc: Provides usermode +d to block channel messages and channel notices */
/** User mode +d - filter out channel messages and channel notices
*/
@@ -163,7 +163,7 @@ class ModuleDeaf : public Module
virtual Version GetVersion()
{
- return Version("Provides support for ircu style usermode +d (deaf to channel messages and channel notices)", VF_VENDOR);
+ return Version("Provides usermode +d to block channel messages and channel notices", VF_VENDOR);
}
};
diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp
index 6ef955a9f..1a0734ed9 100644
--- a/src/modules/m_delaymsg.cpp
+++ b/src/modules/m_delaymsg.cpp
@@ -18,14 +18,11 @@
#include "inspircd.h"
-#include <stdarg.h>
/* $ModDesc: Provides channelmode +d <int>, to deny messages to a channel until <int> seconds. */
class DelayMsgMode : public ModeHandler
{
- private:
- CUList empty;
public:
LocalIntExt jointime;
DelayMsgMode(Module* Parent) : ModeHandler(Parent, "delaymsg", 'd', PARAM_SETONLY, MODETYPE_CHANNEL)
@@ -55,7 +52,6 @@ class ModuleDelayMsg : public Module
Implementation eventlist[] = { I_OnUserJoin, I_OnUserPreMessage};
ServerInstance->Modules->Attach(eventlist, this, 2);
}
- ~ModuleDelayMsg();
Version GetVersion();
void OnUserJoin(Membership* memb, bool sync, bool created, CUList&);
ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list);
@@ -65,6 +61,9 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
{
if (adding)
{
+ if ((channel->IsModeSet('d')) && (channel->GetModeParameter('d') == parameter))
+ return MODEACTION_DENY;
+
/* Setting a new limit, sanity check */
long limit = atoi(parameter.c_str());
@@ -76,6 +75,9 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
}
else
{
+ if (!channel->IsModeSet('d'))
+ return MODEACTION_DENY;
+
/*
* Clean up metadata
*/
@@ -87,10 +89,6 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
return MODEACTION_ALLOW;
}
-ModuleDelayMsg::~ModuleDelayMsg()
-{
-}
-
Version ModuleDelayMsg::GetVersion()
{
return Version("Provides channelmode +d <int>, to deny messages to a channel until <int> seconds.", VF_VENDOR);
@@ -98,7 +96,7 @@ Version ModuleDelayMsg::GetVersion()
void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CUList&)
{
- if (memb->chan->IsModeSet('d'))
+ if ((IS_LOCAL(memb->user)) && (memb->chan->IsModeSet('d')))
{
djm.jointime.set(memb, ServerInstance->Time());
}
@@ -107,7 +105,7 @@ void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CULis
ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
{
/* Server origin */
- if (!user)
+ if ((!user) || (!IS_LOCAL(user)))
return MOD_RES_PASSTHRU;
if (target_type != TYPE_CHANNEL)
@@ -118,7 +116,7 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty
if (!memb)
return MOD_RES_PASSTHRU;
-
+
time_t ts = djm.jointime.get(memb);
if (ts == 0)
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 6a41c484f..2160b02dc 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -243,7 +243,7 @@ class ModuleDNSBL : public Module
ReadConf();
ServerInstance->Modules->AddService(nameExt);
ServerInstance->Modules->AddService(countExt);
- Implementation eventlist[] = { I_OnRehash, I_OnSetClientIP, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
+ Implementation eventlist[] = { I_OnRehash, I_OnUserInit, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -348,24 +348,22 @@ class ModuleDNSBL : public Module
ReadConf();
}
- void OnSetClientIP(User* user)
+ void OnUserInit(LocalUser* user)
{
- LocalUser *luser = IS_LOCAL(user);
-
- if (!luser || luser->exempt)
+ if (user->exempt)
return;
unsigned char a, b, c, d;
char reversedipbuf[128];
std::string reversedip;
- if (luser->client_sa.sa.sa_family != AF_INET)
+ if (user->client_sa.sa.sa_family != AF_INET)
return;
- d = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
- c = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
- b = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
- a = (unsigned char) luser->client_sa.in4.sin_addr.s_addr & 0xFF;
+ d = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
+ c = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
+ b = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
+ a = (unsigned char) user->client_sa.in4.sin_addr.s_addr & 0xFF;
snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a);
reversedip = std::string(reversedipbuf);
@@ -379,11 +377,11 @@ class ModuleDNSBL : public Module
/* now we'd need to fire off lookups for `hostname'. */
bool cached;
- DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, luser, DNSBLConfEntries[i], cached);
+ DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, user, DNSBLConfEntries[i], cached);
ServerInstance->AddResolver(r, cached);
i++;
}
- countExt.set(luser, i);
+ countExt.set(user, i);
}
ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass)
diff --git a/src/modules/m_globops.cpp b/src/modules/m_globops.cpp
index db55858d6..d9dd8f2ac 100644
--- a/src/modules/m_globops.cpp
+++ b/src/modules/m_globops.cpp
@@ -38,13 +38,7 @@ class CommandGlobops : public Command
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
- std::string line = "From " + std::string(user->nick) + ": ";
- for (int i = 0; i < (int)parameters.size(); i++)
- {
- line = line + parameters[i] + " ";
- }
- ServerInstance->SNO->WriteGlobalSno('g',line);
-
+ ServerInstance->SNO->WriteGlobalSno('g', "From " + user->nick + ": " + parameters[0]);
return CMD_SUCCESS;
}
};
diff --git a/src/modules/m_halfop.cpp b/src/modules/m_halfop.cpp
index f0eda3e56..7a43f0241 100644
--- a/src/modules/m_halfop.cpp
+++ b/src/modules/m_halfop.cpp
@@ -92,11 +92,6 @@ class ModuleHalfop : public Module
throw ModuleException("Could not add new modes!");
}
- ~ModuleHalfop()
- {
- ServerInstance->Modes->DelMode(&mh);
- }
-
Version GetVersion()
{
return Version("Channel half-operator mode provider", VF_VENDOR);
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index a7bd4a8c5..60c23f45b 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -21,7 +21,7 @@
*/
-/* $ModDesc: Provides the /HELPOP command, works like UnrealIRCd's helpop */
+/* $ModDesc: Provides the /HELPOP command for useful information */
#include "inspircd.h"
@@ -29,35 +29,13 @@ static std::map<irc::string, std::string> helpop_map;
/** Handles user mode +h
*/
-class Helpop : public ModeHandler
+class Helpop : public SimpleUserModeHandler
{
public:
- Helpop(Module* Creator) : ModeHandler(Creator, "helpop", 'h', PARAM_NONE, MODETYPE_USER)
+ Helpop(Module* Creator) : SimpleUserModeHandler(Creator, "helpop", 'h')
{
oper = true;
}
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!dest->IsModeSet('h'))
- {
- dest->SetMode('h',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (dest->IsModeSet('h'))
- {
- dest->SetMode('h',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
};
/** Handles /HELPOP
@@ -188,7 +166,7 @@ class ModuleHelpop : public Module
Version GetVersion()
{
- return Version("Provides the /HELPOP command, works like UnrealIRCd's helpop", VF_VENDOR);
+ return Version("Provides the /HELPOP command for useful information", VF_VENDOR);
}
};
diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp
index 17e2e8605..9c582551b 100644
--- a/src/modules/m_hidechans.cpp
+++ b/src/modules/m_hidechans.cpp
@@ -24,32 +24,10 @@
/** Handles user mode +I
*/
-class HideChans : public ModeHandler
+class HideChans : public SimpleUserModeHandler
{
public:
- HideChans(Module* Creator) : ModeHandler(Creator, "hidechans", 'I', PARAM_NONE, MODETYPE_USER) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!dest->IsModeSet('I'))
- {
- dest->SetMode('I',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (dest->IsModeSet('I'))
- {
- dest->SetMode('I',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
+ HideChans(Module* Creator) : SimpleUserModeHandler(Creator, "hidechans", 'I') { }
};
class ModuleHideChans : public Module
diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp
index cde50b1a9..998a57bb3 100644
--- a/src/modules/m_hideoper.cpp
+++ b/src/modules/m_hideoper.cpp
@@ -25,35 +25,13 @@
/** Handles user mode +H
*/
-class HideOper : public ModeHandler
+class HideOper : public SimpleUserModeHandler
{
public:
- HideOper(Module* Creator) : ModeHandler(Creator, "hideoper", 'H', PARAM_NONE, MODETYPE_USER)
+ HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H')
{
oper = true;
}
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!dest->IsModeSet('H'))
- {
- dest->SetMode('H',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (dest->IsModeSet('H'))
- {
- dest->SetMode('H',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
};
class ModuleHideOper : public Module
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index b7c9c1cfd..c30e4d200 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -216,15 +216,17 @@ class IdentRequestSocket : public EventHandler
char ibuf[MAXBUF];
int recvresult = ServerInstance->SE->Recv(this, ibuf, MAXBUF-1, 0);
+ /* Close (but don't delete from memory) our socket
+ * and flag as done since the ident lookup has finished
+ */
+ Close();
+ done = true;
+
/* Cant possibly be a valid response shorter than 3 chars,
* because the shortest possible response would look like: '1,1'
*/
if (recvresult < 3)
- {
- Close();
- done = true;
return;
- }
ServerInstance->Logs->Log("m_ident",DEBUG,"ReadResponse()");
@@ -263,13 +265,6 @@ class IdentRequestSocket : public EventHandler
break;
}
-
- /* Close (but dont delete from memory) our socket
- * and flag as done
- */
- Close();
- done = true;
- return;
}
};
@@ -388,7 +383,11 @@ class ModuleIdent : public Module
{
/* Module unloading, tidy up users */
if (target_type == TYPE_USER)
- OnUserDisconnect((LocalUser*)item);
+ {
+ LocalUser* user = IS_LOCAL((User*) item);
+ if (user)
+ OnUserDisconnect(user);
+ }
}
virtual void OnUserDisconnect(LocalUser *user)
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index 1ecec735e..5e6628e6d 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -47,6 +47,7 @@ class InviteException : public ListModeBase
class ModuleInviteException : public Module
{
+ bool invite_bypass_key;
InviteException ie;
public:
ModuleInviteException() : ie(this)
@@ -54,9 +55,10 @@ public:
if (!ServerInstance->Modes->AddMode(&ie))
throw ModuleException("Could not add new modes!");
+ OnRehash(NULL);
ie.DoImplements(this);
- Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite, I_OnCheckKey };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite, I_OnCheckKey, I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 4);
}
void On005Numeric(std::string &output)
@@ -66,17 +68,14 @@ public:
ModResult OnCheckInvite(User* user, Channel* chan)
{
- if(chan != NULL)
+ modelist* list = ie.extItem.get(chan);
+ if (list)
{
- modelist* list = ie.extItem.get(chan);
- if (list)
+ for (modelist::iterator it = list->begin(); it != list->end(); it++)
{
- for (modelist::iterator it = list->begin(); it != list->end(); it++)
+ if (chan->CheckBan(user, it->mask))
{
- if (chan->CheckBan(user, it->mask))
- {
- return MOD_RES_ALLOW;
- }
+ return MOD_RES_ALLOW;
}
}
}
@@ -86,7 +85,7 @@ public:
ModResult OnCheckKey(User* user, Channel* chan, const std::string& key)
{
- if (ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true))
+ if (invite_bypass_key)
return OnCheckInvite(user, chan);
return MOD_RES_PASSTHRU;
}
@@ -103,6 +102,7 @@ public:
void OnRehash(User* user)
{
+ invite_bypass_key = ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true);
ie.DoRehash();
}
diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp
index cc2e25308..3408e4621 100644
--- a/src/modules/m_lockserv.cpp
+++ b/src/modules/m_lockserv.cpp
@@ -34,15 +34,20 @@ class CommandLockserv : public Command
public:
CommandLockserv(Module* Creator, bool& lock) : Command(Creator, "LOCKSERV", 0), locked(lock)
{
- flags_needed = 'o'; syntax.clear();
+ flags_needed = 'o';
}
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
+ if (locked)
+ {
+ user->WriteServ("NOTICE %s :The server is already locked.", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+
locked = true;
user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server.c_str());
- ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
- /* Dont send to the network */
+ ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
return CMD_SUCCESS;
}
};
@@ -55,15 +60,20 @@ private:
public:
CommandUnlockserv(Module* Creator, bool &lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
{
- flags_needed = 'o'; syntax.clear();
+ flags_needed = 'o';
}
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
+ if (!locked)
+ {
+ user->WriteServ("NOTICE %s :The server isn't locked.", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+
locked = false;
user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server.c_str());
- ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
- /* Dont send to the network */
+ ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
return CMD_SUCCESS;
}
};
diff --git a/src/modules/m_mlock.cpp b/src/modules/m_mlock.cpp
index e9ca3bfd0..3fb60a3d2 100644
--- a/src/modules/m_mlock.cpp
+++ b/src/modules/m_mlock.cpp
@@ -54,17 +54,15 @@ public:
return MOD_RES_PASSTHRU;
std::string *mlock_str = mlock.get(channel);
- if (!mlock_str || mlock_str->empty())
+ if (!mlock_str)
return MOD_RES_PASSTHRU;
- for (const char *modes = parameters[1].c_str(); *modes; modes++)
+ std::string::size_type p = parameters[1].find_first_of(*mlock_str);
+ if (p != std::string::npos)
{
- if (mlock_str->find(*modes) != std::string::npos)
- {
- source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
- channel->name.c_str(), *modes, mlock_str->c_str());
- return MOD_RES_DENY;
- }
+ source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
+ channel->name.c_str(), parameters[1][p], mlock_str->c_str());
+ return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 0b4e39764..8c8e1c473 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -21,34 +21,12 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style channel mode +C */
+/* $ModDesc: Provides channel mode +C to block CTCPs */
-class NoCTCP : public ModeHandler
+class NoCTCP : public SimpleChannelModeHandler
{
public:
- NoCTCP(Module* Creator) : ModeHandler(Creator, "noctcp", 'C', PARAM_NONE, MODETYPE_CHANNEL) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!channel->IsModeSet('C'))
- {
- channel->SetMode('C',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (channel->IsModeSet('C'))
- {
- channel->SetMode('C',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
+ NoCTCP(Module* Creator) : SimpleChannelModeHandler(Creator, "noctcp", 'C') { }
};
class ModuleNoCTCP : public Module
@@ -73,7 +51,7 @@ class ModuleNoCTCP : public Module
virtual Version GetVersion()
{
- return Version("Provides support for unreal-style channel mode +C", VF_VENDOR);
+ return Version("Provides channel mode +C to block CTCPs", VF_VENDOR);
}
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
@@ -86,21 +64,20 @@ class ModuleNoCTCP : public Module
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
{
Channel* c = (Channel*)dest;
- ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
+ if (!c->IsModeSet('C'))
+ return MOD_RES_PASSTHRU;
+
+ if ((text.empty()) || (text[0] != '\001') || (strncmp(text.c_str(),"\1ACTION ",8)))
+ return MOD_RES_PASSTHRU;
+ ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
- if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet('C')))
+ if (!c->GetExtBanStatus(user, 'C'))
{
- if ((text.length()) && (text[0] == '\1'))
- {
- if (strncmp(text.c_str(),"\1ACTION ",8))
- {
- user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
- return MOD_RES_DENY;
- }
- }
+ user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
+ return MOD_RES_DENY;
}
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 4d56ad35f..f5c404682 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -23,32 +23,10 @@
/* $ModDesc: Provides support for channel mode +N & extban +b N: which prevents nick changes on channel */
-class NoNicks : public ModeHandler
+class NoNicks : public SimpleChannelModeHandler
{
public:
- NoNicks(Module* Creator) : ModeHandler(Creator, "nonick", 'N', PARAM_NONE, MODETYPE_CHANNEL) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!channel->IsModeSet('N'))
- {
- channel->SetMode('N',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (channel->IsModeSet('N'))
- {
- channel->SetMode('N',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
+ NoNicks(Module* Creator) : SimpleChannelModeHandler(Creator, "nonick", 'N') { }
};
class ModuleNoNickChange : public Module
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 4aa51ef48..ccb44ccde 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -21,7 +21,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style channel mode +T */
+/* $ModDesc: Provides channel mode +T to block notices to the channel */
class NoNotice : public SimpleChannelModeHandler
{
@@ -80,7 +80,7 @@ class ModuleNoNotice : public Module
virtual Version GetVersion()
{
- return Version("Provides support for unreal-style channel mode +T", VF_VENDOR);
+ return Version("Provides channel mode +T to block notices to the channel", VF_VENDOR);
}
};
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 074c644e1..2e6fad79f 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -24,32 +24,13 @@
/* $ModDesc: Provides support for oper-only chans via the +O channel mode */
-class OperChans : public ModeHandler
+class OperChans : public SimpleChannelModeHandler
{
public:
/* This is an oper-only mode */
- OperChans(Module* Creator) : ModeHandler(Creator, "operonly", 'O', PARAM_NONE, MODETYPE_CHANNEL) { oper = true; }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+ OperChans(Module* Creator) : SimpleChannelModeHandler(Creator, "operonly", 'O')
{
- if (adding)
- {
- if (!channel->IsModeSet('O'))
- {
- channel->SetMode('O',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (channel->IsModeSet('O'))
- {
- channel->SetMode('O',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
+ oper = true;
}
};
diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp
index da506dd58..7e28f6c21 100644
--- a/src/modules/m_operlevels.cpp
+++ b/src/modules/m_operlevels.cpp
@@ -29,17 +29,7 @@ class ModuleOperLevels : public Module
public:
ModuleOperLevels()
{
- Implementation eventlist[] = { I_OnRehash, I_OnKill };
- ServerInstance->Modules->Attach(eventlist, this, 2);
- }
-
- virtual ~ModuleOperLevels()
- {
- }
-
-
- virtual void OnRehash(User* user)
- {
+ ServerInstance->Modules->Attach(I_OnKill, this);
}
virtual Version GetVersion()
@@ -64,7 +54,6 @@ class ModuleOperLevels : public Module
}
return MOD_RES_PASSTHRU;
}
-
};
MODULE_INIT(ModuleOperLevels)
diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp
index d029fda64..0b04ff576 100644
--- a/src/modules/m_opermodes.cpp
+++ b/src/modules/m_opermodes.cpp
@@ -29,13 +29,7 @@ class ModuleModesOnOper : public Module
public:
ModuleModesOnOper()
{
- Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
- ServerInstance->Modules->Attach(eventlist, this, 2);
- }
-
-
- virtual void OnRehash(User* user)
- {
+ ServerInstance->Modules->Attach(I_OnPostOper, this);
}
virtual ~ModuleModesOnOper()
@@ -49,6 +43,9 @@ class ModuleModesOnOper : public Module
virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
{
+ if (!IS_LOCAL(user))
+ return;
+
// whenever a user opers, go through the oper types, find their <type:modes>,
// and if they have one apply their modes. The mode string can contain +modes
// to add modes to the user or -modes to take modes from the user.
@@ -67,22 +64,14 @@ class ModuleModesOnOper : public Module
std::string buf;
std::stringstream ss(smodes);
- std::vector<std::string> tokens;
+ std::vector<std::string> modes;
+ modes.push_back(u->nick);
// split into modes and mode params
while (ss >> buf)
- tokens.push_back(buf);
-
- std::vector<std::string> modes;
- modes.push_back(u->nick);
-
- // process mode params
- for (unsigned int k = 0; k < tokens.size(); k++)
- {
- modes.push_back(tokens[k]);
- }
+ modes.push_back(buf);
- ServerInstance->SendGlobalMode(modes, u);
+ ServerInstance->SendMode(modes, u);
}
};
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 1e875a3d6..76d6ee469 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -26,7 +26,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style oper-override */
+/* $ModDesc: Provides support for allowing opers to override certain things. */
class ModuleOverride : public Module
{
@@ -194,7 +194,7 @@ class ModuleOverride : public Module
Version GetVersion()
{
- return Version("Provides support for unreal-style oper-override",VF_VENDOR);
+ return Version("Provides support for allowing opers to override certain things",VF_VENDOR);
}
};
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index 9ea3f72f1..6830f18ce 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -1,6 +1,7 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
+ * Copyright (C) 2012 Shawn Smith <ShawnSmith0828@gmail.com>
* Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
* Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
* Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
@@ -23,7 +24,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides channel mode +L (limit redirection) */
+/* $ModDesc: Provides channel mode +L (limit redirection) and usermode +L (no forced redirection) */
/** Handle channel mode +L
*/
@@ -86,19 +87,44 @@ class Redirect : public ModeHandler
}
};
+/** Handles usermode +L to stop forced redirection and print an error.
+*/
+class AntiRedirect : public SimpleUserModeHandler
+{
+ public:
+ AntiRedirect(Module* Creator) : SimpleUserModeHandler(Creator, "antiredirect", 'L') {}
+};
+
class ModuleRedirect : public Module
{
Redirect re;
+ AntiRedirect re_u;
+ bool UseUsermode;
public:
ModuleRedirect()
- : re(this)
+ : re(this), re_u(this)
{
+ /* Setting this here so it isn't changable by rehasing the config later. */
+ UseUsermode = ServerInstance->Config->ConfValue("redirect")->getBool("antiredirect");
+ /* Channel mode */
if (!ServerInstance->Modes->AddMode(&re))
throw ModuleException("Could not add new modes!");
+
+ /* Check to see if the usermode is enabled in the config */
+ if (UseUsermode)
+ {
+ /* Log noting that this breaks compatability. */
+ ServerInstance->Logs->Log("m_redirect", DEFAULT, "REDIRECT: Enabled usermode +L. This breaks linking with servers that do not have this enabled. This is disabled by default in the 2.0 branch but will be enabled in the next version.");
+
+ /* Try to add the usermode */
+ if (!ServerInstance->Modes->AddMode(&re_u))
+ throw ModuleException("Could not add new modes!");
+ }
+
Implementation eventlist[] = { I_OnUserPreJoin };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
@@ -122,10 +148,20 @@ class ModuleRedirect : public Module
user->WriteNumeric(470, "%s %s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", user->nick.c_str(), cname);
return MOD_RES_DENY;
}
-
- user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname, channel.c_str());
- Channel::JoinUser(user, channel.c_str(), false, "", false, ServerInstance->Time());
- return MOD_RES_DENY;
+ /* We check the bool value here to make sure we have it enabled, if we don't then
+ usermode +L might be assigned to something else. */
+ if (UseUsermode && user->IsModeSet('L'))
+ {
+ user->WriteNumeric(470, "%s %s %s :Force redirection stopped.",
+ user->nick.c_str(), cname, channel.c_str());
+ return MOD_RES_DENY;
+ }
+ else
+ {
+ user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname, channel.c_str());
+ Channel::JoinUser(user, channel.c_str(), false, "", false, ServerInstance->Time());
+ return MOD_RES_DENY;
+ }
}
}
}
@@ -138,7 +174,7 @@ class ModuleRedirect : public Module
virtual Version GetVersion()
{
- return Version("Provides channel mode +L (limit redirection)", VF_VENDOR);
+ return Version("Provides channel mode +L (limit redirection) and user mode +L (no forced redirection)", VF_VENDOR);
}
};
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index 3d351313d..46732b6a6 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -21,7 +21,7 @@
#include "inspircd.h"
-/* $ModDesc: Provides support for unreal-style SAJOIN command */
+/* $ModDesc: Provides command SAJOIN to allow opers to force-join users to channels */
/** Handle /SAJOIN
*/
@@ -117,7 +117,7 @@ class ModuleSajoin : public Module
virtual Version GetVersion()
{
- return Version("Provides support for unreal-style SAJOIN command", VF_OPTCOMMON | VF_VENDOR);
+ return Version("Provides command SAJOIN to allow opers to force-join users to channels", VF_OPTCOMMON | VF_VENDOR);
}
};
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index 5d088cf12..d9c75adf7 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -20,7 +20,7 @@
*/
-/* $ModDesc: Provides more advanced UnrealIRCd SAMODE command */
+/* $ModDesc: Provides command SAMODE to allow opers to change modes on channels and users */
#include "inspircd.h"
@@ -64,7 +64,7 @@ class ModuleSaMode : public Module
Version GetVersion()
{
- return Version("Provides more advanced UnrealIRCd SAMODE command", VF_VENDOR);
+ return Version("Provides command SAMODE to allow opers to change modes on channels and users", VF_VENDOR);
}
ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector<std::string>& parameters)
diff --git a/src/modules/m_satopic.cpp b/src/modules/m_satopic.cpp
index bf65cc5d5..a0e3319af 100644
--- a/src/modules/m_satopic.cpp
+++ b/src/modules/m_satopic.cpp
@@ -44,8 +44,7 @@ class CommandSATopic : public Command
// 3rd parameter overrides access checks
target->SetTopic(user, newTopic, true);
- ServerInstance->SNO->WriteToSnoMask('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
- ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
+ ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
return CMD_SUCCESS;
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index cd34e955a..a28be61dc 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -39,19 +39,17 @@ class Channel_r : public ModeHandler
if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
{
// Only change the mode if it's not redundant
- if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r')))
+ if ((adding != channel->IsModeSet('r')))
{
channel->SetMode('r',adding);
return MODEACTION_ALLOW;
}
-
- return MODEACTION_DENY;
}
else
{
source->WriteNumeric(500, "%s :Only a server may modify the +r channel mode", source->nick.c_str());
- return MODEACTION_DENY;
}
+ return MODEACTION_DENY;
}
};
@@ -67,18 +65,17 @@ class User_r : public ModeHandler
{
if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
{
- if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r')))
+ if ((adding != dest->IsModeSet('r')))
{
dest->SetMode('r',adding);
return MODEACTION_ALLOW;
}
- return MODEACTION_DENY;
}
else
{
source->WriteNumeric(500, "%s :Only a server may modify the +r user mode", source->nick.c_str());
- return MODEACTION_DENY;
}
+ return MODEACTION_DENY;
}
};
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index 0d6b1d9f3..32c1d5dc3 100644
--- a/src/modules/m_setname.cpp
+++ b/src/modules/m_setname.cpp
@@ -36,7 +36,7 @@ class CommandSetname : public Command
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
- if (parameters.size() == 0)
+ if (parameters[0].empty())
{
user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick.c_str());
return CMD_FAILURE;
@@ -50,8 +50,7 @@ class CommandSetname : public Command
if (user->ChangeName(parameters[0].c_str()))
{
- ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to %s", user->nick.c_str(), parameters[0].c_str());
- return CMD_SUCCESS;
+ ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to '%s'", user->nick.c_str(), parameters[0].c_str());
}
return CMD_SUCCESS;
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index 6eec64bd5..d81dd553d 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -27,35 +27,13 @@
/** Handle user mode +W
*/
-class SeeWhois : public ModeHandler
+class SeeWhois : public SimpleUserModeHandler
{
public:
- SeeWhois(Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, "showwhois", 'W', PARAM_NONE, MODETYPE_USER)
+ SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
{
oper = IsOpersOnly;
}
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- if (adding)
- {
- if (!dest->IsModeSet('W'))
- {
- dest->SetMode('W',true);
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (dest->IsModeSet('W'))
- {
- dest->SetMode('W',false);
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
};
class WhoisNoticeCmd : public Command
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index fe1c41162..197bbc1bf 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -158,7 +158,7 @@ class CommandShun : public Command
else
{
delete r;
- user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), expr.c_str());
+ user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), target.c_str());
return CMD_FAILURE;
}
}
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp
index db9a7f2d6..5c3ad548d 100644
--- a/src/modules/m_spanningtree/addline.cpp
+++ b/src/modules/m_spanningtree/addline.cpp
@@ -30,7 +30,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
{
if (params.size() < 6)
{
- ServerInstance->SNO->WriteToSnoMask('d',"%s sent me a malformed ADDLINE of type %s.",prefix.c_str(),params[0].c_str());
+ ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", MyRoot->GetName().c_str());
return true;
}
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 50775be1d..929ace474 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -105,6 +105,7 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
// while the name is equal in case-insensitive compare, it might differ in case; use the remote version
chan->name = channel;
chan->age = TS;
+ chan->ClearInvites();
param_list.push_back(channel);
this->RemoveStatus(ServerInstance->FakeClient, param_list);
}
diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp
index 7edc720af..35bce781d 100644
--- a/src/modules/m_spanningtree/svspart.cpp
+++ b/src/modules/m_spanningtree/svspart.cpp
@@ -30,17 +30,19 @@
CmdResult CommandSVSPart::Handle(const std::vector<std::string>& parameters, User *user)
{
- std::string reason = "Services forced part";
+ User* u = ServerInstance->FindUUID(parameters[0]);
+ if (!u)
+ return CMD_FAILURE;
- if (parameters.size() == 3)
- reason = parameters[2];
-
- User* u = ServerInstance->FindNick(parameters[0]);
Channel* c = ServerInstance->FindChan(parameters[1]);
+ if (!c)
+ return CMD_FAILURE;
- if (u && IS_LOCAL(u))
+ if (IS_LOCAL(u))
+ {
+ std::string reason = (parameters.size() == 3) ? parameters[2] : "Services forced part";
c->PartUser(u, reason);
-
+ }
return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index be5455bce..13dfad3f1 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -315,6 +315,10 @@ class TreeSocket : public BufferedSocket
/** Handle server quit on close
*/
virtual void Close();
+
+ /** Returns true if this server was introduced to the rest of the network
+ */
+ bool Introduced();
};
#endif
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index dcb35af31..7804c870d 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -183,7 +183,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
{
DelServerEvent(Utils->Creator, Current->GetName());
- if (!Current->GetSocket() || Current->GetSocket()->GetLinkState() == CONNECTED)
+ if (!Current->GetSocket() || Current->GetSocket()->Introduced())
{
parameterlist params;
params.push_back(Current->GetName());
@@ -245,3 +245,8 @@ void TreeSocket::OnDataReady()
SendError("RecvQ overrun (line too long)");
Utils->Creator->loopCall = false;
}
+
+bool TreeSocket::Introduced()
+{
+ return (capab == NULL);
+}
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index cb49d92c9..e6fbad4c6 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -440,6 +440,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
ServerInstance->Logs->Log("m_spanningtree", SPARSE, "Unrecognised S2S command :%s %s %s",
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Unrecognised command '" + command + "' -- possibly loaded mismatched modules");
+ return;
}
if (params.size() < cmd->min_params)
@@ -448,6 +449,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
ServerInstance->Logs->Log("m_spanningtree", SPARSE, "Insufficient parameters for S2S command :%s %s %s",
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Insufficient parameters for command '" + command + "'");
+ return;
}
CmdResult res = cmd->Handle(params, who);
@@ -459,7 +461,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
SendError("Error handling '" + command + "' -- possibly loaded mismatched modules");
}
- if (res == CMD_SUCCESS)
+ else if (res == CMD_SUCCESS)
Utils->RouteCommand(route_back_again, command, params, who);
}
}
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 0a8f4dbfc..7dd2cad1d 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -67,7 +67,7 @@ CmdResult CommandUID::Handle(const parameterlist &params, User* serversrc)
/*
* Nick collision.
*/
- int collide = sock->DoCollision(iter->second, age_t, params[5], modestr, params[0]);
+ int collide = sock->DoCollision(iter->second, age_t, params[5], params[6], params[0]);
ServerInstance->Logs->Log("m_spanningtree",DEBUG,"*** Collision on %s, collide=%d", params[2].c_str(), collide);
if (collide != 1)
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index 504f1840b..ef63b2511 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -24,7 +24,7 @@
#include "inspircd.h"
#include "ssl.h"
-/* $ModDesc: Provides support for unreal-style channel mode +z */
+/* $ModDesc: Provides channel mode +z to allow for Secure/SSL only channels */
/** Handle channel mode +z
*/
@@ -134,7 +134,7 @@ class ModuleSSLModes : public Module
Version GetVersion()
{
- return Version("Provides support for unreal-style channel mode +z", VF_VENDOR);
+ return Version("Provides channel mode +z to allow for Secure/SSL only channels", VF_VENDOR);
}
};
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index cd4f35c4b..86f307bae 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -72,8 +72,8 @@ class ModuleStripColor : public Module
{
/* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */
int seq = 0;
- std::string::iterator i,safei;
- for (i = sentence.begin(); i != sentence.end();)
+
+ for (std::string::iterator i = sentence.begin(); i != sentence.end();)
{
if (*i == 3)
seq = 1;
@@ -89,20 +89,7 @@ class ModuleStripColor : public Module
seq = 0;
if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31)))
- {
- if (i != sentence.begin())
- {
- safei = i;
- --i;
- sentence.erase(safei);
- ++i;
- }
- else
- {
- sentence.erase(i);
- i = sentence.begin();
- }
- }
+ i = sentence.erase(i);
else
++i;
}
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index dc53f2f0c..a98c06c75 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -90,7 +90,7 @@ class ModuleSWhois : public Module
ModuleSWhois() : cmd(this)
{
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnWhoisLine, I_OnPostCommand };
+ Implementation eventlist[] = { I_OnWhoisLine, I_OnPostOper };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
@@ -112,11 +112,10 @@ class ModuleSWhois : public Module
return MOD_RES_PASSTHRU;
}
- void OnPostCommand(const std::string &command, const std::vector<std::string> &params, LocalUser *user, CmdResult result, const std::string &original_line)
+ void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
{
- if ((command != "OPER") || (result != CMD_SUCCESS))
+ if (!IS_LOCAL(user))
return;
- ConfigReader Conf;
std::string swhois = user->oper->getConfig("swhois");
diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp
index 365602b7e..683c14afa 100644
--- a/src/modules/m_xline_db.cpp
+++ b/src/modules/m_xline_db.cpp
@@ -235,6 +235,8 @@ class ModuleXLineDB : public Module
{
ServerInstance->SNO->WriteToSnoMask('x', "database: Added a line of type %s", command_p[1].c_str());
}
+ else
+ delete xl;
}
}