summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/conf/helpop-full.conf.example8
-rw-r--r--docs/conf/helpop.conf.example8
-rw-r--r--docs/conf/modules.conf.example26
-rw-r--r--docs/conf/modules/unrealircd.conf.example9
-rw-r--r--include/hashcomp.h10
-rw-r--r--include/inspircd.h54
-rw-r--r--include/modules.h100
-rw-r--r--include/users.h60
-rw-r--r--src/commands/cmd_nick.cpp2
-rw-r--r--src/commands/cmd_notice.cpp8
-rw-r--r--src/commands/cmd_privmsg.cpp8
-rw-r--r--src/commands/cmd_stats.cpp12
-rw-r--r--src/commands/cmd_whois.cpp5
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/helperfuncs.cpp43
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules.cpp97
-rw-r--r--src/modules/m_banredirect.cpp3
-rw-r--r--src/modules/m_cgiirc.cpp6
-rw-r--r--src/modules/m_channames.cpp29
-rw-r--r--src/modules/m_chanprotect.cpp308
-rw-r--r--src/modules/m_check.cpp2
-rw-r--r--src/modules/m_customprefix.cpp2
-rw-r--r--src/modules/m_httpd_stats.cpp3
-rw-r--r--src/modules/m_nationalchars.cpp13
-rw-r--r--src/modules/m_nicklock.cpp2
-rw-r--r--src/modules/m_ojoin.cpp2
-rw-r--r--src/modules/m_rline.cpp5
-rw-r--r--src/modules/m_sanick.cpp2
-rw-r--r--src/modules/m_setidle.cpp6
-rw-r--r--src/modules/m_shun.cpp5
-rw-r--r--src/modules/m_spanningtree/capab.cpp3
-rw-r--r--src/modules/m_spanningtree/idle.cpp3
-rw-r--r--src/modules/m_spanningtree/server.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket.h3
-rw-r--r--src/modules/m_spanningtree/utils.cpp2
-rw-r--r--src/modules/m_sqloper.cpp13
-rw-r--r--src/modules/u_listmode.h8
-rw-r--r--src/userprocess.cpp18
-rw-r--r--src/users.cpp9
-rw-r--r--src/xline.cpp20
41 files changed, 156 insertions, 769 deletions
diff --git a/docs/conf/helpop-full.conf.example b/docs/conf/helpop-full.conf.example
index bc9326e62..ffd3761be 100644
--- a/docs/conf/helpop-full.conf.example
+++ b/docs/conf/helpop-full.conf.example
@@ -804,15 +804,15 @@ Closes all unregistered connections to the local server.">
v [nickname] Gives voice to [nickname], allowing them to speak
while the channel is +m.
- h [nickname] Gives halfop status to [nickname] (this mode can
- be disabled).
+ h [nickname] Gives halfop status to [nickname] (requires
+ customprefix module).
o [nickname] Gives op status to [nickname].
a [nickname] Gives protected status to [nickname], preventing
them from them from being kicked (+q only,
- requires chanprotect module).
+ requires customprefix module).
q [nickname] Gives owner status to [nickname], preventing them
from being kicked (Services or only, requires
- chanprotect module).
+ customprefix module).
b [hostmask] Bans [hostmask] from the channel.
e [hostmask] Excepts [hostmask] from bans (requires
diff --git a/docs/conf/helpop.conf.example b/docs/conf/helpop.conf.example
index 02ddff8a2..d54752cfb 100644
--- a/docs/conf/helpop.conf.example
+++ b/docs/conf/helpop.conf.example
@@ -117,15 +117,15 @@ LOCKSERV UNLOCKSERV JUMPSERVER">
v [nickname] Gives voice to [nickname], allowing them to speak
while the channel is +m.
- h [nickname] Gives halfop status to [nickname] (this mode can
- be disabled).
+ h [nickname] Gives halfop status to [nickname] (requires
+ customprefix module).
o [nickname] Gives op status to [nickname].
a [nickname] Gives protected status to [nickname], preventing
them from them from being kicked (+q only,
- requires chanprotect module).
+ requires customprefix module).
q [nickname] Gives owner status to [nickname], preventing them
from being kicked (Services or only, requires
- chanprotect module).
+ customprefix module).
b [hostmask] Bans [hostmask] from the channel.
e [hostmask] Excepts [hostmask] from bans (requires
diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example
index a163c1646..bd64f69f5 100644
--- a/docs/conf/modules.conf.example
+++ b/docs/conf/modules.conf.example
@@ -418,32 +418,6 @@
#<module name="m_channelban.so">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
-# Chanprotect module: gives +q and +a channel modes
-#<module name="m_chanprotect.so">
-
-<chanprotect
- # noservices: With this set to yes, when a user joins a empty channel,
- # the server will set +q on them. If set to no, it will only set +o
- # on them until they register the channel.
- noservices="no"
-
- # qprefix: Prefix (symbol) to use for +q users.
- qprefix="~"
-
- # aprefix: Prefix (symbol) to use for +a users.
- aprefix="&amp;"
-
- # deprotectself: If this value is set (true, yes or 1), it will allow
- # +a and +q users to remove the +a and +q from themselves, otherwise,
- # the status will have to be removed by services.
- deprotectself="yes"
-
- # deprotectothers: If this value is set to yes, true, or 1, then any
- # user with +q or +a may remove the +q or +a from other users.
- deprotectothers="yes">
-
-
-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Check module: gives /check
# Check is useful for looking up information on channels,
# users, IP addresses and hosts.
diff --git a/docs/conf/modules/unrealircd.conf.example b/docs/conf/modules/unrealircd.conf.example
index fa5d652f1..2d27b43a0 100644
--- a/docs/conf/modules/unrealircd.conf.example
+++ b/docs/conf/modules/unrealircd.conf.example
@@ -93,15 +93,6 @@
<module name="m_chanfilter.so">
<chanfilter hidemask="yes">
-<module name="m_chanprotect.so">
-
-<chanprotect
- noservices="no"
- qprefix="~"
- aprefix="&amp;"
- deprotectself="yes"
- deprotectothers="yes">
-
<module name="m_check.so">
<module name="m_chghost.so">
<hostname charmap="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_/0123456789">
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 449b367b9..2932f2a48 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -280,15 +280,7 @@ namespace irc
* mode changes to be obtained.
*/
int GetStackedLine(std::vector<std::string> &result, int max_line_size = 360);
-
- /** deprecated compatability interface - TODO remove */
- int GetStackedLine(std::deque<std::string> &result, int max_line_size = 360) {
- std::vector<std::string> r;
- int n = GetStackedLine(r, max_line_size);
- result.clear();
- result.insert(result.end(), r.begin(), r.end());
- return n;
- }
+
};
/** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812.
diff --git a/include/inspircd.h b/include/inspircd.h
index 9456ce329..13cd92451 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -46,6 +46,15 @@
#define CUSTOM_PRINTF(STRING, FIRST)
#endif
+#if defined __clang__ || defined __GNUC__
+# define DEPRECATED_METHOD(function) function __attribute__((deprecated))
+#elif defined _MSC_VER
+# define DEPRECATED_METHOD(function) __declspec(deprecated) function
+#else
+# pragma message ("Warning! DEPRECATED_METHOD() does not work on your compiler!")
+# define DEPRECATED_METHOD(function) function
+#endif
+
// Required system headers.
#include <ctime>
#include <cstdarg>
@@ -117,11 +126,6 @@ CoreExport extern InspIRCd* ServerInstance;
*/
#define ERROR -1
-/** Support for librodent -
- * see http://www.chatspike.net/index.php?z=64
- */
-#define ETIREDHAMSTERS EAGAIN
-
/** Template function to convert any input type to std::string
*/
template<typename T> inline std::string ConvNumeric(const T &in)
@@ -264,12 +268,10 @@ class serverstats
}
};
-DEFINE_HANDLER2(IsNickHandler, bool, const char*, size_t);
+DEFINE_HANDLER2(IsNickHandler, bool, const std::string&, size_t);
DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
-DEFINE_HANDLER1(IsIdentHandler, bool, const char*);
-DEFINE_HANDLER1(FloodQuitUserHandler, void, User*);
-DEFINE_HANDLER2(IsChannelHandler, bool, const char*, size_t);
-DEFINE_HANDLER1(IsSIDHandler, bool, const std::string&);
+DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&);
+DEFINE_HANDLER2(IsChannelHandler, bool, const std::string&, size_t);
DEFINE_HANDLER1(RehashHandler, void, const std::string&);
DEFINE_HANDLER3(OnCheckExemptionHandler, ModResult, User*, Channel*, const std::string&);
@@ -337,10 +339,8 @@ class CoreExport InspIRCd
IsNickHandler HandleIsNick;
IsIdentHandler HandleIsIdent;
- FloodQuitUserHandler HandleFloodQuitUser;
OnCheckExemptionHandler HandleOnCheckExemption;
IsChannelHandler HandleIsChannel;
- IsSIDHandler HandleIsSID;
RehashHandler HandleRehash;
GenRandomHandler HandleGenRandom;
@@ -571,12 +571,12 @@ class CoreExport InspIRCd
* @param chname A channel name to verify
* @return True if the name is valid
*/
- caller2<bool, const char*, size_t> IsChannel;
+ caller2<bool, const std::string&, size_t> IsChannel;
/** Return true if str looks like a server ID
* @param string to check against
*/
- caller1<bool, const std::string&> IsSID;
+ static bool IsSID(const std::string& sid);
/** Rehash the local server
*/
@@ -619,13 +619,13 @@ class CoreExport InspIRCd
* @param n A nickname to verify
* @return True if the nick is valid
*/
- caller2<bool, const char*, size_t> IsNick;
+ caller2<bool, const std::string&, size_t> IsNick;
/** Return true if an ident is valid
* @param An ident to verify
* @return True if the ident is valid
*/
- caller1<bool, const char*> IsIdent;
+ caller1<bool, const std::string&> IsIdent;
/** Add a dns Resolver class to this server's active set
* @param r The resolver to add
@@ -689,22 +689,6 @@ class CoreExport InspIRCd
static bool MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
static bool MatchCIDR(const char *str, const char *mask, unsigned const char *map = NULL);
- /** Call the handler for a given command.
- * @param commandname The command whos handler you wish to call
- * @param parameters The mode parameters
- * @param user The user to execute the command as
- * @return True if the command handler was called successfully
- */
- CmdResult CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user);
-
- /** Return true if the command is a module-implemented command and the given parameters are valid for it
- * @param commandname The command name to check
- * @param pcnt The parameter count
- * @param user The user to test-execute the command as
- * @return True if the command handler is a module command, and there are enough parameters and the user has permission to the command
- */
- bool IsValidModuleCommand(const std::string &commandname, int pcnt, User* user);
-
/** Return true if the given parameter is a valid nick!user\@host mask
* @param mask A nick!user\@host masak to match against
* @return True i the mask is valid
@@ -817,12 +801,6 @@ class CoreExport InspIRCd
*/
void DoWhois(User* user, User* dest,unsigned long signon, unsigned long idle, const char* nick);
- /** Quit a user for excess flood, and if they are not
- * fully registered yet, temporarily zline their IP.
- * @param current user to quit
- */
- caller1<void, User*> FloodQuitUser;
-
/** 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
diff --git a/include/modules.h b/include/modules.h
index 626f6e9b8..d47e3a62e 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -736,8 +736,6 @@ class CoreExport Module : public classbase, public usecountbase
* (see below). This function will be called for every user visible on your side
* of the burst, allowing you to for example set modes, etc.
*
- * For a good example of how to use this function, please see src/modules/m_chanprotect.cpp
- *
* @param chan The channel being syncronized
* @param proto A pointer to the module handling network protocol
* @param opaque An opaque pointer set by the protocol module, should not be modified!
@@ -770,9 +768,6 @@ class CoreExport Module : public classbase, public usecountbase
* down the network link as a broadcast, without a module calling it having to know the format
* of the MODE command before the actual mode string.
*
- * More documentation to follow soon. Please see src/modules/m_chanprotect.cpp for examples
- * of how to use this function.
- *
* @param opaque An opaque pointer set by the protocol module, should not be modified!
* @param target_type The type of item to decode data for, TYPE_USER or TYPE_CHANNEL
* @param target The Channel* or User* that modes should be sent for
@@ -1296,101 +1291,6 @@ class CoreExport Module : public classbase, public usecountbase
virtual void OnSetUserIP(LocalUser* user);
};
-
-#define CONF_NO_ERROR 0x000000
-#define CONF_NOT_A_NUMBER 0x000010
-#define CONF_INT_NEGATIVE 0x000080
-#define CONF_VALUE_NOT_FOUND 0x000100
-#define CONF_FILE_NOT_FOUND 0x000200
-
-
-/** Allows reading of values from configuration files
- * This class allows a module to read from either the main configuration file (inspircd.conf) or from
- * a module-specified configuration file. It may either be instantiated with one parameter or none.
- * Constructing the class using one parameter allows you to specify a path to your own configuration
- * file, otherwise, inspircd.conf is read.
- */
-class CoreExport ConfigReader : public interfacebase
-{
- protected:
- /** Error code
- */
- long error;
-
- public:
- /** Default constructor.
- * This constructor initialises the ConfigReader class to read the inspircd.conf file
- * as specified when running ./configure.
- */
- ConfigReader();
- /** Default destructor.
- * This method destroys the ConfigReader class.
- */
- ~ConfigReader();
-
- /** Retrieves a value from the config file.
- * This method retrieves a value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve.
- */
- std::string ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds = false);
- /** Retrieves a value from the config file.
- * This method retrieves a value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve. If the
- * tag is not found the default value is returned instead.
- */
- std::string ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds = false);
-
- /** Retrieves a boolean value from the config file.
- * This method retrieves a boolean value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve. The values "1", "yes"
- * and "true" in the config file count as true to ReadFlag, and any other value counts as false.
- */
- bool ReadFlag(const std::string &tag, const std::string &name, int index);
- /** Retrieves a boolean value from the config file.
- * This method retrieves a boolean value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve. The values "1", "yes"
- * and "true" in the config file count as true to ReadFlag, and any other value counts as false.
- * If the tag is not found, the default value is used instead.
- */
- bool ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index);
-
- /** Retrieves an integer value from the config file.
- * This method retrieves an integer value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve. Any invalid integer
- * values in the tag will cause the objects error value to be set, and any call to GetError() will
- * return CONF_INVALID_NUMBER to be returned. need_positive is set if the number must be non-negative.
- * If a negative number is placed into a tag which is specified positive, 0 will be returned and GetError()
- * will return CONF_INT_NEGATIVE. Note that need_positive is not suitable to get an unsigned int - you
- * should cast the result to achieve that effect.
- */
- int ReadInteger(const std::string &tag, const std::string &name, int index, bool need_positive);
- /** Retrieves an integer value from the config file.
- * This method retrieves an integer value from the config file. Where multiple copies of the tag
- * exist in the config file, index indicates which of the values to retrieve. Any invalid integer
- * values in the tag will cause the objects error value to be set, and any call to GetError() will
- * return CONF_INVALID_NUMBER to be returned. needs_unsigned is set if the number must be unsigned.
- * If a signed number is placed into a tag which is specified unsigned, 0 will be returned and GetError()
- * will return CONF_NOT_UNSIGNED. If the tag is not found, the default value is used instead.
- */
- int ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive);
-
- /** Returns the last error to occur.
- * Valid errors can be found by looking in modules.h. Any nonzero value indicates an error condition.
- * A call to GetError() resets the error flag back to 0.
- */
- long GetError();
-
- /** Counts the number of times a given tag appears in the config file.
- * This method counts the number of times a tag appears in a config file, for use where
- * there are several tags of the same kind, e.g. with opers and connect types. It can be
- * used with the index value of ConfigReader::ReadValue to loop through all copies of a
- * multiple instance tag.
- */
- int Enumerate(const std::string &tag);
-};
-
-
-
/** Caches a text file into memory and can be used to retrieve lines from it.
* This class contains methods for read-only manipulation of a text file in memory.
* Either use the constructor type with one parameter to load a file into memory
diff --git a/include/users.h b/include/users.h
index c79bf7cb8..102e7783f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -267,10 +267,6 @@ class CoreExport User : public Extensible
*/
time_t signon;
- /** Time that the connection last sent a message, used to calculate idle time
- */
- time_t idle_lastmsg;
-
/** Client address that the user is connected from.
* Do not modify this value directly, use SetClientIP() to change it.
* Port is not valid for remote users.
@@ -347,12 +343,6 @@ class CoreExport User : public Extensible
*/
unsigned int registered:3;
- /** True when DNS lookups are completed.
- * The UserResolver classes res_forward and res_reverse will
- * set this value once they complete.
- */
- unsigned int dns_done:1;
-
/** Whether or not to send an snotice about this user's quitting
*/
unsigned int quietquit:1;
@@ -364,20 +354,6 @@ class CoreExport User : public Extensible
*/
unsigned int quitting:1;
- /** Recursion fix: user is out of SendQ and will be quit as soon as possible.
- * This can't be handled normally because QuitUser itself calls Write on other
- * users, which could trigger their SendQ to overrun.
- */
- unsigned int quitting_sendq:1;
-
- /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
- */
- unsigned int exempt:1;
-
- /** has the user responded to their previous ping?
- */
- unsigned int lastping:1;
-
/** What type of user is this? */
const unsigned int usertype:2;
@@ -402,12 +378,6 @@ class CoreExport User : public Extensible
*/
User(const std::string &uid, const std::string& srv, int objtype);
- /** Check if the user matches a G or K line, and disconnect them if they do.
- * @param doZline True if ZLines should be checked (if IP has changed since initial connect)
- * Returns true if the user matched a ban, false else.
- */
- bool CheckLines(bool doZline = false);
-
/** Returns the full displayed host of the user
* This member function returns the hostname of the user as seen by other users
* on the server, in nick!ident\@host form.
@@ -792,10 +762,34 @@ class CoreExport LocalUser : public User, public InviteBase
*/
int GetServerPort();
+ /** Recursion fix: user is out of SendQ and will be quit as soon as possible.
+ * This can't be handled normally because QuitUser itself calls Write on other
+ * users, which could trigger their SendQ to overrun.
+ */
+ unsigned int quitting_sendq:1;
+
+ /** True when DNS lookups are completed.
+ * The UserResolver classes res_forward and res_reverse will
+ * set this value once they complete.
+ */
+ unsigned int dns_done:1;
+
+ /** has the user responded to their previous ping?
+ */
+ unsigned int lastping:1;
+
+ /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
+ */
+ unsigned int exempt:1;
+
/** Used by PING checking code
*/
time_t nping;
+ /** Time that the connection last sent a message, used to calculate idle time
+ */
+ time_t idle_lastmsg;
+
/** This value contains how far into the penalty threshold the user is.
* This is used either to enable fake lag or for excess flood quits
*/
@@ -814,6 +808,12 @@ class CoreExport LocalUser : public User, public InviteBase
*/
void StartDNSLookup();
+ /** Check if the user matches a G or K line, and disconnect them if they do.
+ * @param doZline True if ZLines should be checked (if IP has changed since initial connect)
+ * Returns true if the user matched a ban, false else.
+ */
+ bool CheckLines(bool doZline = false);
+
/** Use this method to fully connect a user.
* This will send the message of the day, check G/K/E lines, etc.
*/
diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp
index a079e59d0..4c26d947f 100644
--- a/src/commands/cmd_nick.cpp
+++ b/src/commands/cmd_nick.cpp
@@ -66,7 +66,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
{
newnick = user->uuid;
}
- else if (!ServerInstance->IsNick(newnick.c_str(), ServerInstance->Config->Limits.NickMax))
+ else if (!ServerInstance->IsNick(newnick, ServerInstance->Config->Limits.NickMax))
{
user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),newnick.c_str());
return CMD_FAILURE;
diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp
index d5ef7ba1d..d0845a051 100644
--- a/src/commands/cmd_notice.cpp
+++ b/src/commands/cmd_notice.cpp
@@ -57,7 +57,9 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
CUList exempt_list;
- user->idle_lastmsg = ServerInstance->Time();
+ LocalUser* localuser = IS_LOCAL(user);
+ if (localuser)
+ localuser->idle_lastmsg = ServerInstance->Time();
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
@@ -98,7 +100,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
if (chan)
{
- if (IS_LOCAL(user))
+ if (localuser)
{
if ((chan->IsModeSet('n')) && (!chan->HasUser(user)))
{
@@ -166,7 +168,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
const char* destnick = parameters[0].c_str();
- if (IS_LOCAL(user))
+ if (localuser)
{
const char* targetserver = strchr(destnick, '@');
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index cefdd4800..09314e8a9 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -56,7 +56,9 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us
Channel *chan;
CUList except_list;
- user->idle_lastmsg = ServerInstance->Time();
+ LocalUser* localuser = IS_LOCAL(user);
+ if (localuser)
+ localuser->idle_lastmsg = ServerInstance->Time();
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
@@ -99,7 +101,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us
if (chan)
{
- if (IS_LOCAL(user) && chan->GetPrefixValue(user) < VOICE_VALUE)
+ if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE)
{
if (chan->IsModeSet('n') && !chan->HasUser(user))
{
@@ -169,7 +171,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us
const char* destnick = parameters[0].c_str();
- if (IS_LOCAL(user))
+ if (localuser)
{
const char* targetserver = strchr(destnick, '@');
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 9a5bfc52d..c37b041a9 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -161,13 +161,15 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
case 'P':
{
- int idx = 0;
- for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
+ unsigned int idx = 0;
+ for (std::list<User*>::const_iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); ++i)
{
- if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->server))
+ User* oper = *i;
+ if (!ServerInstance->ULine(oper->server))
{
- results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+
- (IS_LOCAL(i->second) ? ConvToStr(ServerInstance->Time() - i->second->idle_lastmsg) + " secs" : "unavailable"));
+ LocalUser* lu = IS_LOCAL(oper);
+ results.push_back(sn+" 249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " +
+ (lu ? ConvToStr(ServerInstance->Time() - lu->idle_lastmsg) + " secs" : "unavailable"));
idx++;
}
}
diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp
index ba2ad9c15..3a07fce7b 100644
--- a/src/commands/cmd_whois.cpp
+++ b/src/commands/cmd_whois.cpp
@@ -74,9 +74,10 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User
* For remote users (/w remoteuser remoteuser), spanningtree will handle calling do_whois, so we can ignore this case.
* Thanks to djGrrr for not being impatient while I have a crap day coding. :p -- w00t
*/
- if (IS_LOCAL(dest) && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1))
+ LocalUser* localuser = IS_LOCAL(dest);
+ if (localuser && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1))
{
- idle = abs((long)((dest->idle_lastmsg)-ServerInstance->Time()));
+ idle = abs((long)((localuser->idle_lastmsg)-ServerInstance->Time()));
signon = dest->signon;
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 1f863ba62..668290f4d 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -241,7 +241,7 @@ void ServerConfig::CrossCheckOperClassType()
std::string name = tag->getString("name");
if (name.empty())
throw CoreException("<type:name> is missing from tag at " + tag->getTagLocation());
- if (!ServerInstance->IsNick(name.c_str(), Limits.NickMax))
+ if (!ServerInstance->IsNick(name, Limits.NickMax))
throw CoreException("<type:name> is invalid (value '" + name + "')");
if (oper_blocks.find(" " + name) != oper_blocks.end())
throw CoreException("Duplicate type block with name " + name + " at " + tag->getTagLocation());
@@ -483,7 +483,7 @@ void ServerConfig::Fill()
ServerName = ConfValue("server")->getString("name");
sid = ConfValue("server")->getString("id");
ValidHost(ServerName, "<server:name>");
- if (!sid.empty() && !ServerInstance->IsSID(sid))
+ if (!InspIRCd::IsSID(sid))
throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
}
else
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 5a8f55f11..42cb55cfd 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -281,47 +281,35 @@ void InspIRCd::ProcessColors(file_cache& input)
}
/* true for valid channel name, false else */
-bool IsChannelHandler::Call(const char *chname, size_t max)
+bool IsChannelHandler::Call(const std::string& chname, size_t max)
{
- const char *c = chname + 1;
+ if (chname.empty() || chname.length() > max)
+ return false;
- /* check for no name - don't check for !*chname, as if it is empty, it won't be '#'! */
- if (!chname || *chname != '#')
- {
+ if (chname[0] != '#')
return false;
- }
- while (*c)
+ for (std::string::const_iterator i = chname.begin()+1; i != chname.end(); ++i)
{
- switch (*c)
+ switch (*i)
{
case ' ':
case ',':
case 7:
return false;
}
-
- c++;
- }
-
- size_t len = c - chname;
- /* too long a name - note funky pointer arithmetic here. */
- if (len > max)
- {
- return false;
}
return true;
}
/* true for valid nickname, false else */
-bool IsNickHandler::Call(const char* n, size_t max)
+bool IsNickHandler::Call(const std::string& n, size_t max)
{
- if (!n || !*n)
+ if (n.empty() || n.length() > max)
return false;
- unsigned int p = 0;
- for (const char* i = n; *i; i++, p++)
+ for (std::string::const_iterator i = n.begin(); i != n.end(); ++i)
{
if ((*i >= 'A') && (*i <= '}'))
{
@@ -329,7 +317,7 @@ bool IsNickHandler::Call(const char* n, size_t max)
continue;
}
- if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n))
+ if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i != n.begin()))
{
/* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */
continue;
@@ -339,17 +327,16 @@ bool IsNickHandler::Call(const char* n, size_t max)
return false;
}
- /* too long? or not */
- return (p <= max);
+ return true;
}
/* return true for good ident, false else */
-bool IsIdentHandler::Call(const char* n)
+bool IsIdentHandler::Call(const std::string& n)
{
- if (!n || !*n)
+ if (n.empty())
return false;
- for (const char* i = n; *i; i++)
+ for (std::string::const_iterator i = n.begin(); i != n.end(); ++i)
{
if ((*i >= 'A') && (*i <= '}'))
{
@@ -367,7 +354,7 @@ bool IsIdentHandler::Call(const char* n)
return true;
}
-bool IsSIDHandler::Call(const std::string &str)
+bool InspIRCd::IsSID(const std::string &str)
{
/* Returns true if the string given is exactly 3 characters long,
* starts with a digit, and the other two characters are A-Z or digits
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 344e2a473..68d1917c4 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -321,11 +321,9 @@ InspIRCd::InspIRCd(int argc, char** argv) :
OperQuit("OperQuit", NULL),
GenRandom(&HandleGenRandom),
IsChannel(&HandleIsChannel),
- IsSID(&HandleIsSID),
Rehash(&HandleRehash),
IsNick(&HandleIsNick),
IsIdent(&HandleIsIdent),
- FloodQuitUser(&HandleFloodQuitUser),
OnCheckExemption(&HandleOnCheckExemption)
{
ServerInstance = this;
diff --git a/src/modules.cpp b/src/modules.cpp
index b8a831c48..560fd6b2b 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -425,16 +425,6 @@ std::string& ModuleManager::LastError()
return LastModuleError;
}
-CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user)
-{
- return this->Parser->CallHandler(commandname, parameters, user);
-}
-
-bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, User* user)
-{
- return this->Parser->IsValidCommand(commandname, pcnt, user);
-}
-
void ModuleManager::AddService(ServiceProvider& item)
{
switch (item.service)
@@ -606,93 +596,6 @@ const std::vector<std::string> ModuleManager::GetAllModuleNames(int filter)
return retval;
}
-ConfigReader::ConfigReader()
-{
- this->error = 0;
- ServerInstance->Logs->Log("MODULE", DEBUG, "ConfigReader is deprecated in 2.0; "
- "use ServerInstance->Config->ConfValue(\"key\") or ->ConfTags(\"key\") instead");
-}
-
-
-ConfigReader::~ConfigReader()
-{
-}
-
-static ConfigTag* SlowGetTag(const std::string &tag, int index)
-{
- ConfigTagList tags = ServerInstance->Config->ConfTags(tag);
- while (tags.first != tags.second)
- {
- if (!index)
- return tags.first->second;
- tags.first++;
- index--;
- }
- return NULL;
-}
-
-std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds)
-{
- std::string result = default_value;
- if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds))
- {
- this->error = CONF_VALUE_NOT_FOUND;
- }
- return result;
-}
-
-std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds)
-{
- return ReadValue(tag, name, "", index, allow_linefeeds);
-}
-
-bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index)
-{
- bool def = (default_value == "yes");
- return SlowGetTag(tag, index)->getBool(name, def);
-}
-
-bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index)
-{
- return ReadFlag(tag, name, "", index);
-}
-
-
-int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive)
-{
- int v = atoi(default_value.c_str());
- int result = SlowGetTag(tag, index)->getInt(name, v);
-
- if ((need_positive) && (result < 0))
- {
- this->error = CONF_INT_NEGATIVE;
- return 0;
- }
-
- return result;
-}
-
-int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, int index, bool need_positive)
-{
- return ReadInteger(tag, name, "", index, need_positive);
-}
-
-long ConfigReader::GetError()
-{
- long olderr = this->error;
- this->error = 0;
- return olderr;
-}
-
-int ConfigReader::Enumerate(const std::string &tag)
-{
- ServerInstance->Logs->Log("MODULE", DEBUG, "Module is using ConfigReader::Enumerate on %s; this is slow!",
- tag.c_str());
- int i=0;
- while (SlowGetTag(tag, i)) i++;
- return i;
-}
-
FileReader::FileReader(const std::string &filename)
{
LoadFile(filename);
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 1a5126e61..512c9b64e 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -43,7 +43,6 @@ class BanRedirectEntry
};
typedef std::vector<BanRedirectEntry> BanRedirectList;
-typedef std::deque<std::string> StringDeque;
class BanRedirect : public ModeWatcher
{
@@ -242,7 +241,7 @@ class ModuleBanRedirect : public Module
if(redirects)
{
irc::modestacker modestack(false);
- StringDeque stackresult;
+ std::vector<std::string> stackresult;
std::vector<std::string> mode_junk;
mode_junk.push_back(chan->name);
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index d4ef602b3..39833f1a0 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -136,6 +136,10 @@ class CGIResolver : public Resolver
User* them = ServerInstance->FindUUID(theiruid);
if ((them) && (!them->quitting))
{
+ LocalUser* lu = IS_LOCAL(them);
+ if (!lu)
+ return;
+
if (notify)
ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick.c_str(), them->host.c_str(), result.c_str(), typ.c_str());
@@ -144,7 +148,7 @@ class CGIResolver : public Resolver
them->host = result;
them->dhost = result;
them->InvalidateCache();
- them->CheckLines(true);
+ lu->CheckLines(true);
}
}
diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp
index e78171c4a..e9e5ba305 100644
--- a/src/modules/m_channames.cpp
+++ b/src/modules/m_channames.cpp
@@ -23,35 +23,34 @@
static std::bitset<256> allowedmap;
-class NewIsChannelHandler : public HandlerBase2<bool, const char*, size_t>
+class NewIsChannelHandler : public HandlerBase2<bool, const std::string&, size_t>
{
public:
NewIsChannelHandler() { }
virtual ~NewIsChannelHandler() { }
- virtual bool Call(const char*, size_t);
+ virtual bool Call(const std::string&, size_t);
};
-bool NewIsChannelHandler::Call(const char* c, size_t max)
+bool NewIsChannelHandler::Call(const std::string& channame, size_t max)
{
- /* check for no name - don't check for !*chname, as if it is empty, it won't be '#'! */
- if (!c || *c++ != '#')
+ if (channame.empty() || channame.length() > max || channame[0] != '#')
+ return false;
+
+ for (std::string::const_iterator c = channame.begin(); c != channame.end(); ++c)
+ {
+ unsigned int i = *c & 0xFF;
+ if (!allowedmap[i])
return false;
+ }
- while (*c && --max)
- {
- unsigned int i = *c++ & 0xFF;
- if (!allowedmap[i])
- return false;
- }
- // a name of exactly max length will have max = 1 here; the null does not trigger --max
- return max;
+ return true;
}
class ModuleChannelNames : public Module
{
private:
NewIsChannelHandler myhandler;
- caller2<bool, const char*, size_t> rememberer;
+ caller2<bool, const std::string&, size_t> rememberer;
bool badchan;
public:
@@ -73,7 +72,7 @@ class ModuleChannelNames : public Module
std::vector<Channel*> chanvec;
for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
{
- if (!ServerInstance->IsChannel(i->second->name.c_str(), MAXBUF))
+ if (!ServerInstance->IsChannel(i->second->name, MAXBUF))
chanvec.push_back(i->second);
}
std::vector<Channel*>::reverse_iterator c2 = chanvec.rbegin();
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
deleted file mode 100644
index 09364fb32..000000000
--- a/src/modules/m_chanprotect.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2006-2009 Robin Burchell <robin+git@viroteck.net>
- * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
- * Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
- * Copyright (C) 2004-2008 Craig Edwards <craigedwards@brainbox.cc>
- * Copyright (C) 2007 John Brooks <john.brooks@dereferenced.net>
- * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- *
- * 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/>.
- */
-
-
-#include "inspircd.h"
-
-/* $ModDesc: Provides channel modes +a and +q */
-
-#define PROTECT_VALUE 40000
-#define FOUNDER_VALUE 50000
-
-struct ChanProtectSettings
-{
- bool DeprivSelf;
- bool DeprivOthers;
- bool FirstInGetsFounder;
- bool booting;
- ChanProtectSettings() : booting(true) {}
-};
-
-static ChanProtectSettings settings;
-
-/** Handles basic operation of +qa channel modes
- */
-class FounderProtectBase
-{
- private:
- const std::string type;
- const char mode;
- const int list;
- const int end;
- public:
- FounderProtectBase(char Mode, const std::string &mtype, int l, int e) :
- type(mtype), mode(Mode), list(l), end(e)
- {
- }
-
- void RemoveMode(Channel* channel, irc::modestacker* stack)
- {
- const UserMembList* cl = channel->GetUsers();
- std::vector<std::string> mode_junk;
- mode_junk.push_back(channel->name);
- irc::modestacker modestack(false);
- std::deque<std::string> stackresult;
-
- for (UserMembCIter i = cl->begin(); i != cl->end(); i++)
- {
- if (i->second->hasMode(mode))
- {
- if (stack)
- stack->Push(mode, i->first->nick);
- else
- modestack.Push(mode, i->first->nick);
- }
- }
-
- if (stack)
- return;
-
- while (modestack.GetStackedLine(stackresult))
- {
- mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
- ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
- mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
- }
- }
-
- void DisplayList(User* user, Channel* channel)
- {
- const UserMembList* cl = channel->GetUsers();
- for (UserMembCIter i = cl->begin(); i != cl->end(); ++i)
- {
- if (i->second->hasMode(mode))
- {
- user->WriteServ("%d %s %s %s", list, user->nick.c_str(), channel->name.c_str(), i->first->nick.c_str());
- }
- }
- user->WriteServ("%d %s %s :End of channel %s list", end, user->nick.c_str(), channel->name.c_str(), type.c_str());
- }
-
- bool CanRemoveOthers(User* u1, Channel* c)
- {
- Membership* m1 = c->GetUser(u1);
- return (settings.DeprivOthers && m1 && m1->hasMode(mode));
- }
-};
-
-/** Abstraction of FounderProtectBase for channel mode +q
- */
-class ChanFounder : public ModeHandler, public FounderProtectBase
-{
- public:
- ChanFounder(Module* Creator)
- : ModeHandler(Creator, "founder", 'q', PARAM_ALWAYS, MODETYPE_CHANNEL),
- FounderProtectBase('q', "founder", 386, 387)
- {
- ModeHandler::list = true;
- levelrequired = FOUNDER_VALUE;
- m_paramtype = TR_NICK;
- }
-
- void setPrefix(int pfx)
- {
- prefix = pfx;
- }
-
- unsigned int GetPrefixRank()
- {
- return FOUNDER_VALUE;
- }
-
- void RemoveMode(Channel* channel, irc::modestacker* stack)
- {
- FounderProtectBase::RemoveMode(channel, stack);
- }
-
- void RemoveMode(User* user, irc::modestacker* stack)
- {
- }
-
- ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
- {
- User* theuser = ServerInstance->FindNick(parameter);
- // remove own privs?
- if (source == theuser && !adding && settings.DeprivSelf)
- return MOD_RES_ALLOW;
-
- if (!adding && FounderProtectBase::CanRemoveOthers(source, channel))
- {
- return MOD_RES_PASSTHRU;
- }
- else
- {
- source->WriteNumeric(468, "%s %s :Only servers may set channel mode +q", source->nick.c_str(), channel->name.c_str());
- return MOD_RES_DENY;
- }
- }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- return MODEACTION_ALLOW;
- }
-
- void DisplayList(User* user, Channel* channel)
- {
- FounderProtectBase::DisplayList(user,channel);
- }
-};
-
-/** Abstraction of FounderProtectBase for channel mode +a
- */
-class ChanProtect : public ModeHandler, public FounderProtectBase
-{
- public:
- ChanProtect(Module* Creator)
- : ModeHandler(Creator, "admin", 'a', PARAM_ALWAYS, MODETYPE_CHANNEL),
- FounderProtectBase('a',"protected user", 388, 389)
- {
- ModeHandler::list = true;
- levelrequired = PROTECT_VALUE;
- m_paramtype = TR_NICK;
- }
-
- void setPrefix(int pfx)
- {
- prefix = pfx;
- }
-
-
- unsigned int GetPrefixRank()
- {
- return PROTECT_VALUE;
- }
-
- void RemoveMode(Channel* channel, irc::modestacker* stack)
- {
- FounderProtectBase::RemoveMode(channel, stack);
- }
-
- void RemoveMode(User* user, irc::modestacker* stack)
- {
- }
-
- ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
- {
- User* theuser = ServerInstance->FindNick(parameter);
- // source has +q
- if (channel->GetPrefixValue(source) > PROTECT_VALUE)
- return MOD_RES_ALLOW;
-
- // removing own privs?
- if (source == theuser && !adding && settings.DeprivSelf)
- return MOD_RES_ALLOW;
-
- if (!adding && FounderProtectBase::CanRemoveOthers(source, channel))
- {
- return MOD_RES_PASSTHRU;
- }
- else
- {
- source->WriteNumeric(482, "%s %s :You are not a channel founder", source->nick.c_str(), channel->name.c_str());
- return MOD_RES_DENY;
- }
- }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
- {
- return MODEACTION_ALLOW;
- }
-
- void DisplayList(User* user, Channel* channel)
- {
- FounderProtectBase::DisplayList(user, channel);
- }
-
-};
-
-class ModuleChanProtect : public Module
-{
- ChanProtect cp;
- ChanFounder cf;
- public:
- ModuleChanProtect() : cp(this), cf(this)
- {
- }
-
- void init()
- {
- /* Load config stuff */
- LoadSettings();
- settings.booting = false;
-
- ServerInstance->Modules->AddService(cf);
- ServerInstance->Modules->AddService(cp);
-
- Implementation eventlist[] = { I_OnUserPreJoin };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
- }
-
- void LoadSettings()
- {
- ConfigTag* tag = ServerInstance->Config->ConfValue("chanprotect");
-
- settings.FirstInGetsFounder = tag->getBool("noservices");
-
- std::string qpre = tag->getString("qprefix");
- char QPrefix = qpre.empty() ? 0 : qpre[0];
-
- std::string apre = tag->getString("aprefix");
- char APrefix = apre.empty() ? 0 : apre[0];
-
- if ((APrefix && QPrefix) && APrefix == QPrefix)
- throw ModuleException("What the smeg, why are both your +q and +a prefixes the same character?");
-
- if (settings.booting)
- {
- if (APrefix && ServerInstance->Modes->FindPrefix(APrefix) && ServerInstance->Modes->FindPrefix(APrefix) != &cp)
- throw ModuleException("Looks like the +a prefix you picked for m_chanprotect is already in use. Pick another.");
-
- if (QPrefix && ServerInstance->Modes->FindPrefix(QPrefix) && ServerInstance->Modes->FindPrefix(QPrefix) != &cf)
- throw ModuleException("Looks like the +q prefix you picked for m_chanprotect is already in use. Pick another.");
-
- cp.setPrefix(APrefix);
- cf.setPrefix(QPrefix);
- }
- settings.DeprivSelf = tag->getBool("deprotectself", true);
- settings.DeprivOthers = tag->getBool("deprotectothers", true);
- }
-
- ModResult OnUserPreJoin(User* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven)
- {
- // if the user is the first user into the channel, mark them as the founder, but only if
- // the config option for it is set
-
- if (settings.FirstInGetsFounder && !chan)
- privs += 'q';
-
- return MOD_RES_PASSTHRU;
- }
-
- Version GetVersion()
- {
- return Version("Founder and Protect modes (+qa)", VF_VENDOR);
- }
-};
-
-MODULE_INIT(ModuleChanProtect)
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 07276445f..2c46401ae 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -96,7 +96,7 @@ class CommandCheck : public Command
user->SendText(checkstr + " signon " + timestring(targuser->signon));
user->SendText(checkstr + " nickts " + timestring(targuser->age));
if (loctarg)
- user->SendText(checkstr + " lastmsg " + timestring(targuser->idle_lastmsg));
+ user->SendText(checkstr + " lastmsg " + timestring(loctarg->idle_lastmsg));
if (IS_AWAY(targuser))
{
diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp
index dfc60e082..9bf65b3e8 100644
--- a/src/modules/m_customprefix.cpp
+++ b/src/modules/m_customprefix.cpp
@@ -59,7 +59,7 @@ class CustomPrefixMode : public ModeHandler
std::vector<std::string> mode_junk;
mode_junk.push_back(channel->name);
irc::modestacker modestack(false);
- std::deque<std::string> stackresult;
+ std::vector<std::string> stackresult;
for (UserMembCIter i = cl->begin(); i != cl->end(); i++)
{
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 547d6032f..9115fedaf 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -55,8 +55,7 @@ class ModuleHttpStats : public Module
ret += it->second;
ret += ';';
}
- else if (*x == 0x9 || *x == 0xA || *x == 0xD ||
- (*x >= 0x20 && *x <= 0xD7FF) || (*x >= 0xE000 && *x <= 0x10FFFF))
+ else if (*x == 0x9 || *x == 0xA || *x == 0xD || *x >= 0x20)
{
// The XML specification defines the following characters as valid inside an XML document:
// Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp
index b43b6e2b6..59277bb9e 100644
--- a/src/modules/m_nationalchars.cpp
+++ b/src/modules/m_nationalchars.cpp
@@ -31,12 +31,12 @@
/* $ModDesc: Provides an ability to have non-RFC1459 nicks & support for national CASEMAPPING */
-class lwbNickHandler : public HandlerBase2<bool, const char*, size_t>
+class lwbNickHandler : public HandlerBase2<bool, const std::string&, size_t>
{
public:
lwbNickHandler() { }
virtual ~lwbNickHandler() { }
- virtual bool Call(const char*, size_t);
+ virtual bool Call(const std::string&, size_t);
};
/*,m_reverse_additionalUp[256];*/
@@ -71,11 +71,12 @@ char utf8size(unsigned char * mb)
/* Conditions added */
-bool lwbNickHandler::Call(const char* n, size_t max)
+bool lwbNickHandler::Call(const std::string& nick, size_t max)
{
- if (!n || !*n)
+ if (nick.empty())
return false;
+ const char* n = nick.c_str();
unsigned int p = 0;
for (const char* i = n; *i; i++, p++)
{
@@ -225,7 +226,7 @@ class ModuleNationalChars : public Module
lwbNickHandler myhandler;
std::string charset, casemapping;
unsigned char m_additional[256], m_additionalUp[256], m_lower[256], m_upper[256];
- caller2<bool, const char*, size_t> rememberer;
+ caller2<bool, const std::string&, size_t> rememberer;
bool forcequit;
const unsigned char * lowermap_rememberer;
@@ -276,7 +277,7 @@ class ModuleNationalChars : public Module
{
/* Fix by Brain: Dont quit UID users */
User* n = *iter;
- if (!isdigit(n->nick[0]) && !ServerInstance->IsNick(n->nick.c_str(), ServerInstance->Config->Limits.NickMax))
+ if (!isdigit(n->nick[0]) && !ServerInstance->IsNick(n->nick, ServerInstance->Config->Limits.NickMax))
ServerInstance->Users->QuitUser(n, message);
}
}
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index abeb25869..b5564f215 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -51,7 +51,7 @@ class CommandNicklock : public Command
/* Do local sanity checks and bails */
if (IS_LOCAL(user))
{
- if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
+ if (!ServerInstance->IsNick(parameters[1], ServerInstance->Config->Limits.NickMax))
{
user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str());
return CMD_FAILURE;
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index 207be2bb5..e2019e302 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -116,7 +116,7 @@ class NetworkPrefix : public ModeHandler
std::vector<std::string> mode_junk;
mode_junk.push_back(channel->name);
irc::modestacker modestack(false);
- std::deque<std::string> stackresult;
+ std::vector<std::string> stackresult;
for (UserMembCIter i = cl->begin(); i != cl->end(); i++)
{
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index a234c02c6..68e3594a5 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -61,7 +61,8 @@ class RLine : public XLine
bool Matches(User *u)
{
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
@@ -117,7 +118,7 @@ class RLineFactory : public XLineFactory
RLineFactory(dynamic_reference<RegexFactory>& rx) : XLineFactory("R"), rxfactory(rx)
{
}
-
+
/** Generate a RLine
*/
XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp
index 4e4be77ae..ba4fdc033 100644
--- a/src/modules/m_sanick.cpp
+++ b/src/modules/m_sanick.cpp
@@ -54,7 +54,7 @@ class CommandSanick : public Command
return CMD_FAILURE;
}
- if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
+ if (!ServerInstance->IsNick(parameters[1], ServerInstance->Config->Limits.NickMax))
{
user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str());
return CMD_FAILURE;
diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp
index fdb29d14f..7423e2672 100644
--- a/src/modules/m_setidle.cpp
+++ b/src/modules/m_setidle.cpp
@@ -25,16 +25,16 @@
/** Handle /SETIDLE
*/
-class CommandSetidle : public Command
+class CommandSetidle : public SplitCommand
{
public:
- CommandSetidle(Module* Creator) : Command(Creator,"SETIDLE", 1)
+ CommandSetidle(Module* Creator) : SplitCommand(Creator,"SETIDLE", 1)
{
flags_needed = 'o'; syntax = "<duration>";
TRANSLATE2(TR_TEXT, TR_END);
}
- CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+ CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
{
time_t idle = ServerInstance->Duration(parameters[0]);
if (idle < 1)
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 21959e400..c858e62ec 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -43,7 +43,8 @@ public:
bool Matches(User *u)
{
// E: overrides shun
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext))
@@ -107,7 +108,7 @@ class CommandShun : public Command
/* 'time' is a human-readable timestring, like 2d3h2s. */
std::string target = parameters[0];
-
+
User *find = ServerInstance->FindNick(target);
if ((find) && (find->registered == REG_ALL))
target = std::string("*!*@") + find->GetIPString();
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index cf0fde3e8..f36692a54 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -32,9 +32,6 @@ std::string TreeSocket::MyModules(int filter)
{
std::vector<std::string> modlist = ServerInstance->Modules->GetAllModuleNames(filter);
- if (filter == VF_COMMON && proto_version != ProtocolVersion)
- CompatAddModules(modlist);
-
std::string capabilities;
sort(modlist.begin(),modlist.end());
for (std::vector<std::string>::const_iterator i = modlist.begin(); i != modlist.end(); ++i)
diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp
index 8bc0cd2bb..70453b975 100644
--- a/src/modules/m_spanningtree/idle.cpp
+++ b/src/modules/m_spanningtree/idle.cpp
@@ -40,7 +40,8 @@ bool TreeSocket::Whois(const std::string &prefix, parameterlist &params)
User* x = ServerInstance->FindNick(params[0]);
if ((x) && (IS_LOCAL(x)))
{
- long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time()));
+ LocalUser* lu = IS_LOCAL(x);
+ long idle = abs((long)((lu->idle_lastmsg) - ServerInstance->Time()));
parameterlist par;
par.push_back(prefix);
par.push_back(ConvToStr(x->signon));
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 33c7f47b3..e6cec5cb4 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -55,7 +55,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist &params)
this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
return false;
}
- if (!ServerInstance->IsSID(sid))
+ if (!InspIRCd::IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index c1ca5e74a..85d256c61 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -186,9 +186,6 @@ class TreeSocket : public BufferedSocket
*/
void SendCapabilities(int phase);
- /** Add modules to VF_COMMON list for backwards compatability */
- void CompatAddModules(std::vector<std::string>& modlist);
-
/* Isolate and return the elements that are different between two lists */
void ListDifference(const std::string &one, const std::string &two, char sep,
std::string& mleft, std::string& mright);
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index cc1c400db..13d188432 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -61,7 +61,7 @@ ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from
*/
TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
{
- if (ServerInstance->IsSID(ServerName))
+ if (InspIRCd::IsSID(ServerName))
return this->FindServerID(ServerName);
server_hash::iterator iter = serverlist.find(ServerName.c_str());
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index 38bcb744a..7097cd8e2 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -57,21 +57,8 @@ class OpMeQuery : public SQLQuery
SQLEntries row;
while (res.GetRow(row))
{
-#if 0
- parameterlist cols;
- res.GetCols(cols);
-
- std::vector<KeyVal>* items;
- reference<ConfigTag> tag = ConfigTag::create("oper", "<m_sqloper>", 0, items);
- for(unsigned int i=0; i < cols.size(); i++)
- {
- if (!row[i].nul)
- items->insert(std::make_pair(cols[i], row[i]));
- }
-#else
if (OperUser(user, row[0], row[1]))
return;
-#endif
}
ServerInstance->Logs->Log("m_sqloper",DEBUG, "SQLOPER: no matches for %s (checked %d rows)", uid.c_str(), res.Rows());
// nobody succeeded... fall back to OPER
diff --git a/src/modules/u_listmode.h b/src/modules/u_listmode.h
index b370c86e8..b0a8f2505 100644
--- a/src/modules/u_listmode.h
+++ b/src/modules/u_listmode.h
@@ -367,14 +367,6 @@ class ListModeBase : public ModeHandler
}
}
- /** Clean up module on unload
- * @param target_type Type of target to clean
- * @param item Item to clean
- */
- virtual void DoCleanup(int, void*)
- {
- }
-
/** Validate parameters.
* Overridden by implementing module.
* @param source Source user adding the parameter
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 9cc2e7df7..382f4ffa0 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -28,24 +28,6 @@
#include "socketengine.h"
#include "command_parse.h"
-void FloodQuitUserHandler::Call(User* current)
-{
- ServerInstance->Logs->Log("USERS",DEFAULT,"Excess flood from: %s@%s", current->ident.c_str(), current->host.c_str());
- ServerInstance->SNO->WriteToSnoMask('f',"Excess flood from: %s%s%s@%s",
- current->registered == REG_ALL ? current->nick.c_str() : "",
- current->registered == REG_ALL ? "!" : "", current->ident.c_str(), current->host.c_str());
- ServerInstance->Users->QuitUser(current, "Excess flood");
-
- if (current->registered != REG_ALL)
- {
- ZLine* zl = new ZLine(ServerInstance->Time(), 0, ServerInstance->Config->ServerName, "Flood from unregistered connection", current->GetIPString());
- if (ServerInstance->XLines->AddLine(zl,NULL))
- ServerInstance->XLines->ApplyLines();
- else
- delete zl;
- }
-}
-
/**
* This function is called once a second from the mainloop.
* It is intended to do background checking on all the user structs, e.g.
diff --git a/src/users.cpp b/src/users.cpp
index cb07707cd..4241b8f81 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -201,10 +201,9 @@ User::User(const std::string &uid, const std::string& sid, int type)
: uuid(uid), server(sid), usertype(type)
{
age = ServerInstance->Time();
- signon = idle_lastmsg = 0;
+ signon = 0;
registered = 0;
- quietquit = quitting = exempt = dns_done = false;
- quitting_sendq = false;
+ quietquit = quitting = false;
client_sa.sa.sa_family = AF_UNSPEC;
ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str());
@@ -222,6 +221,8 @@ LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::so
bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0),
already_sent(0)
{
+ exempt = quitting_sendq = dns_done = false;
+ idle_lastmsg = 0;
ident = "unknown";
lastping = 0;
eh.SetFd(myfd);
@@ -734,7 +735,7 @@ void LocalUser::CheckClass()
this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;
}
-bool User::CheckLines(bool doZline)
+bool LocalUser::CheckLines(bool doZline)
{
const char* check[] = { "G" , "K", (doZline) ? "Z" : NULL, NULL };
diff --git a/src/xline.cpp b/src/xline.cpp
index 66d24f439..1f192e22a 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -158,7 +158,7 @@ void XLineManager::CheckELines()
for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
{
- User* u = (User*)(*u2);
+ LocalUser* u = *u2;
/* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */
LookupIter safei;
@@ -328,7 +328,7 @@ void ELine::Unset()
/* remove exempt from everyone and force recheck after deleting eline */
for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
{
- User* u = (User*)(*u2);
+ LocalUser* u = *u2;
u->exempt = false;
}
@@ -433,7 +433,7 @@ void XLineManager::ApplyLines()
LocalUserList::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin();
while (u2 != ServerInstance->Users->local_users.rend())
{
- User* u = *u2++;
+ LocalUser* u = *u2++;
// Don't ban people who are exempt.
if (u->exempt)
@@ -554,7 +554,8 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
bool KLine::Matches(User *u)
{
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
@@ -576,7 +577,8 @@ void KLine::Apply(User* u)
bool GLine::Matches(User *u)
{
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
@@ -598,7 +600,8 @@ void GLine::Apply(User* u)
bool ELine::Matches(User *u)
{
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
@@ -615,7 +618,8 @@ bool ELine::Matches(User *u)
bool ZLine::Matches(User *u)
{
- if (u->exempt)
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu && lu->exempt)
return false;
if (InspIRCd::MatchCIDR(u->GetIPString(), this->ipaddr))
@@ -681,7 +685,7 @@ void ELine::OnAdd()
/* When adding one eline, only check the one eline */
for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
{
- User* u = (User*)(*u2);
+ LocalUser* u = *u2;
if (this->Matches(u))
u->exempt = true;
}