summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp6
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/coremods/core_channel/cmode_k.cpp (renamed from src/modes/cmode_k.cpp)6
-rw-r--r--src/coremods/core_channel/cmode_l.cpp (renamed from src/modes/cmode_l.cpp)6
-rw-r--r--src/coremods/core_channel/core_channel.cpp25
-rw-r--r--src/coremods/core_channel/core_channel.h63
-rw-r--r--src/coremods/core_user/core_user.cpp17
-rw-r--r--src/coremods/core_user/core_user.h38
-rw-r--r--src/coremods/core_user/umode_o.cpp (renamed from src/modes/umode_o.cpp)5
-rw-r--r--src/coremods/core_user/umode_s.cpp (renamed from src/modes/umode_s.cpp)5
-rw-r--r--src/inspircd.cpp1
-rw-r--r--src/mode.cpp48
-rw-r--r--src/modules/m_timedbans.cpp2
13 files changed, 161 insertions, 63 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 118a413a8..3bc58505c 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -349,6 +349,9 @@ bool Channel::IsBanned(User* user)
return (result == MOD_RES_DENY);
ListModeBase* banlm = static_cast<ListModeBase*>(*ban);
+ if (!banlm)
+ return false;
+
const ListModeBase::ModeList* bans = banlm->GetList(this);
if (bans)
{
@@ -397,6 +400,9 @@ ModResult Channel::GetExtBanStatus(User *user, char type)
return rv;
ListModeBase* banlm = static_cast<ListModeBase*>(*ban);
+ if (!banlm)
+ return MOD_RES_PASSTHRU;
+
const ListModeBase::ModeList* bans = banlm->GetList(this);
if (bans)
{
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 18b62fb09..ff9d5bd14 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -809,8 +809,6 @@ void ConfigReaderThread::Finish()
ServerInstance->Users.RehashCloneCounts();
ServerInstance->XLines->CheckELines();
ServerInstance->XLines->ApplyLines();
- ChanModeReference ban(NULL, "ban");
- static_cast<ListModeBase*>(*ban)->DoRehash();
Config->ApplyDisabledCommands();
User* user = ServerInstance->FindNick(TheUserUID);
diff --git a/src/modes/cmode_k.cpp b/src/coremods/core_channel/cmode_k.cpp
index 980b3215a..9bab05200 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/coremods/core_channel/cmode_k.cpp
@@ -21,10 +21,10 @@
#include "inspircd.h"
-#include "builtinmodes.h"
+#include "core_channel.h"
-ModeChannelKey::ModeChannelKey()
- : ParamMode<ModeChannelKey, LocalStringExt>(NULL, "key", 'k', PARAM_ALWAYS)
+ModeChannelKey::ModeChannelKey(Module* Creator)
+ : ParamMode<ModeChannelKey, LocalStringExt>(Creator, "key", 'k', PARAM_ALWAYS)
{
}
diff --git a/src/modes/cmode_l.cpp b/src/coremods/core_channel/cmode_l.cpp
index d61b2597b..eb16fd182 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/coremods/core_channel/cmode_l.cpp
@@ -20,10 +20,10 @@
#include "inspircd.h"
-#include "builtinmodes.h"
+#include "core_channel.h"
-ModeChannelLimit::ModeChannelLimit()
- : ParamMode<ModeChannelLimit, LocalIntExt>(NULL, "limit", 'l')
+ModeChannelLimit::ModeChannelLimit(Module* Creator)
+ : ParamMode<ModeChannelLimit, LocalIntExt>(Creator, "limit", 'l')
{
}
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp
index 3af809645..af71e2ced 100644
--- a/src/coremods/core_channel/core_channel.cpp
+++ b/src/coremods/core_channel/core_channel.cpp
@@ -30,6 +30,19 @@ class CoreModChannel : public Module, public CheckExemption::EventListener
CommandKick cmdkick;
CommandNames cmdnames;
CommandTopic cmdtopic;
+
+ ModeChannelBan banmode;
+ SimpleChannelModeHandler inviteonlymode;
+ ModeChannelKey keymode;
+ ModeChannelLimit limitmode;
+ SimpleChannelModeHandler moderatedmode;
+ SimpleChannelModeHandler noextmsgmode;
+ ModeChannelOp opmode;
+ SimpleChannelModeHandler privatemode;
+ SimpleChannelModeHandler secretmode;
+ SimpleChannelModeHandler topiclockmode;
+ ModeChannelVoice voicemode;
+
insp::flat_map<std::string, char> exemptions;
ModResult IsInvited(User* user, Channel* chan)
@@ -49,6 +62,17 @@ class CoreModChannel : public Module, public CheckExemption::EventListener
, cmdkick(this)
, cmdnames(this)
, cmdtopic(this)
+ , banmode(this)
+ , inviteonlymode(this, "inviteonly", 'i')
+ , keymode(this)
+ , limitmode(this)
+ , moderatedmode(this, "moderated", 'm')
+ , noextmsgmode(this, "noextmsg", 'n')
+ , opmode(this)
+ , privatemode(this, "private", 'p')
+ , secretmode(this, "secret", 's')
+ , topiclockmode(this, "topiclock", 't')
+ , voicemode(this)
{
}
@@ -80,6 +104,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener
exempts[restriction] = prefix;
}
exemptions.swap(exempts);
+ banmode.DoRehash();
}
void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 46def3e7b..fa600cd17 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -2,6 +2,9 @@
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
@@ -20,6 +23,7 @@
#pragma once
#include "inspircd.h"
+#include "listmode.h"
#include "modules/exemption.h"
namespace Topic
@@ -135,3 +139,62 @@ class CommandKick : public Command
CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
};
+
+/** Channel mode +b
+ */
+class ModeChannelBan : public ListModeBase
+{
+ public:
+ ModeChannelBan(Module* Creator)
+ : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true, "maxbans")
+ {
+ }
+};
+
+/** Channel mode +k
+ */
+class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
+{
+ static const std::string::size_type maxkeylen = 32;
+ public:
+ ModeChannelKey(Module* Creator);
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
+ void SerializeParam(Channel* chan, const std::string* key, std::string& out) ;
+ ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
+};
+
+/** Channel mode +l
+ */
+class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
+{
+ public:
+ ModeChannelLimit(Module* Creator);
+ bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
+ void SerializeParam(Channel* chan, intptr_t n, std::string& out);
+ ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
+};
+
+/** Channel mode +o
+ */
+class ModeChannelOp : public PrefixMode
+{
+ public:
+ ModeChannelOp(Module* Creator)
+ : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
+ {
+ ranktoset = ranktounset = OP_VALUE;
+ }
+};
+
+/** Channel mode +v
+ */
+class ModeChannelVoice : public PrefixMode
+{
+ public:
+ ModeChannelVoice(Module* Creator)
+ : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
+ {
+ selfremove = false;
+ ranktoset = ranktounset = HALFOP_VALUE;
+ }
+};
diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp
index 5068bd4aa..8504de8e0 100644
--- a/src/coremods/core_user/core_user.cpp
+++ b/src/coremods/core_user/core_user.cpp
@@ -147,11 +147,24 @@ class CoreModUser : public Module
CommandPong cmdpong;
CommandQuit cmdquit;
CommandUser cmduser;
+ SimpleUserModeHandler invisiblemode;
+ ModeUserOperator operatormode;
+ ModeUserServerNoticeMask snomaskmode;
public:
CoreModUser()
- : cmdaway(this), cmdmode(this), cmdnick(this), cmdpart(this), cmdpass(this), cmdping(this)
- , cmdpong(this), cmdquit(this), cmduser(this)
+ : cmdaway(this)
+ , cmdmode(this)
+ , cmdnick(this)
+ , cmdpart(this)
+ , cmdpass(this)
+ , cmdping(this)
+ , cmdpong(this)
+ , cmdquit(this)
+ , cmduser(this)
+ , invisiblemode(this, "invisible", 'i')
+ , operatormode(this)
+ , snomaskmode(this)
{
}
diff --git a/src/coremods/core_user/core_user.h b/src/coremods/core_user/core_user.h
index 2a1ba7bfd..befb07ef5 100644
--- a/src/coremods/core_user/core_user.h
+++ b/src/coremods/core_user/core_user.h
@@ -2,6 +2,9 @@
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
@@ -20,6 +23,7 @@
#pragma once
#include "inspircd.h"
+#include "listmode.h"
class MessageWrapper
{
@@ -182,3 +186,37 @@ class CommandUser : public SplitCommand
*/
static CmdResult CheckRegister(LocalUser* user);
};
+
+/** User mode +s
+ */
+class ModeUserServerNoticeMask : public ModeHandler
+{
+ /** Process a snomask modifier string, e.g. +abc-de
+ * @param user The target user
+ * @param input A sequence of notice mask characters
+ * @return The cleaned mode sequence which can be output,
+ * e.g. in the above example if masks c and e are not
+ * valid, this function will return +ab-d
+ */
+ std::string ProcessNoticeMasks(User* user, const std::string& input);
+
+ public:
+ ModeUserServerNoticeMask(Module* Creator);
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding) CXX11_OVERRIDE;
+ void OnParameterMissing(User* user, User* dest, Channel* channel) CXX11_OVERRIDE;
+
+ /** Create a displayable mode string of the snomasks set on a given user
+ * @param user The user whose notice masks to format
+ * @return The notice mask character sequence
+ */
+ std::string GetUserParameter(const User* user) const CXX11_OVERRIDE;
+};
+
+/** User mode +o
+ */
+class ModeUserOperator : public ModeHandler
+{
+ public:
+ ModeUserOperator(Module* Creator);
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding) CXX11_OVERRIDE;
+};
diff --git a/src/modes/umode_o.cpp b/src/coremods/core_user/umode_o.cpp
index 9d50e571b..20668fdaa 100644
--- a/src/modes/umode_o.cpp
+++ b/src/coremods/core_user/umode_o.cpp
@@ -19,9 +19,10 @@
#include "inspircd.h"
-#include "builtinmodes.h"
+#include "core_user.h"
-ModeUserOperator::ModeUserOperator() : ModeHandler(NULL, "oper", 'o', PARAM_NONE, MODETYPE_USER)
+ModeUserOperator::ModeUserOperator(Module* Creator)
+ : ModeHandler(Creator, "oper", 'o', PARAM_NONE, MODETYPE_USER)
{
oper = true;
}
diff --git a/src/modes/umode_s.cpp b/src/coremods/core_user/umode_s.cpp
index ffad21662..0122ebe3e 100644
--- a/src/modes/umode_s.cpp
+++ b/src/coremods/core_user/umode_s.cpp
@@ -20,9 +20,10 @@
#include "inspircd.h"
-#include "builtinmodes.h"
+#include "core_user.h"
-ModeUserServerNoticeMask::ModeUserServerNoticeMask() : ModeHandler(NULL, "snomask", 's', PARAM_SETONLY, MODETYPE_USER)
+ModeUserServerNoticeMask::ModeUserServerNoticeMask(Module* Creator)
+ : ModeHandler(Creator, "snomask", 's', PARAM_SETONLY, MODETYPE_USER)
{
oper = true;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 0068a6fee..8c5137d3b 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -398,7 +398,6 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->Config->Read();
this->Config->Apply(NULL, "");
Logs->OpenFileLogs();
- ModeParser::InitBuiltinModes();
// If we don't have a SID, generate one based on the server name and the server description
if (Config->sid.empty())
diff --git a/src/mode.cpp b/src/mode.cpp
index 98b0f9854..e2129b55a 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -24,7 +24,6 @@
#include "inspircd.h"
-#include "builtinmodes.h"
ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type, Class mclass)
: ServiceProvider(Creator, Name, SERVICE_MODE)
@@ -894,53 +893,6 @@ void PrefixMode::RemoveMode(Channel* chan, Modes::ChangeList& changelist)
}
}
-struct builtin_modes
-{
- SimpleChannelModeHandler s;
- SimpleChannelModeHandler p;
- SimpleChannelModeHandler m;
- SimpleChannelModeHandler t;
-
- SimpleChannelModeHandler n;
- SimpleChannelModeHandler i;
- ModeChannelKey k;
- ModeChannelLimit l;
-
- ModeChannelBan b;
- ModeChannelOp o;
- ModeChannelVoice v;
-
- SimpleUserModeHandler ui;
- ModeUserOperator uo;
- ModeUserServerNoticeMask us;
-
- builtin_modes()
- : s(NULL, "secret", 's')
- , p(NULL, "private", 'p')
- , m(NULL, "moderated", 'm')
- , t(NULL, "topiclock", 't')
- , n(NULL, "noextmsg", 'n')
- , i(NULL, "inviteonly", 'i')
- , ui(NULL, "invisible", 'i')
- {
- }
-
- void init()
- {
- ServiceProvider* modes[] = { &s, &p, &m, &t, &n, &i, &k, &l, &b, &o, &v,
- &ui, &uo, &us };
- ServerInstance->Modules->AddServices(modes, sizeof(modes)/sizeof(ServiceProvider*));
- }
-};
-
-static builtin_modes static_modes;
-
-void ModeParser::InitBuiltinModes()
-{
- static_modes.init();
- static_modes.b.DoRehash();
-}
-
bool ModeParser::IsModeChar(char chr)
{
return ((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z'));
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 9b74b6f23..14ef11107 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -45,6 +45,8 @@ class CommandTban : public Command
bool IsBanSet(Channel* chan, const std::string& mask)
{
ListModeBase* banlm = static_cast<ListModeBase*>(*banmode);
+ if (!banlm)
+ return false;
const ListModeBase::ModeList* bans = banlm->GetList(chan);
if (bans)
{