summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/base.h2
-rw-r--r--include/builtinmodes.h4
-rw-r--r--include/configparser.h2
-rw-r--r--include/configreader.h8
-rw-r--r--include/extensible.h2
-rw-r--r--include/inspircd.h9
-rw-r--r--include/inspsocket.h4
-rw-r--r--include/listmode.h7
-rw-r--r--include/mode.h2
-rw-r--r--include/modules.h2
-rw-r--r--include/modules/dns.h2
-rw-r--r--include/modules/exemption.h58
-rw-r--r--include/numerics.h8
-rw-r--r--include/socketengine.h16
-rw-r--r--include/typedefs.h6
-rw-r--r--include/users.h24
16 files changed, 111 insertions, 45 deletions
diff --git a/include/base.h b/include/base.h
index c378afc1c..d8781f796 100644
--- a/include/base.h
+++ b/include/base.h
@@ -202,7 +202,7 @@ class CoreExport CoreException : public std::exception
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~CoreException() throw() {};
+ virtual ~CoreException() throw() {}
/** Returns the reason for the exception.
* @return Human readable description of the error
*/
diff --git a/include/builtinmodes.h b/include/builtinmodes.h
index a77734ae3..bfb46823f 100644
--- a/include/builtinmodes.h
+++ b/include/builtinmodes.h
@@ -97,8 +97,8 @@ class ModeUserServerNoticeMask : public ModeHandler
public:
ModeUserServerNoticeMask();
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
- void OnParameterMissing(User* user, User* dest, Channel* channel);
+ 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
diff --git a/include/configparser.h b/include/configparser.h
index 02619e759..c9790c59f 100644
--- a/include/configparser.h
+++ b/include/configparser.h
@@ -41,7 +41,7 @@ enum ParseFlags
struct ParseStack
{
std::vector<std::string> reading;
- insp::flat_map<std::string, std::string> vars;
+ insp::flat_map<std::string, std::string, irc::insensitive_swo> vars;
ConfigDataHash& output;
ConfigFileCache& FilesOutput;
std::stringstream& errstr;
diff --git a/include/configreader.h b/include/configreader.h
index 005d4a37d..4d70d8510 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -35,7 +35,7 @@
/** Structure representing a single \<tag> in config */
class CoreExport ConfigTag : public refcountbase
{
- std::vector<KeyVal> items;
+ ConfigItems items;
public:
const std::string tag;
const std::string src_name;
@@ -80,10 +80,10 @@ class CoreExport ConfigTag : public refcountbase
std::string getTagLocation();
- inline const std::vector<KeyVal>& getItems() const { return items; }
+ inline const ConfigItems& getItems() const { return items; }
- /** Create a new ConfigTag, giving access to the private KeyVal item list */
- static ConfigTag* create(const std::string& Tag, const std::string& file, int line, std::vector<KeyVal>*& Items);
+ /** Create a new ConfigTag, giving access to the private ConfigItems item list */
+ static ConfigTag* create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items);
private:
ConfigTag(const std::string& Tag, const std::string& file, int line);
};
diff --git a/include/extensible.h b/include/extensible.h
index 07756fb59..1da45cee6 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -111,7 +111,7 @@ class CoreExport Extensible : public classbase
inline const ExtensibleStore& GetExtList() const { return extensions; }
Extensible();
- virtual CullResult cull();
+ virtual CullResult cull() CXX11_OVERRIDE;
virtual ~Extensible();
void doUnhookExtensions(const std::vector<reference<ExtensionItem> >& toRemove);
diff --git a/include/inspircd.h b/include/inspircd.h
index 303d24745..a1a828994 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -169,7 +169,6 @@ DEFINE_HANDLER1(IsNickHandler, bool, const std::string&);
DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&);
DEFINE_HANDLER1(IsChannelHandler, bool, const std::string&);
-DEFINE_HANDLER3(OnCheckExemptionHandler, ModResult, User*, Channel*, const std::string&);
/** The main class of the irc server.
* This class contains instances of all the other classes in this software.
@@ -217,7 +216,6 @@ class CoreExport InspIRCd
IsNickHandler HandleIsNick;
IsIdentHandler HandleIsIdent;
- OnCheckExemptionHandler HandleOnCheckExemption;
IsChannelHandler HandleIsChannel;
GenRandomHandler HandleGenRandom;
@@ -521,13 +519,6 @@ class CoreExport InspIRCd
*/
InspIRCd(int argc, char** argv);
- /** Called to check whether a channel restriction mode applies to a user
- * @param User that is attempting some action
- * @param Channel that the action is being performed on
- * @param Action name
- */
- caller3<ModResult, User*, Channel*, const std::string&> OnCheckExemption;
-
/** Prepare the ircd for restart or shutdown.
* This function unloads all modules which can be unloaded,
* closes all open sockets, and closes the logfile.
diff --git a/include/inspsocket.h b/include/inspsocket.h
index 751374fdf..95f29ff11 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -312,7 +312,7 @@ class CoreExport StreamSocket : public EventHandler
*/
virtual void Close();
/** This ensures that close is called prior to destructor */
- virtual CullResult cull();
+ virtual CullResult cull() CXX11_OVERRIDE;
/** Get the IOHook of a module attached to this socket
* @param mod Module whose IOHook to return
@@ -372,7 +372,7 @@ class CoreExport BufferedSocket : public StreamSocket
/** When there is data waiting to be read on a socket, the OnDataReady()
* method is called.
*/
- virtual void OnDataReady() = 0;
+ virtual void OnDataReady() CXX11_OVERRIDE = 0;
/**
* When an outbound connection fails, and the attempt times out, you
diff --git a/include/listmode.h b/include/listmode.h
index 94af1d524..f49c5b3c8 100644
--- a/include/listmode.h
+++ b/include/listmode.h
@@ -63,6 +63,9 @@ class CoreExport ListModeBase : public ModeHandler
*/
typedef std::vector<ListLimit> limitlist;
+ /** The default maximum list size. */
+ static const unsigned int DEFAULT_LIST_SIZE = 64;
+
/** Finds the limit of modes that can be placed on the given channel name according to the config
* @param channame The channel name to find the limit for
* @return The maximum number of modes of this type that we allow to be set on the given channel name
@@ -123,6 +126,10 @@ class CoreExport ListModeBase : public ModeHandler
*/
unsigned int GetLimit(Channel* channel);
+ /** Gets the lower list limit for this listmode.
+ */
+ unsigned int GetLowerLimit();
+
/** Retrieves the list of all modes set on the given channel
* @param channel Channel to get the list from
* @return A list with all modes of this type set on the given channel, can be NULL
diff --git a/include/mode.h b/include/mode.h
index 956b86050..2e9ed22f3 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -166,7 +166,7 @@ class CoreExport ModeHandler : public ServiceProvider
* @param mclass The object type of this mode handler, one of ModeHandler::Class
*/
ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type, Class mclass = MC_OTHER);
- virtual CullResult cull();
+ virtual CullResult cull() CXX11_OVERRIDE;
virtual ~ModeHandler();
/** Register this object in the ModeParser
diff --git a/include/modules.h b/include/modules.h
index 5deed943a..d9d05a396 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -276,7 +276,7 @@ class CoreExport Module : public classbase, public usecountbase
/** Clean up prior to destruction
* If you override, you must call this AFTER your module's cleanup
*/
- virtual CullResult cull();
+ virtual CullResult cull() CXX11_OVERRIDE;
/** Default destructor.
* destroys a module class
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 5f2836761..61abd7144 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -33,6 +33,8 @@ namespace DNS
QUERY_CNAME = 5,
/* Reverse DNS lookup */
QUERY_PTR = 12,
+ /* TXT */
+ QUERY_TXT = 16,
/* IPv6 AAAA lookup */
QUERY_AAAA = 28
};
diff --git a/include/modules/exemption.h b/include/modules/exemption.h
new file mode 100644
index 000000000..2f4ee02fc
--- /dev/null
+++ b/include/modules/exemption.h
@@ -0,0 +1,58 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2016-2017 Peter Powell <petpow@saberuk.com>
+ *
+ * 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
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "event.h"
+
+namespace CheckExemption
+{
+ class EventListener;
+ class EventProvider;
+}
+
+class CheckExemption::EventListener
+ : public Events::ModuleEventListener
+{
+ protected:
+ EventListener(Module* mod)
+ : ModuleEventListener(mod, "event/exemption")
+ {
+ }
+
+ public:
+ /** Called when checking if a user is exempt from something.
+ * @param user The user to check exemption for.
+ * @param chan The channel to check exemption on.
+ * @param restriction The restriction to check for.
+ * @return Either MOD_RES_ALLOW to confirm an exemption, MOD_RES_DENY to deny an exemption,
+ * or MOD_RES_PASSTHRU to let another module handle the event.
+ */
+ virtual ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) = 0;
+};
+
+class CheckExemption::EventProvider
+ : public Events::ModuleEventProvider
+{
+ public:
+ EventProvider(Module* mod)
+ : ModuleEventProvider(mod, "event/exemption")
+ {
+ }
+};
diff --git a/include/numerics.h b/include/numerics.h
index 0d5537278..e1d225d31 100644
--- a/include/numerics.h
+++ b/include/numerics.h
@@ -46,11 +46,13 @@ enum
RPL_SERVERVERSION = 4, // 2812, not 1459
RPL_ISUPPORT = 5, // not RFC, extremely common though (defined as RPL_BOUNCE in 2812, widely ignored)
- RPL_MAP = 6, // unrealircd
- RPL_ENDMAP = 7, // unrealircd
RPL_SNOMASKIS = 8, // unrealircd
RPL_REDIR = 10,
+ RPL_MAP = 15, // ircu
+ RPL_ENDMAP = 17, // ircu
+ RPL_MAPUSERS = 18, // insp-specific
+
RPL_YOURUUID = 42, // taken from ircnet
RPL_UMODEIS = 221,
@@ -70,8 +72,6 @@ enum
RPL_LOCALUSERS = 265,
RPL_GLOBALUSERS = 266,
- RPL_MAPUSERS = 270, // insp-specific
-
RPL_AWAY = 301,
RPL_USERHOST = 302,
RPL_ISON = 303,
diff --git a/include/socketengine.h b/include/socketengine.h
index c0026bfc6..b00643952 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -244,11 +244,19 @@ class CoreExport SocketEngine
*/
Statistics() : lastempty(0), TotalEvents(0), ReadEvents(0), WriteEvents(0), ErrorEvents(0) { }
- /** Increase the counters for bytes sent/received in this second.
- * @param len_in Bytes received, 0 if updating number of bytes written.
- * @param len_out Bytes sent, 0 if updating number of bytes read.
+ /** Update counters for network data received.
+ * This should be called after every read-type syscall.
+ * @param len_in Number of bytes received, or -1 for error, as typically
+ * returned by a read-style syscall.
*/
- void Update(size_t len_in, size_t len_out);
+ void UpdateReadCounters(int len_in);
+
+ /** Update counters for network data sent.
+ * This should be called after every write-type syscall.
+ * @param len_out Number of bytes sent, or -1 for error, as typically
+ * returned by a read-style syscall.
+ */
+ void UpdateWriteCounters(int len_out);
/** Get data transfer statistics.
* @param kbitspersec_in Filled with incoming traffic in this second in kbit/s.
diff --git a/include/typedefs.h b/include/typedefs.h
index 879ef0627..873382999 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -66,13 +66,13 @@ typedef std::vector<Membership*> IncludeChanList;
*/
typedef std::vector<std::string> file_cache;
-/** A configuration key and value pair
+/** A mapping of configuration keys to their assigned values.
*/
-typedef std::pair<std::string, std::string> KeyVal;
+typedef insp::flat_map<std::string, std::string, irc::insensitive_swo> ConfigItems;
/** The entire configuration
*/
-typedef std::multimap<std::string, reference<ConfigTag> > ConfigDataHash;
+typedef std::multimap<std::string, reference<ConfigTag>, irc::insensitive_swo> ConfigDataHash;
/** Iterator of ConfigDataHash */
typedef ConfigDataHash::const_iterator ConfigIter;
diff --git a/include/users.h b/include/users.h
index 4939feb1e..4c8df549d 100644
--- a/include/users.h
+++ b/include/users.h
@@ -717,7 +717,7 @@ class CoreExport User : public Extensible
/** Default destructor
*/
virtual ~User();
- virtual CullResult cull();
+ virtual CullResult cull() CXX11_OVERRIDE;
};
class CoreExport UserIOHandler : public StreamSocket
@@ -742,7 +742,7 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
{
public:
LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
- CullResult cull();
+ CullResult cull() CXX11_OVERRIDE;
UserIOHandler eh;
@@ -836,12 +836,12 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
*/
void SetClass(const std::string &explicit_name = "");
- bool SetClientIP(const char* sip, bool recheck_eline = true);
+ bool SetClientIP(const char* sip, bool recheck_eline = true) CXX11_OVERRIDE;
- void SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline = true);
+ void SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline = true) CXX11_OVERRIDE;
- void Write(const std::string& text);
- void Write(const char*, ...) CUSTOM_PRINTF(2, 3);
+ void Write(const std::string& text) CXX11_OVERRIDE;
+ void Write(const char*, ...) CXX11_OVERRIDE CUSTOM_PRINTF(2, 3);
/** Send a NOTICE message from the local server to the user.
* The message will be sent even if the user is connected to a remote server.
@@ -855,7 +855,7 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
* @param command A command (should be all CAPS)
* @return True if this user can execute the command
*/
- bool HasPermission(const std::string &command);
+ bool HasPermission(const std::string &command) CXX11_OVERRIDE;
/** Returns true if a user has a given permission.
* This is used to check whether or not users may perform certain actions which admins may not wish to give to
@@ -865,7 +865,7 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
* @param noisy If set to true, the user is notified that they do not have the specified permission where applicable. If false, no notification is sent.
* @return True if this user has the permission in question.
*/
- bool HasPrivPermission(const std::string &privstr, bool noisy = false);
+ bool HasPrivPermission(const std::string &privstr, bool noisy = false) CXX11_OVERRIDE;
/** Returns true or false if a user can set a privileged user or channel mode.
* This is done by looking up their oper type from User::oper, then referencing
@@ -873,7 +873,7 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
* @param mh Mode to check
* @return True if the user can set or unset this mode.
*/
- bool HasModePermission(const ModeHandler* mh) const;
+ bool HasModePermission(const ModeHandler* mh) const CXX11_OVERRIDE;
/** Change nick to uuid, unset REG_NICK and send a nickname overruled numeric.
* This is called when another user (either local or remote) needs the nick of this user and this user
@@ -904,9 +904,9 @@ class CoreExport FakeUser : public User
nick = sname;
}
- virtual CullResult cull();
- virtual const std::string& GetFullHost();
- virtual const std::string& GetFullRealHost();
+ virtual CullResult cull() CXX11_OVERRIDE;
+ virtual const std::string& GetFullHost() CXX11_OVERRIDE;
+ virtual const std::string& GetFullRealHost() CXX11_OVERRIDE;
};
/* Faster than dynamic_cast */