aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-07-29 12:13:45 +0100
committerGravatar Sadie Powell2020-07-29 12:13:45 +0100
commite059f822495b02f73f85a668c152c8233cb66f92 (patch)
tree3fc144657d6843f6b07caec69839921bdc962663 /src
parentAdd a method for creating a regex pattern with included flags. (diff)
parentReplace all erroneous space indentation with tab indentation. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_channel/cmode_k.cpp1
-rw-r--r--src/coremods/core_channel/core_channel.h3
-rw-r--r--src/coremods/core_message.cpp3
-rw-r--r--src/inspsocket.cpp12
-rw-r--r--src/modules/m_ircv3_ctctags.cpp3
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_timedbans.cpp37
-rw-r--r--src/users.cpp2
-rw-r--r--src/xline.cpp38
9 files changed, 69 insertions, 32 deletions
diff --git a/src/coremods/core_channel/cmode_k.cpp b/src/coremods/core_channel/cmode_k.cpp
index 861513ba2..c383cf837 100644
--- a/src/coremods/core_channel/cmode_k.cpp
+++ b/src/coremods/core_channel/cmode_k.cpp
@@ -46,6 +46,7 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, s
if (exists && (parameter != *key))
{
/* Key is currently set and the correct key wasn't given */
+ source->WriteNumeric(ERR_KEYSET, channel->name, "Channel key already set");
return MODEACTION_DENY;
}
} else {
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 03f5db2e2..b2e1355a4 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -55,7 +55,8 @@ enum
{
// From RFC 1459.
RPL_BANLIST = 367,
- RPL_ENDOFBANLIST = 368
+ RPL_ENDOFBANLIST = 368,
+ ERR_KEYSET = 467
};
/** Handle /INVITE.
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp
index d77ba3083..010cf4eae 100644
--- a/src/coremods/core_message.cpp
+++ b/src/coremods/core_message.cpp
@@ -174,7 +174,10 @@ class CommandMessage : public Command
// If the source isn't allowed to mass message users then reject
// the attempt to mass-message users.
if (!source->HasPrivPermission("users/mass-message"))
+ {
+ source->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
return CMD_FAILURE;
+ }
// Extract the server glob match from the target parameter.
std::string servername(parameters[0], 1);
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index f0f804fff..e20f9a3b2 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -495,6 +495,18 @@ IOHook* StreamSocket::GetModHook(Module* mod) const
return NULL;
}
+IOHook* StreamSocket::GetLastHook() const
+{
+ IOHook* curr = GetIOHook();
+ IOHook* last = curr;
+
+ for (; curr; curr = GetNextHook(curr))
+ last = curr;
+
+ return last;
+}
+
+
void StreamSocket::AddIOHook(IOHook* newhook)
{
IOHook* curr = GetIOHook();
diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp
index fa838f54f..63c4c7f2e 100644
--- a/src/modules/m_ircv3_ctctags.cpp
+++ b/src/modules/m_ircv3_ctctags.cpp
@@ -110,7 +110,10 @@ class CommandTagMsg : public Command
// If the source isn't allowed to mass message users then reject
// the attempt to mass-message users.
if (!source->HasPrivPermission("users/mass-message"))
+ {
+ source->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
return CMD_FAILURE;
+ }
// Extract the server glob match from the target parameter.
std::string servername(parameters[0], 1);
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index c7b64bdd0..a8a89545e 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -138,7 +138,7 @@ class ModuleOverride
{
// If the kicker's status is less than the target's, or the kicker's status is less than or equal to voice
if ((memb->chan->GetPrefixValue(source) < memb->getRank()) || (memb->chan->GetPrefixValue(source) <= VOICE_VALUE) ||
- (memb->chan->GetPrefixValue(source) == HALFOP_VALUE && memb->getRank() == HALFOP_VALUE))
+ (memb->chan->GetPrefixValue(source) == HALFOP_VALUE && memb->getRank() == HALFOP_VALUE))
{
ServerInstance->SNO.WriteGlobalSno('v',source->nick+" used oper override to kick "+memb->user->nick+" on "+memb->chan->name+" ("+reason+")");
return MOD_RES_ALLOW;
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index b34854549..b67a1b95d 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -71,6 +71,8 @@ class CommandTban : public Command
}
public:
+ bool sendnotice;
+
CommandTban(Module* Creator)
: Command(Creator,"TBAN", 3)
, banmode(Creator, "ban")
@@ -131,13 +133,18 @@ class CommandTban : public Command
T.chan = channel;
TimedBanList.push_back(T);
- const std::string message = InspIRCd::Format("Timed ban %s added by %s on %s lasting for %s.",
+ if (sendnotice)
+ {
+ const std::string message = InspIRCd::Format("Timed ban %s added by %s on %s lasting for %s.",
mask.c_str(), user->nick.c_str(), channel->name.c_str(), InspIRCd::DurationString(duration).c_str());
- // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
- PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
- char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
- channel->WriteRemoteNotice(message, pfxchar);
+ // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
+ PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
+ char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
+
+ channel->WriteRemoteNotice(message, pfxchar);
+ }
+
return CMD_SUCCESS;
}
@@ -205,6 +212,12 @@ class ModuleTimedBans : public Module
{
}
+ void ReadConfig(ConfigStatus& status) override
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("timedbans");
+ cmd.sendnotice = tag->getBool("sendnotice", true);
+ }
+
void OnBackgroundTimer(time_t curtime) override
{
timedbans expired;
@@ -224,13 +237,17 @@ class ModuleTimedBans : public Module
const std::string mask = i->mask;
Channel* cr = i->chan;
- const std::string message = InspIRCd::Format("Timed ban %s set by %s on %s has expired.",
+ if (cmd.sendnotice)
+ {
+ const std::string message = InspIRCd::Format("Timed ban %s set by %s on %s has expired.",
mask.c_str(), i->setter.c_str(), cr->name.c_str());
- // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
- PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
- char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
- cr->WriteRemoteNotice(message, pfxchar);
+ // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
+ PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
+ char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
+
+ cr->WriteRemoteNotice(message, pfxchar);
+ }
Modes::ChangeList setban;
setban.push_remove(ServerInstance->Modes.FindMode('b', MODETYPE_CHANNEL), mask);
diff --git a/src/users.cpp b/src/users.cpp
index e04fefdde..459c2fc51 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1139,7 +1139,7 @@ void LocalUser::SetClass(const std::string &explicit_name)
/* check if host matches.. */
if (!InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
- !InspIRCd::MatchCIDR(this->GetRealHost(), c->GetHost(), NULL))
+ !InspIRCd::MatchCIDR(this->GetRealHost(), c->GetHost(), NULL))
{
ServerInstance->Logs.Log("CONNECTCLASS", LOG_DEBUG, "No host match (for %s)", c->GetHost().c_str());
continue;
diff --git a/src/xline.cpp b/src/xline.cpp
index 6f81b965c..79164e3ea 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -67,15 +67,15 @@ class ELineFactory : public XLineFactory
class KLineFactory : public XLineFactory
{
public:
- KLineFactory() : XLineFactory("K") { }
+ KLineFactory() : XLineFactory("K") { }
/** Generate a KLine
*/
- XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
- {
- IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask);
- return new KLine(set_time, duration, source, reason, ih.first, ih.second);
- }
+ XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
+ {
+ IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask);
+ return new KLine(set_time, duration, source, reason, ih.first, ih.second);
+ }
};
/** An XLineFactory specialized to generate QLine* pointers
@@ -83,14 +83,14 @@ class KLineFactory : public XLineFactory
class QLineFactory : public XLineFactory
{
public:
- QLineFactory() : XLineFactory("Q") { }
+ QLineFactory() : XLineFactory("Q") { }
/** Generate a QLine
*/
- XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
- {
- return new QLine(set_time, duration, source, reason, xline_specific_mask);
- }
+ XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
+ {
+ return new QLine(set_time, duration, source, reason, xline_specific_mask);
+ }
};
/** An XLineFactory specialized to generate ZLine* pointers
@@ -98,14 +98,14 @@ class QLineFactory : public XLineFactory
class ZLineFactory : public XLineFactory
{
public:
- ZLineFactory() : XLineFactory("Z") { }
+ ZLineFactory() : XLineFactory("Z") { }
/** Generate a ZLine
*/
- XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
- {
- return new ZLine(set_time, duration, source, reason, xline_specific_mask);
- }
+ XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) override
+ {
+ return new ZLine(set_time, duration, source, reason, xline_specific_mask);
+ }
};
@@ -581,7 +581,7 @@ bool KLine::Matches(User *u)
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
- InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
+ InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;
}
@@ -604,7 +604,7 @@ bool GLine::Matches(User *u)
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
- InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
+ InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;
}
@@ -623,7 +623,7 @@ bool ELine::Matches(User *u)
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
- InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
+ InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;
}