]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #230 from Robby-/insp20-openssl
authorAttila Molnar <attilamolnar@hush.com>
Fri, 13 Jul 2012 19:24:06 +0000 (12:24 -0700)
committerAttila Molnar <attilamolnar@hush.com>
Fri, 13 Jul 2012 19:24:06 +0000 (12:24 -0700)
[2.0] m_ssl_openssl: Show cipher used on connect and allow available ciphers to be customized.

119 files changed:
configure
docs/Doxyfile
docs/conf/inspircd.conf.example
docs/conf/modules.conf.example
include/caller.h
include/channelmanager.h [deleted file]
include/channels.h
include/command_parse.h
include/configparser.h
include/configreader.h
include/ctables.h
include/extensible.h
include/hashcomp.h
include/inspircd.h
include/inspsocket.h
include/logger.h
include/membership.h
include/mode.h
include/modules.h
include/protocol.h
include/socket.h
include/socketengine.h
include/threadengines/threadengine_pthread.h
include/timer.h
include/typedefs.h
include/usermanager.h
include/users.h
include/xline.h
make/gnutlscert.pm
src/channelmanager.cpp [deleted file]
src/channels.cpp
src/commands/cmd_away.cpp
src/commands/cmd_clearcache.cpp
src/commands/cmd_commands.cpp
src/commands/cmd_eline.cpp
src/commands/cmd_invite.cpp
src/commands/cmd_ison.cpp
src/commands/cmd_join.cpp
src/commands/cmd_kick.cpp
src/commands/cmd_links.cpp
src/commands/cmd_loadmodule.cpp
src/commands/cmd_lusers.cpp
src/commands/cmd_motd.cpp
src/commands/cmd_names.cpp
src/commands/cmd_nick.cpp
src/commands/cmd_oper.cpp
src/commands/cmd_rehash.cpp
src/commands/cmd_stats.cpp
src/commands/cmd_userhost.cpp
src/commands/cmd_version.cpp
src/configparser.cpp
src/configreader.cpp
src/hashcomp.cpp
src/inspircd.cpp
src/mode.cpp
src/modes/cmode_b.cpp
src/modules.cpp
src/modules/extra/m_ldapoper.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/m_alltime.cpp
src/modules/m_blockamsg.cpp
src/modules/m_blockcolor.cpp
src/modules/m_botmode.cpp
src/modules/m_callerid.cpp
src/modules/m_cap.cpp
src/modules/m_cap.h
src/modules/m_chanhistory.cpp
src/modules/m_chanlog.cpp
src/modules/m_chgname.cpp
src/modules/m_commonchans.cpp
src/modules/m_dccallow.cpp
src/modules/m_deaf.cpp
src/modules/m_delaymsg.cpp
src/modules/m_dnsbl.cpp
src/modules/m_globops.cpp
src/modules/m_halfop.cpp
src/modules/m_helpop.cpp
src/modules/m_hidechans.cpp
src/modules/m_hideoper.cpp
src/modules/m_ident.cpp
src/modules/m_inviteexception.cpp
src/modules/m_lockserv.cpp
src/modules/m_mlock.cpp
src/modules/m_noctcp.cpp
src/modules/m_nonicks.cpp
src/modules/m_nonotice.cpp
src/modules/m_operchans.cpp
src/modules/m_operlevels.cpp
src/modules/m_opermodes.cpp
src/modules/m_override.cpp
src/modules/m_redirect.cpp
src/modules/m_sajoin.cpp
src/modules/m_samode.cpp
src/modules/m_satopic.cpp
src/modules/m_services_account.cpp
src/modules/m_setname.cpp
src/modules/m_showwhois.cpp
src/modules/m_shun.cpp
src/modules/m_spanningtree/addline.cpp
src/modules/m_spanningtree/fjoin.cpp
src/modules/m_spanningtree/svspart.cpp
src/modules/m_spanningtree/treesocket.h
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_sslmodes.cpp
src/modules/m_stripcolor.cpp
src/modules/m_swhois.cpp
src/modules/m_xline_db.cpp
src/server.cpp
src/socketengines/socketengine_ports.cpp
src/stats.cpp [deleted file]
src/usermanager.cpp
src/users.cpp
src/version.sh
win/inspircd.nsi
win/inspircd.vcxproj
win/inspircd_win32wrapper.h
win/make_gnutls_cert.bat [new file with mode: 0644]

index 61313c9fe2804e60be87b4550fa45a2e56799db0..8edcdfe08b0a2179c54c47f88f696d3d809c6530 100755 (executable)
--- a/configure
+++ b/configure
@@ -625,8 +625,8 @@ should NOT be used. You should probably specify a newer compiler.\n\n";
        }
        else
        {
-               print "\nCould not detect OpenSSL or GnuTLS. Make sure pkg-config is installed if\n";
-               print "you intend to use OpenSSL, or that GnuTLS is in your path if you intend\nto use GnuTLS.\n\n";
+               print "\nCould not detect OpenSSL or GnuTLS. Make sure pkg-config is installed and\n";
+               print "is in your path.\n\n";
        }
 
        yesno('MODUPDATE',"Would you like to check for updates to third-party modules?");
index dd74f58abf97d1a91d5186423fd64ea4694f226a..c2abe85d80f3a15494ededa4619512c61e71e157 100644 (file)
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.0
+# Doxyfile 1.8.1
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project.
@@ -553,12 +553,6 @@ MAX_INITIALIZER_LINES  = 30
 
 SHOW_USED_FILES        = YES
 
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES       = NO
-
 # Set the SHOW_FILES tag to NO to disable the generation of the Files page.
 # This will remove the Files entry from the Quick Index and from the
 # Folder Tree View (if specified). The default is YES.
@@ -707,7 +701,11 @@ EXCLUDE_SYMLINKS       = YES
 # against the file with absolute path, so to exclude all test directories
 # for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = */.git/* */doxygen/*
+EXCLUDE_PATTERNS       = */.git/* \
+                         */doxygen/* \
+                         */commands/* \
+                         */modes/* \
+                         */modules/*
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
@@ -947,20 +945,23 @@ HTML_COLORSTYLE_GAMMA  = 80
 
 HTML_TIMESTAMP         = NO
 
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS     = YES
-
 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
 # documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+# page has loaded.
 
 HTML_DYNAMIC_SECTIONS  = NO
 
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
+# entries shown in the various tree structured indices initially; the user
+# can expand and collapse entries dynamically later on. Doxygen will expand
+# the tree to such a level that at most the specified number of entries are
+# visible (unless a fully collapsed tree already exceeds this amount).
+# So setting the number of entries 1 will produce a full collapsed tree by
+# default. 0 is a special value representing an infinite number of entries
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
 # If the GENERATE_DOCSET tag is set to YES, additional index files
 # will be generated that can be used as input for Apple's Xcode 3
 # integrated development environment, introduced with OSX 10.5 (Leopard).
@@ -1139,11 +1140,6 @@ GENERATE_TREEVIEW      = NO
 
 ENUM_VALUES_PER_LINE   = 4
 
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES       = NO
-
 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
 # used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
@@ -1711,7 +1707,7 @@ CALLER_GRAPH           = NO
 
 GRAPHICAL_HIERARCHY    = YES
 
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
 # then doxygen will show the dependencies a directory has on other directories
 # in a graphical way. The dependency relations are determined by the #include
 # relations between the files in the directories.
index d1293be25b2129f79a3b5b240bc92fc75a3fdf21..f483e6692d11c56b64eb95ea091eb8b94043da9a 100644 (file)
          # specified using <files secretmotd="filename"> or <execfiles ...>
          motd="secretmotd"
 
+         # Allow color codes to be processed in the message of the day file.
+         # the following characters are valid color code escapes:
+         #   \002 or \b = Bold
+         #   \037 or \u = Underline
+         #   \003 or \c = Color (with a code postfixed to this char)
+         #   \017 or \x = Stop all color sequences
+         allowmotdcolors="false"
+
          # port: What port this user is allowed to connect on. (optional)
          # The port MUST be set to listen in the bind blocks above.
          port="6697">
index e987f48781523ee6b5ed689407231eec85f62868..f86ebfa6ca7c20f29d31e8d4bea7004c6775673f 100644 (file)
 #<randquote file="randquotes.conf">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
-# Redirect module: Adds channel redirection (mode +L)
+# Redirect module: Adds channel redirection (mode +L)                 #
+# Optional: <redirect:antiredirect> to add usermode +L to stop forced #
+# redirection and instead print an error.                             #
+#                                                                     #
+# Note: You can not update this with a simple rehash, it requires     #
+# reloading the module for it to take effect.                         #
+# This also breaks linking to servers that do not have the option.    #
+# This defaults to false for the 2.0 version, it will be enabled in   #
+# all the future versions.                                            #
 #<module name="m_redirect.so">
+#<redirect antiredirect="true">
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 # Regular Expression Provider for Glob or wildcard (?/*) matching.
index 88e7df4a1349015623d24af1572299daa2d801b0..64b37611f04d4512e879322b5efae1ca8359c6c5 100644 (file)
@@ -44,7 +44,7 @@
  *
  * MyNewFunction replaceme(ServerInstance);
  *
- * someclass->MyFunction = &replaceme;
+ * someclass->MyFunction = \&replaceme;
  *
  * After this point, calls to someclass->MyFunction will call the new code in your
  * replacement functor.
diff --git a/include/channelmanager.h b/include/channelmanager.h
deleted file mode 100644 (file)
index 58d4fce..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
- *
- * 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/>.
- */
-
-
-#ifndef CHANNELMANAGER_H
-#define CHANNELMANAGER_H
-
-/** THe channel manager class allocates and deallocates channels and manages
- * the container which holds them. For some reason, nobody finished this.
- * TODO: Finish in future release!
- */
-class CoreExport ChannelManager
-{
- public:
-       /** Constructor
-        */
-       ChannelManager()
-       {
-       }
-};
-
-#endif
index 89ac6b86ca0327b6a43e9b3da741dc7bb44d802a..dda53f69da0b0be756bbcd9d5de59d76aaca4c50 100644 (file)
@@ -56,7 +56,7 @@ class BanItem : public HostItem
  * This class represents a channel, and contains its name, modes, topic, topic set time,
  * etc, and an instance of the BanList type.
  */
-class CoreExport Channel : public Extensible
+class CoreExport Channel : public Extensible, public InviteBase
 {
        /** Connect a Channel to a User
         */
@@ -122,7 +122,7 @@ class CoreExport Channel : public Extensible
 
        /** Sets or unsets a custom mode in the channels info
         * @param mode The mode character to set or unset
-        * @param mode_on True if you want to set the mode or false if you want to remove it
+        * @param value True if you want to set the mode or false if you want to remove it
         */
        void SetMode(ModeHandler* mode, bool value);
        void SetMode(char mode,bool mode_on);
@@ -147,7 +147,7 @@ class CoreExport Channel : public Extensible
          * @param mode The mode character you wish to query
          *
          * For example if "+L #foo" is set, and you pass this method
-         * 'L', it will return '#foo'. If the mode is not set on the
+         * 'L', it will return '\#foo'. If the mode is not set on the
          * channel, or the mode has no parameters associated with it,
          * it will return an empty string.
          *
@@ -199,7 +199,7 @@ class CoreExport Channel : public Extensible
        const UserMembList* GetUsers();
 
        /** Returns true if the user given is on the given channel.
-        * @param The user to look for
+        * @param user The user to look for
         * @return True if the user is on this channel
         */
        bool HasUser(User* user);
@@ -261,7 +261,7 @@ class CoreExport Channel : public Extensible
         * Internally, this calls WriteAllExcept().
         * @param user User whos details to prefix the line with, and to omit from receipt of the message
         * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
-        * use the nick!user@host of the user.
+        * use the nick!user\@host of the user.
         * @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
         * @param text A printf-style format string which builds the output line without prefix
         * @param ... Zero or more POD type
@@ -271,7 +271,7 @@ class CoreExport Channel : public Extensible
        /** Write to all users on a channel except a list of users, using va_args for text
         * @param user User whos details to prefix the line with, and to omit from receipt of the message
         * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
-        * use the nick!user@host of the user.
+        * use the nick!user\@host of the user.
         * @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
         * @param except_list A list of users NOT to send the text to
         * @param text A printf-style format string which builds the output line without prefix
@@ -283,7 +283,7 @@ class CoreExport Channel : public Extensible
         * Internally, this calls WriteAllExcept().
         * @param user User whos details to prefix the line with, and to omit from receipt of the message
         * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
-        * use the nick!user@host of the user.
+        * use the nick!user\@host of the user.
         * @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
         * @param text A std::string containing the output line without prefix
         */
@@ -292,7 +292,7 @@ class CoreExport Channel : public Extensible
        /** Write to all users on a channel except a list of users, using std::string for text
         * @param user User whos details to prefix the line with, and to omit from receipt of the message
         * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
-        * use the nick!user@host of the user.
+        * use the nick!user\@host of the user.
         * @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
         * @param except_list A list of users NOT to send the text to
         * @param text A std::string containing the output line without prefix
index 35d4be2b04f7c608fd4879d949f798c6fdba580e..f6ff588e1a82139742fd29997a99b8254e99a871 100644 (file)
@@ -60,7 +60,6 @@ class CoreExport CommandParser
        Commandtable cmdlist;
 
        /** Default constructor.
-        * @param Instance The creator of this class
         */
        CommandParser();
 
@@ -97,7 +96,7 @@ class CoreExport CommandParser
         * We need a version which takes two potential lists for JOIN, because a JOIN may contain two lists of items at once,
         * the channel names and their keys as follows:
         *
-        * JOIN #chan1,#chan2,#chan3 key1,,key3
+        * JOIN \#chan1,\#chan2,\#chan3 key1,,key3
         *
         * Therefore, we need to deal with both lists concurrently. The first instance of this method does that by creating
         * two instances of irc::commasepstream and reading them both together until the first runs out of tokens.
@@ -107,7 +106,6 @@ class CoreExport CommandParser
         * @param user The user who sent the command
         * @param CommandObj the command object to call for each parameter in the list
         * @param parameters Parameter list as an array of array of char (that's not a typo).
-        * @param The number of items in the parameters list
         * @param splithere The first parameter index to split as a comma seperated list
         * @param extra The second parameter index to split as a comma seperated list
         * @param usemax Limit the command to MaxTargets targets
index 478899ed92f203481515541e6df68d04552af6ee..4b83d26d7e01dfceb37a879649f17259710aaa6a 100644 (file)
@@ -61,13 +61,19 @@ struct ParseStack
 struct FileWrapper
 {
        FILE* const f;
-       FileWrapper(FILE* file) : f(file) {}
+       bool close_with_pclose;
+       FileWrapper(FILE* file, bool use_pclose = false) : f(file), close_with_pclose(use_pclose) {}
        operator bool() { return f; }
        operator FILE*() { return f; }
        ~FileWrapper()
        {
                if (f)
-                       fclose(f);
+               {
+                       if (close_with_pclose)
+                               pclose(f);
+                       else
+                               fclose(f);
+               }
        }
 };
 
index f42bf67fea6c1c5adf3bbe820fc84457b1b55b10..e360d391735ed2775ad208388aa66ee8e9d941f5 100644 (file)
@@ -33,7 +33,7 @@
 #include "socketengine.h"
 #include "socket.h"
 
-/** Structure representing a single <tag> in config */
+/** Structure representing a single \<tag> in config */
 class CoreExport ConfigTag : public refcountbase
 {
        std::vector<KeyVal> items;
@@ -174,11 +174,11 @@ class CoreExport OperInfo : public refcountbase
        /** Allowed channel modes from oper classes. */
        std::bitset<64> AllowedChanModes;
 
-       /** <oper> block used for this oper-up. May be NULL. */
+       /** \<oper> block used for this oper-up. May be NULL. */
        reference<ConfigTag> oper_block;
-       /** <type> block used for this oper-up. Valid for local users, may be NULL on remote */
+       /** \<type> block used for this oper-up. Valid for local users, may be NULL on remote */
        reference<ConfigTag> type_block;
-       /** <class> blocks referenced from the <type> block. These define individual permissions */
+       /** \<class> blocks referenced from the \<type> block. These define individual permissions */
        std::vector<reference<ConfigTag> > class_blocks;
        /** Name of the oper type; i.e. the one shown in WHOIS */
        std::string name;
@@ -208,7 +208,6 @@ class CoreExport ServerConfig
 
        /** Get a configuration tag
         * @param tag The name of the tag to get
-        * @param offset get the Nth occurance of the tag
         */
        ConfigTag* ConfValue(const std::string& tag);
 
@@ -375,7 +374,7 @@ class CoreExport ServerConfig
        /** The full path to the modules directory.
         * This is either set at compile time, or
         * overridden in the configuration file via
-        * the <path> tag.
+        * the \<path> tag.
         */
        std::string ModPath;
 
@@ -391,7 +390,7 @@ class CoreExport ServerConfig
        bool RestrictBannedUsers;
 
        /** If this is set to true, then mode lists (e.g
-        * MODE #chan b) are hidden from unprivileged
+        * MODE \#chan b) are hidden from unprivileged
         * users.
         */
        bool HideModeLists[256];
@@ -515,7 +514,7 @@ class CoreExport ServerConfig
         */
        bool UndernetMsgPrefix;
 
-       /** If set to true, the full nick!user@host will be shown in the TOPIC command
+       /** If set to true, the full nick!user\@host will be shown in the TOPIC command
         * for who set the topic last. If false, only the nick is shown.
         */
        bool FullHostInTopic;
@@ -569,7 +568,11 @@ class CoreExport ServerConfig
 
        void Fill();
 
-       /* Returns true if the given string starts with a windows drive letter
+       /** Parses color codes from string values to actual color codes
+        */
+       void ProcessColors(ConfigFileCache::iterator &file);
+
+       /** Returns true if the given string starts with a windows drive letter
         */
        bool StartsWithWindowsDriveLetter(const std::string &path);
 
index 0bd8f360c921e358969c20ce19c39a582b825e97..f016dd4c5b4fae6e30e1d2dd4f1ae26dce701fe8 100644 (file)
@@ -147,15 +147,11 @@ class CoreExport Command : public ServiceProvider
        int Penalty;
 
        /** Create a new command.
-        * @param Instance Pointer to creator class
+        * @param me The module which created this command.
         * @param cmd Command name. This must be UPPER CASE.
-        * @param flags User mode required to execute the command. May ONLY be one mode - it's a string to give warnings if people mix params up.
-        * For oper only commands, set this to 'o', otherwise use 0.
         * @param minpara Minimum parameters required for the command.
-        * @param maxpara Maximum number of parameters this command may have - extra parameters will be tossed into one last space-seperated param.
-        * @param before_reg If this is set to true, the command will
-        * be allowed before the user is 'registered' (has sent USER,
-        * NICK, optionally PASS, and been resolved).
+        * @param maxpara Maximum number of parameters this command may have - extra parameters
+        * will be tossed into one last space-seperated param.
         */
        Command(Module* me, const std::string &cmd, int minpara = 0, int maxpara = 0) :
                ServiceProvider(me, cmd, SERVICE_COMMAND), flags_needed(0), min_params(minpara), max_params(maxpara),
index 40e820d680460ff52b4ba38f983890721f4d9065..f327cf75c0144dbef88afbe0a92de4504c1d936b 100644 (file)
  */
 
 
+#ifndef EXTENSIBLE_H
+#define EXTENSIBLE_H
+
+#include <stdint.h>
+
 enum SerializeFormat
 {
        /** Shown to a human (does not need to be unserializable) */
@@ -185,3 +190,5 @@ class CoreExport StringExtItem : public ExtensionItem
        void unset(Extensible* container);
        void free(void* item);
 };
+
+#endif
index d9516e7fa4707936997e6468f3c52466404c9d0b..59986e66f1fbb20e38ecb4b1aba6f64a4ddf648b 100644 (file)
@@ -157,7 +157,7 @@ namespace irc
 
        /** Compose a hex string from raw data.
         * @param raw The raw data to compose hex from
-        * @pram rawsz The size of the raw data buffer
+        * @param rawsz The size of the raw data buffer
         * @return The hex string.
         */
        CoreExport std::string hex(const unsigned char *raw, size_t rawsz);
@@ -441,7 +441,7 @@ namespace irc
 
                /** Used to split on commas
                 */
-               commasepstream* sep;
+               commasepstream sep;
 
                /** Current position in a range of ports
                 */
@@ -462,7 +462,7 @@ namespace irc
                /** Used to determine overlapping of ports
                 * without O(n) algorithm being used
                 */
-               std::map<long, bool> overlap_set;
+               std::set<long> overlap_set;
 
                /** Returns true if val overlaps an existing range
                 */
@@ -475,10 +475,6 @@ namespace irc
                 */
                portparser(const std::string &source, bool allow_overlapped = true);
 
-               /** Frees the internal commasepstream object
-                */
-               ~portparser();
-
                /** Fetch the next token from the stream
                 * @return The next port number is returned, or 0 if none remain
                 */
@@ -596,7 +592,7 @@ inline std::string& trim(std::string &str)
 }
 
 /** Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of
- * #ifdefs we'll just do it all at once. Except, of course, with TR1, when it's the same as GCC.
+ * \#ifdefs we'll just do it all at once. Except, of course, with TR1, when it's the same as GCC.
  */
 BEGIN_HASHMAP_NAMESPACE
 
index 9c9609530b0cc867e8be250be0750ae61b3b0d8a..c06a28043b4be3154ea91c3b28010922f846bd90 100644 (file)
@@ -348,16 +348,16 @@ class CoreExport InspIRCd
        static const char LogHeader[];
 
        /** Find a user in the UUID hash
-        * @param nick The nickname to find
+        * @param uid The UUID to find
         * @return A pointer to the user, or NULL if the user does not exist
         */
-       User* FindUUID(const std::string &);
+       User* FindUUID(const std::string &uid);
 
        /** Find a user in the UUID hash
-        * @param nick The nickname to find
+        * @param uid The UUID to find
         * @return A pointer to the user, or NULL if the user does not exist
         */
-       User* FindUUID(const char *);
+       User* FindUUID(const char *uid);
 
        /** Build the ISUPPORT string by triggering all modules On005Numeric events
         */
@@ -460,10 +460,6 @@ class CoreExport InspIRCd
         */
        LocalStringExt OperQuit;
 
-       /** Holds whether the MOTD has been parsed for color codes
-       */
-       bool ProcessedMotdEscapes;
-
        /** Get the current time
         * Because this only calls time() once every time around the mainloop,
         * it is much faster than calling time() directly.
@@ -498,6 +494,7 @@ class CoreExport InspIRCd
         * @param sockfd A valid file descriptor of an open socket
         * @param port The port number to bind to
         * @param addr The address to bind to (IP only)
+        * @param dolisten Should this port be listened on?
         * @return True if the port was bound successfully
         */
        bool BindSocket(int sockfd, int port, const char* addr, bool dolisten = true);
@@ -585,7 +582,7 @@ class CoreExport InspIRCd
        /** Causes the server to exit after unloading modules and
         * closing all open file descriptors.
         *
-        * @param The exit code to give to the operating system
+        * @param status The exit code to give to the operating system
         * (See the ExitStatus enum for valid values)
         */
        void Exit(int status);
@@ -664,6 +661,7 @@ class CoreExport InspIRCd
         * to check case against (may be NULL). If map is null, match will be case insensitive.
         * @param str The literal string to match against
         * @param mask The glob pattern to match against.
+        * @param map The character map to use when matching.
         */
        static bool Match(const std::string &str, const std::string &mask, unsigned const char *map = NULL);
        static bool Match(const  char *str, const char *mask, unsigned const char *map = NULL);
@@ -673,6 +671,7 @@ class CoreExport InspIRCd
         * Supports CIDR patterns as well as globs.
         * @param str The literal string to match against
         * @param mask The glob or CIDR pattern to match against.
+        * @param map The character map to use when matching.
         */
        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);
@@ -680,15 +679,14 @@ class CoreExport InspIRCd
        /** Call the handler for a given command.
         * @param commandname The command whos handler you wish to call
         * @param parameters The mode parameters
-        * @param pcnt The number of items you have given in the first parameter
         * @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 parameters The mode parameters
-        * @param pcnt The number of items you have given in the first parameter
+        * @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
         */
@@ -792,10 +790,6 @@ class CoreExport InspIRCd
         */
        void SendWhoisLine(User* user, User* dest, int numeric, const char* format, ...) CUSTOM_PRINTF(5, 6);
 
-       /** Handle /STATS
-        */
-       void DoStats(char statschar, User* user, string_list &results);
-
        /** Handle /WHOIS
         */
        void DoWhois(User* user, User* dest,unsigned long signon, unsigned long idle, const char* nick);
index f00d6a96ae744c2463d10f684414b7895d3c6de9..6eb7eb584d342911d1d2a4e4dd9971c70cc93ed0 100644 (file)
@@ -85,7 +85,6 @@ class CoreExport SocketTimeout : public Timer
  public:
        /** Create a socket timeout class
         * @param fd File descriptor of BufferedSocket
-        * @pram Instance server instance to attach to
         * @param thesock BufferedSocket to attach to
         * @param secs_from_now Seconds from now to time out
         * @param now The current time
@@ -195,9 +194,10 @@ class CoreExport BufferedSocket : public StreamSocket
         * This will create a socket, register with socket engine, and start the asynchronous
         * connection process. If an error is detected at this point (such as out of file descriptors),
         * OnError will be called; otherwise, the state will become CONNECTING.
-        * @param dest Address to connect to
-        * @param bind Address to bind to (if NULL, no bind will be done)
-        * @param timeout Time to wait for connection
+        * @param ipaddr Address to connect to
+        * @param aport Port to connect on
+        * @param maxtime Time to wait for connection
+        * @param connectbindip Address to bind to (if NULL, no bind will be done)
         */
        void DoConnect(const std::string &ipaddr, int aport, unsigned long maxtime, const std::string &connectbindip);
 
index 6c4acb41be75811d552ae5c8cd3afb7960bd9915..0fa4bc7cd029ce7374b3548128c61276d767089f 100644 (file)
@@ -160,7 +160,7 @@ class CoreExport LogManager
                }
        }
 
-       /** Opens all logfiles defined in the configuration file using <log method="file">.
+       /** Opens all logfiles defined in the configuration file using \<log method="file">.
         */
        void OpenFileLogs();
 
@@ -207,7 +207,7 @@ class CoreExport LogManager
        /** Logs an event, sending it to all LogStreams registered for the type.
         * @param type Log message type (ex: "USERINPUT", "MODULE", ...)
         * @param loglevel Log message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
-        * @param msg The format of the message to be logged. See your C manual on printf() for details.
+        * @param fmt The format of the message to be logged. See your C manual on printf() for details.
         */
        void Log(const std::string &type, int loglevel, const char *fmt, ...) CUSTOM_PRINTF(4, 5);
 };
index 281d04f70ba1818366416b77d2aee32ad1e99d3d..436a9371c5c30ef60505d3be81026d9b4aec016a 100644 (file)
@@ -35,4 +35,29 @@ class CoreExport Membership : public Extensible
        unsigned int getRank();
 };
 
+class CoreExport InviteBase
+{
+ protected:
+       InviteList invites;
+
+ public:
+       void ClearInvites();
+
+       friend class Invitation;
+};
+
+class Invitation : public classbase
+{
+       Invitation(Channel* c, LocalUser* u, time_t timeout) : user(u), chan(c), expiry(timeout) {}
+
+ public:
+       LocalUser* const user;
+       Channel* const chan;
+       time_t expiry;
+
+       ~Invitation();
+       static void Create(Channel* c, LocalUser* u, time_t timeout);
+       static Invitation* Find(Channel* c, LocalUser* u, bool check_expired = true);
+};
+
 #endif
index 501d04aae52f3f245d08110a93ac5c4a0f3e6ac0..1dab442d40ac6d993ae8c8787a89fc93c66e83a1 100644 (file)
@@ -154,6 +154,7 @@ class CoreExport ModeHandler : public ServiceProvider
         * The constructor for ModeHandler initalizes the mode handler.
         * The constructor of any class you derive from ModeHandler should
         * probably call this constructor with the parameters set correctly.
+        * @param me The module which created this mode
         * @param name A one-word name for the mode
         * @param modeletter The mode letter you wish to handle
         * @param params Parameters taken by the mode
@@ -233,7 +234,7 @@ class CoreExport ModeHandler : public ServiceProvider
         */
        virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding); /* Can change the mode parameter as its a ref */
        /**
-        * If your mode is a listmode, then this method will be called for displaying an item list, e.g. on MODE #channel +modechar
+        * If your mode is a listmode, then this method will be called for displaying an item list, e.g. on MODE \#channel +modechar
         * without any parameter or other modes in the command.
         * @param user The user issuing the command
         * @param channel The channel they're requesting an item list of (e.g. a banlist, or an exception list etc)
@@ -274,6 +275,7 @@ class CoreExport ModeHandler : public ServiceProvider
         * and can be used when your mode is of this type, otherwise you must implement a more advanced version of it to remove
         * your mode properly from each user.
         * @param user The user which the server wants to remove your mode from
+        * @param stack The mode stack to add the mode change to
         */
        virtual void RemoveMode(User* user, irc::modestacker* stack = NULL);
 
@@ -284,6 +286,7 @@ class CoreExport ModeHandler : public ServiceProvider
         * and can be used when your mode is of this type, otherwise you must implement a more advanced version of it to remove
         * your mode properly from each channel. Note that in the case of listmodes, you should remove the entire list of items.
         * @param channel The channel which the server wants to remove your mode from
+        * @param stack The mode stack to add the mode change to
         */
        virtual void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
 
@@ -342,7 +345,7 @@ class CoreExport ModeWatcher : public classbase
         */
        char mode;
        /**
-        * The mode type being watched (user or  channel)
+        * The mode type being watched (user or channel)
         */
        ModeType m_type;
 
@@ -377,7 +380,7 @@ class CoreExport ModeWatcher : public classbase
         * If you alter the parameter you are given, the mode handler will see your atered version
         * when it handles the mode.
         * @param adding True if the mode is being added and false if it is being removed
-        * @type The mode type, either MODETYPE_USER or MODETYPE_CHANNEL
+        * @param type The mode type, either MODETYPE_USER or MODETYPE_CHANNEL
         * @return True to allow the mode change to go ahead, false to abort it. If you abort the
         * change, the mode handler (and ModeWatcher::AfterMode()) will never see the mode change.
         */
@@ -390,7 +393,7 @@ class CoreExport ModeWatcher : public classbase
         * @param parameter The parameter of the mode, if the mode is supposed to have a parameter.
         * You cannot alter the parameter here, as the mode handler has already processed it.
         * @param adding True if the mode is being added and false if it is being removed
-        * @type The mode type, either MODETYPE_USER or MODETYPE_CHANNEL
+        * @param type The mode type, either MODETYPE_USER or MODETYPE_CHANNEL
         */
        virtual void AfterMode(User* source, User* dest, Channel* channel, const std::string &parameter, bool adding, ModeType type);
 };
@@ -459,9 +462,9 @@ class CoreExport ModeParser
         *
         * nick!ident -> nick!ident@*
         *
-        * host.name -> *!*@host.name
+        * host.name -> *!*\@host.name
         *
-        * ident@host.name -> *!ident@host.name
+        * ident@host.name -> *!ident\@host.name
         *
         * This method can be used on both IPV4 and IPV6 user masks.
         */
@@ -508,14 +511,15 @@ class CoreExport ModeParser
         * @param parameters The parameters of the mode change, in the format
         * they would be from a MODE command.
         * @param user The user setting or removing the modes. When the modes are set
-        * by a server, an 'uninitialized' User is used, where *user::nick == NULL
+        * by a server, an 'uninitialized' User is used, where *user\::nick == NULL
         * and *user->server == NULL.
+        * @param merge Should the mode parameters be merged?
         */
        void Process(const std::vector<std::string>& parameters, User *user, bool merge = false);
 
        /** Find the mode handler for a given mode and type.
         * @param modeletter mode letter to search for
-        * @param type of mode to search for, user or channel
+        * @param mt type of mode to search for, user or channel
         * @returns a pointer to a ModeHandler class, or NULL of there isnt a handler for the given mode
         */
        ModeHandler* FindMode(unsigned const char modeletter, ModeType mt);
index 7cd6bbeab5e9d7cfc65a1d6bfbfff6d9cff69030..49c16ae6115ab549faee1e3ec72420b2e9c084d5 100644 (file)
@@ -116,7 +116,7 @@ struct ModResult {
  * and numerical comparisons in preprocessor macros if they wish to support
  * multiple versions of InspIRCd in one file.
  */
-#define INSPIRCD_VERSION_API 2
+#define INSPIRCD_VERSION_API 1
 
 /**
  * This #define allows us to call a method in all
@@ -339,7 +339,6 @@ enum Implementation
        I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
        I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
        I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent,
-       I_OnSetClientIP,
        I_END
 };
 
@@ -431,6 +430,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param sync This is set to true if the JOIN is the result of a network sync and the remote user is being introduced
         * to a channel due to the network sync.
         * @param created This is true if the join created the channel
+        * @param except_list A list of users not to send to.
         */
        virtual void OnUserJoin(Membership* memb, bool sync, bool created, CUList& except_list);
 
@@ -439,13 +439,14 @@ class CoreExport Module : public classbase, public usecountbase
         * seen the join.
         * @param memb The channel membership created
         */
-       virtual void OnPostJoin(Membership*);
+       virtual void OnPostJoin(Membership* memb);
 
        /** Called when a user parts a channel.
         * The details of the leaving user are available to you in the parameter User *user,
         * and the details of the channel they have left is available in the variable Channel *channel
         * @param memb The channel membership being destroyed
         * @param partmessage The part message, or an empty string (may be modified)
+        * @param except_list A list of users to not send to.
         */
        virtual void OnUserPart(Membership* memb, std::string &partmessage, CUList& except_list);
 
@@ -515,8 +516,7 @@ class CoreExport Module : public classbase, public usecountbase
         * output to be sent to the user by the core. If you do this you must produce your own numerics,
         * notices etc.
         * @param source The user issuing the kick
-        * @param user The user being kicked
-        * @param chan The channel the user is being kicked from
+        * @param memb The channel membership of the user who is being kicked.
         * @param reason The kick reason
         * @return 1 to prevent the kick, 0 to continue normally, -1 to explicitly allow the kick regardless of normal operation
         */
@@ -526,9 +526,9 @@ class CoreExport Module : public classbase, public usecountbase
         * If this method is called, the kick is already underway and cannot be prevented, so
         * to prevent a kick, please use Module::OnUserPreKick instead of this method.
         * @param source The user issuing the kick
-        * @param user The user being kicked
-        * @param chan The channel the user is being kicked from
+        * @param memb The channel membership of the user who was kicked.
         * @param reason The kick reason
+        * @param except_list A list of users to not send to.
         */
        virtual void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& except_list);
 
@@ -662,6 +662,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param target_type The type of target (TYPE_USER or TYPE_CHANNEL)
         * @param text the text being sent by the user
         * @param status The status being used, e.g. PRIVMSG @#chan has status== '@', 0 to send to everyone.
+        * @param exempt_list A list of users to not send to.
         */
        virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
 
@@ -673,6 +674,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param target_type The type of target (TYPE_USER or TYPE_CHANNEL)
         * @param text the text being sent by the user
         * @param status The status being used, e.g. NOTICE @#chan has status== '@', 0 to send to everyone.
+        * @param exempt_list A list of users to not send to.
         */
        virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
 
@@ -687,6 +689,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param target_type The type of target (TYPE_USER or TYPE_CHANNEL)
         * @param text the text being sent by the user
         * @param status The status being used, e.g. NOTICE @#chan has status== '@', 0 to send to everyone.
+        * @param exempt_list A list of users not to send to. For channel messages, this will usually contain just the sender.
         */
        virtual void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list);
 
@@ -756,7 +759,6 @@ class CoreExport Module : public classbase, public usecountbase
 
        /** Allows module data, sent via ProtoSendMetaData, to be decoded again by a receiving module.
         * Please see src/modules/m_swhois.cpp for a working example of how to use this method call.
-        * @param target_type The type of item to decode data for, TYPE_USER or TYPE_CHANNEL
         * @param target The Channel* or User* that data should be added to
         * @param extname The extension name which is being sent
         * @param extdata The extension data, encoded at the other end by an identical module through OnSyncChannelMetaData or OnSyncUserMetaData
@@ -788,7 +790,6 @@ class CoreExport Module : public classbase, public usecountbase
         * More documentation to follow soon. Please see src/modules/m_swhois.cpp for example 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 metadata should be sent for
         * @param extname The extension name to send metadata for
         * @param extdata Encoded data for this extension name, which will be encoded at the oppsite end by an identical module using OnDecodeMetaData
@@ -818,7 +819,7 @@ class CoreExport Module : public classbase, public usecountbase
        /** Called whenever a user's IDENT is changed.
         * This event triggers after the name has been set.
         * @param user The user who's IDENT is being changed
-        * @param gecos The new IDENT being set on the user
+        * @param ident The new IDENT being set on the user
         */
        virtual void OnChangeIdent(User* user, const std::string &ident);
 
@@ -902,6 +903,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param source The user sending the KILL
         * @param dest The user being killed
         * @param reason The kill reason
+        * @param operreason The oper kill reason
         */
        virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
 
@@ -928,7 +930,6 @@ class CoreExport Module : public classbase, public usecountbase
         * absolutely neccessary (e.g. a module that extends the features of another
         * module).
         * @param mod Pointer to the module being unloaded (still valid)
-        * @param name The filename of the module being unloaded
         */
        virtual void OnUnloadModule(Module* mod);
 
@@ -951,7 +952,6 @@ class CoreExport Module : public classbase, public usecountbase
         * method returns, it will be passed an invalid pointer to the user object and crash!)
         * @param command The command being executed
         * @param parameters An array of array of characters containing the parameters for the command
-        * @param pcnt The nuimber of parameters passed to the command
         * @param user the user issuing the command
         * @param validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc.
         * You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs).
@@ -967,7 +967,6 @@ class CoreExport Module : public classbase, public usecountbase
         * provided.
         * @param command The command being executed
         * @param parameters An array of array of characters containing the parameters for the command
-        * @param pcnt The nuimber of parameters passed to the command
         * @param user the user issuing the command
         * @param result The return code given by the command handler, one of CMD_SUCCESS or CMD_FAILURE
         * @param original_line The entire original line as passed to the parser from the user
@@ -1033,6 +1032,7 @@ class CoreExport Module : public classbase, public usecountbase
         * return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
         * @param user The user joining the channel
         * @param chan The channel being joined
+        * @param keygiven The key given on joining the channel.
         * @return 1 to explicitly allow the join, 0 to proceed as normal
         */
        virtual ModResult OnCheckKey(User* user, Channel* chan, const std::string &keygiven);
@@ -1105,7 +1105,7 @@ class CoreExport Module : public classbase, public usecountbase
         * @param user The user changing the topic
         * @param chan The channels who's topic is being changed
         * @param topic The actual topic text
-        * @param 1 to block the topic change, 0 to allow
+        * @return 1 to block the topic change, 0 to allow
         */
        virtual ModResult OnPreTopicChange(User* user, Channel* chan, const std::string &topic);
 
@@ -1133,7 +1133,7 @@ class CoreExport Module : public classbase, public usecountbase
         * The password field (from the config file) is in 'password' and is to be compared against
         * 'input'. This method allows for encryption of passwords (oper, connect:allow, die/restart, etc).
         * You should return a nonzero value to override the normal comparison, or zero to pass it on.
-        * @param ex The object that's causing the authentication (User* for <oper> <connect:allow> etc, Server* for <link>).
+        * @param ex The object that's causing the authentication (User* for \<oper> \<connect:allow> etc, Server* for \<link>).
         * @param password The password from the configuration file (the password="" value).
         * @param input The password entered by the user or whoever.
         * @param hashtype The hash value from the config
@@ -1176,62 +1176,61 @@ class CoreExport Module : public classbase, public usecountbase
        virtual ModResult OnDelBan(User* source, Channel* channel,const std::string &banmask);
 
        /** Called to install an I/O hook on an event handler
-        * @param user The item to possibly install the I/O hook on
-        * @param via The port that <user> connected on
+        * @param user The socket to possibly install the I/O hook on
+        * @param via The port that the user connected on
         */
-       virtual void OnHookIO(StreamSocket*, ListenSocket* via);
+       virtual void OnHookIO(StreamSocket* user, ListenSocket* via);
 
        /** Called when a port accepts a connection
         * Return MOD_RES_ACCEPT if you have used the file descriptor.
         * @param fd The file descriptor returned from accept()
-        * @param from The local port the user connected to
+        * @param sock The socket connection for the new user
         * @param client The client IP address and port
         * @param server The server IP address and port
         */
-       virtual ModResult OnAcceptConnection(int fd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
+       virtual ModResult OnAcceptConnection(int fd, ListenSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
 
        /** Called immediately after any connection is accepted. This is intended for raw socket
         * processing (e.g. modules which wrap the tcp connection within another library) and provides
         * no information relating to a user record as the connection has not been assigned yet.
         * There are no return values from this call as all modules get an opportunity if required to
         * process the connection.
-        * @param fd The file descriptor returned from accept()
+        * @param sock The socket in question
         * @param client The client IP address and port
         * @param server The server IP address and port
-        * @param localport The local port number the user connected to
         */
-       virtual void OnStreamSocketAccept(StreamSocket*, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
+       virtual void OnStreamSocketAccept(StreamSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
 
        /**
         * Called when a hooked stream has data to write, or when the socket
         * engine returns it as writable
-        * @param socket The socket in question
+        * @param sock The socket in question
         * @param sendq Data to send to the socket
         * @return 1 if the sendq has been completely emptied, 0 if there is
         *  still data to send, and -1 if there was an error
         */
-       virtual int OnStreamSocketWrite(StreamSocket*, std::string& sendq);
+       virtual int OnStreamSocketWrite(StreamSocket* sock, std::string& sendq);
 
        /** Called immediately before any socket is closed. When this event is called, shutdown()
         * has not yet been called on the socket.
-        * @param fd The file descriptor of the socket prior to close()
+        * @param sock The socket in question
         */
-       virtual void OnStreamSocketClose(StreamSocket*);
+       virtual void OnStreamSocketClose(StreamSocket* sock);
 
        /** Called immediately upon connection of an outbound BufferedSocket which has been hooked
         * by a module.
-        * @param fd The file descriptor of the socket immediately after connect()
+        * @param sock The socket in question
         */
-       virtual void OnStreamSocketConnect(StreamSocket*);
+       virtual void OnStreamSocketConnect(StreamSocket* sock);
 
        /**
         * Called when the stream socket has data to read
-        * @param socket The socket that is ready
+        * @param sock The socket that is ready
         * @param recvq The receive queue that new data should be appended to
         * @return 1 if new data has been read, 0 if no new data is ready (but the
         *  socket is still connected), -1 if there was an error or close
         */
-       virtual int OnStreamSocketRead(StreamSocket*, std::string& recvq);
+       virtual int OnStreamSocketRead(StreamSocket* sock, std::string& recvq);
 
        /** Called whenever a user sets away or returns from being away.
         * The away message is available as a parameter, but should not be modified.
@@ -1289,11 +1288,6 @@ class CoreExport Module : public classbase, public usecountbase
         * @param line The raw line to send; modifiable, if empty no line will be returned.
         */
        virtual void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line);
-
-       /** Called whenever a User's ip changes.
-        * @param user The user whose ip changed.
-        */
-       virtual void OnSetClientIP(User *user);
 };
 
 
@@ -1564,13 +1558,14 @@ class CoreExport ModuleManager
         * automatically detatch your module from all events it is attached to.
         * @param i Event type to detach
         * @param mod Module to detach event from
-        * @param Detach true if the event was detached
+        * @return True if the event was detached
         */
        bool Detach(Implementation i, Module* mod);
 
        /** Attach an array of events to a module
         * @param i Event types (array) to attach
         * @param mod Module to attach events to
+        * @param sz The size of the implementation array
         */
        void Attach(Implementation* i, Module* mod, size_t sz);
 
index c880eee23f2cc03770c3d81325ac14f35b313c04..aabb5b022c7d444be244b08ffe40313f1a866c1e 100644 (file)
@@ -70,7 +70,8 @@ class ProtocolInterface
 
        /** Send mode changes for an object.
         * @param target The channel name or user to send mode changes for.
-        * @param The mode changes to send.
+        * @param modedata The mode changes to send.
+        * @param translate A list of translation types
         */
        virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &translate) { }
 
index 7fa58f8ad992bfe444fafe3bd9d618a7dabd2a16..16809c3f81988bd75da2dcae0819348d5fc56f4a 100644 (file)
@@ -105,6 +105,7 @@ namespace irc
                 * IPV6 addresses.
                 * @param address The human readable address, e.g. fred\@1.2.3.4
                 * @param cidr_mask The human readable mask, e.g. *\@1.2.0.0/16
+                * @param match_with_username Does the  mask include a nickname segment?
                 * @return True if the mask matches the address
                 */
                CoreExport bool MatchCIDR(const std::string &address, const std::string &cidr_mask, bool match_with_username);
index 7e089da6b8e44b77455c4290352758c51d01198c..b790f6d77596b389bab0862b1b35aa8754ae0797 100644 (file)
@@ -202,7 +202,9 @@ class CoreExport EventHandler : public classbase
         * class, and it will be called whenever read or write
         * events are received.
         * @param et either one of EVENT_READ for read events,
-        * and EVENT_WRITE for write events.
+        * EVENT_WRITE for write events and EVENT_ERROR for
+        * error events.
+        * @param errornum The error code which goes with an EVENT_ERROR.
         */
        virtual void HandleEvent(EventType et, int errornum = 0) = 0;
 
@@ -358,6 +360,8 @@ public:
        /** Abstraction for BSD sockets accept(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param addr The client IP address and port
+        * @param addrlen The size of the sockaddr parameter.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen);
@@ -379,6 +383,9 @@ public:
        /** Abstraction for BSD sockets send(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param buf The buffer in which the data that is sent is stored.
+        * @param len The size of the buffer.
+        * @param flags A flag value that controls the sending of the data.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int Send(EventHandler* fd, const void *buf, size_t len, int flags);
@@ -386,6 +393,9 @@ public:
        /** Abstraction for BSD sockets recv(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param buf The buffer in which the data that is read is stored.
+        * @param len The size of the buffer.
+        * @param flags A flag value that controls the reception of the data.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int Recv(EventHandler* fd, void *buf, size_t len, int flags);
@@ -393,6 +403,11 @@ public:
        /** Abstraction for BSD sockets recvfrom(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param buf The buffer in which the data that is read is stored.
+        * @param len The size of the buffer.
+        * @param flags A flag value that controls the reception of the data.
+        * @param from The remote IP address and port.
+        * @param fromlen The size of the from parameter.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen);
@@ -400,6 +415,11 @@ public:
        /** Abstraction for BSD sockets sendto(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param buf The buffer in which the data that is sent is stored.
+        * @param len The size of the buffer.
+        * @param flags A flag value that controls the sending of the data.
+        * @param to The remote IP address and port.    
+        * @param tolen The size of the to parameter.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int SendTo(EventHandler* fd, const void *buf, size_t len, int flags, const sockaddr *to, socklen_t tolen);
@@ -407,6 +427,8 @@ public:
        /** Abstraction for BSD sockets connect(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param serv_addr The server IP address and port.
+        * @param addrlen The size of the sockaddr parameter.
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen);
@@ -426,6 +448,7 @@ public:
        /** Abstraction for BSD sockets shutdown(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
+        * @param how What part of the socket to shut down
         * @return This method should return exactly the same values as the system call it emulates.
         */
        int Shutdown(EventHandler* fd, int how);
index 9ae5fb3cb335b29fab5d21843405065457de6f20..5168ed238cb53dbb5f4862af37efa151448bece9 100644 (file)
@@ -39,7 +39,6 @@ class CoreExport ThreadEngine
  public:
 
        /** Constructor.
-        * @param Instance Creator object
         */
        ThreadEngine();
 
index 0de6710ac865b43739d7a9dcf8e5fc4e846d23e8..9bb7128b85ac7f6283ec51a0e6986fc7464a6a1d 100644 (file)
@@ -137,11 +137,6 @@ class CoreExport TimerManager
 
        /** Add an Timer
         * @param T an Timer derived class to add
-        * @param secs_from_now You may set this to the number of seconds
-        * from the current time when the timer will tick, or you may just
-        * leave this unset and the values set by the Timers constructor
-        * will be used. This is used internally for re-triggering repeating
-        * timers.
         */
        void AddTimer(Timer *T);
 
index 615af6c9ce05182191e197e248f97e3d6e900263..7659628d22c900dffca052e384a76d42a5d3cbd4 100644 (file)
@@ -34,6 +34,8 @@ class DNSRequest;
 class Extensible;
 class FakeUser;
 class InspIRCd;
+class Invitation;
+class InviteBase;
 class LocalUser;
 class Membership;
 class Module;
@@ -72,7 +74,7 @@ typedef std::vector<std::pair<std::string, std::string> > FailedPortList;
 
 /** Holds a complete list of all channels to which a user has been invited and has not yet joined, and the time at which they'll expire.
  */
-typedef std::vector< std::pair<irc::string, time_t> > InvitedList;
+typedef std::vector<Invitation*> InviteList;
 
 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
  */
index b549edb1039d9769aaa811303f346db0fd320c9e..92b40b373ba6b595768f40180945e6c6b04bd6c5 100644 (file)
@@ -73,7 +73,6 @@ class CoreExport UserManager
        /** Add a client to the system.
         * This will create a new User, insert it into the user_hash,
         * initialize it as not yet registered, and add it to the socket engine.
-        * @param Instance a pointer to the server instance
         * @param socket The socket id (file descriptor) this user is on
         * @param via The socket that this user connected using
         * @param client The IP address and client port of the user
@@ -84,8 +83,8 @@ class CoreExport UserManager
 
        /** Disconnect a user gracefully
         * @param user The user to remove
-        * @param r The quit reason to show to normal users
-        * @param oreason The quit reason to show to opers
+        * @param quitreason The quit reason to show to normal users
+        * @param operreason The quit reason to show to opers
         * @return Although this function has no return type, on exit the user provided will no longer exist.
         */
        void QuitUser(User *user, const std::string &quitreason, const char* operreason = "");
index cdc0d80783265a085bcfeb6b5e04ef15c91d8be3..57dea3fa5557643603c72e7c03752191400bfa40 100644 (file)
@@ -29,6 +29,7 @@
 #include "inspsocket.h"
 #include "dns.h"
 #include "mode.h"
+#include "membership.h"
 
 /** connect class types
  */
@@ -394,11 +395,6 @@ class CoreExport User : public Extensible
         */
        bool SetClientIP(const char* sip);
 
-       /** Sets the client IP for this user
-        * @return true always
-        */
-       bool SetClientIP(irc::sockets::sockaddrs *sa);
-
        /** Constructor
         * @throw CoreException if the UID allocated to the user already exists
         */
@@ -412,14 +408,14 @@ class CoreExport User : public Extensible
 
        /** 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&at;host form.
+        * on the server, in nick!ident\@host form.
         * @return The full masked host of the user
         */
        virtual const std::string& GetFullHost();
 
        /** Returns the full real host of the user
         * This member function returns the hostname of the user as seen by other users
-        * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
+        * on the server, in nick!ident\@host form. If any form of hostname cloaking is in operation,
         * e.g. through a module, then this method will ignore it and return the true hostname.
         * @return The full real host of the user
         */
@@ -456,7 +452,7 @@ class CoreExport User : public Extensible
        void SetNoticeMask(unsigned char sm, bool value);
 
        /** Create a displayable mode string for this users umodes
-        * @param The mode string
+        * @param showparameters The mode string
         */
        const char* FormatModes(bool showparameters = false);
 
@@ -500,20 +496,20 @@ class CoreExport User : public Extensible
        virtual bool HasModePermission(unsigned char mode, ModeType type);
 
        /** Creates a wildcard host.
-        * Takes a buffer to use and fills the given buffer with the host in the format *!*@hostname
-        * @return The wildcarded hostname in *!*@host form
+        * Takes a buffer to use and fills the given buffer with the host in the format *!*\@hostname
+        * @return The wildcarded hostname in *!*\@host form
         */
        char* MakeWildHost();
 
        /** Creates a usermask with real host.
-        * Takes a buffer to use and fills the given buffer with the hostmask in the format user@host
-        * @return the usermask in the format user@host
+        * Takes a buffer to use and fills the given buffer with the hostmask in the format user\@host
+        * @return the usermask in the format user\@host
         */
        const std::string& MakeHost();
 
        /** Creates a usermask with real ip.
-        * Takes a buffer to use and fills the given buffer with the ipmask in the format user@ip
-        * @return the usermask in the format user@ip
+        * Takes a buffer to use and fills the given buffer with the ipmask in the format user\@ip
+        * @return the usermask in the format user\@ip
         */
        const std::string& MakeHostIP();
 
@@ -569,34 +565,35 @@ class CoreExport User : public Extensible
 
        void WriteNumeric(unsigned int numeric, const std::string &text);
 
-       /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
-        * @param user The user to prepend the :nick!user@host of
+       /** Write text to this user, appending CR/LF and prepending :nick!user\@host of the user provided in the first parameter.
+        * @param user The user to prepend the :nick!user\@host of
         * @param text A std::string to send to the user
         */
        void WriteFrom(User *user, const std::string &text);
 
-       /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
-        * @param user The user to prepend the :nick!user@host of
+       /** Write text to this user, appending CR/LF and prepending :nick!user\@host of the user provided in the first parameter.
+        * @param user The user to prepend the :nick!user\@host of
         * @param text The format string for text to send to the user
         * @param ... POD-type format arguments
         */
        void WriteFrom(User *user, const char* text, ...) CUSTOM_PRINTF(3, 4);
 
-       /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
+       /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user\@host.
         * @param dest The user to route the message to
-        * @param text A std::string to send to the user
+        * @param data A std::string to send to the user
         */
        void WriteTo(User *dest, const std::string &data);
 
-       /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
+       /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user\@host.
         * @param dest The user to route the message to
-        * @param text The format string for text to send to the user
+        * @param data The format string for text to send to the user
         * @param ... POD-type format arguments
         */
        void WriteTo(User *dest, const char *data, ...) CUSTOM_PRINTF(3, 4);
 
-       /** Write to all users that can see this user (including this user in the list), appending CR/LF
-        * @param text A std::string to send to the users
+       /** Write to all users that can see this user (including this user in the list if include_self is true), appending CR/LF
+        * @param line A std::string to send to the users
+        * @param include_self Should the message be sent back to the author?
         */
        void WriteCommonRaw(const std::string &line, bool include_self = true);
 
@@ -643,7 +640,7 @@ class CoreExport User : public Extensible
         * Run this after the item in question has changed.
         * You should not need to use this function, call ChangeDisplayedHost instead
         *
-        * @param The entire QUIT line, including the source using the old value
+        * @param quitline The entire QUIT line, including the source using the old value
         */
        void DoHostCycle(const std::string &quitline);
 
@@ -661,7 +658,7 @@ class CoreExport User : public Extensible
         * ALWAYS use this function, rather than writing User::ident directly,
         * as this correctly causes the user to seem to quit (where configured)
         * before setting their ident field.
-        * @param host The new ident to set
+        * @param newident The new ident to set
         * @return True if the change succeeded, false if it didn't
         */
        bool ChangeIdent(const char* newident);
@@ -740,14 +737,8 @@ class CoreExport UserIOHandler : public StreamSocket
 
 typedef unsigned int already_sent_t;
 
-class CoreExport LocalUser : public User
+class CoreExport LocalUser : public User, public InviteBase
 {
-       /** A list of channels the user has a pending invite to.
-        * Upon INVITE channels are added, and upon JOIN, the
-        * channels are removed from this list.
-        */
-       InvitedList invites;
-
  public:
        LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
        CullResult cull();
@@ -771,7 +762,7 @@ class CoreExport LocalUser : public User
        int cmds_out;
 
        /** Password specified by the user when they registered (if any).
-        * This is stored even if the <connect> block doesnt need a password, so that
+        * This is stored even if the \<connect> block doesnt need a password, so that
         * modules may check it.
         */
        std::string password;
@@ -782,7 +773,7 @@ class CoreExport LocalUser : public User
 
        ConnectClass* GetClass();
 
-       /** Call this method to find the matching <connect> for a user, and to check them against it.
+       /** Call this method to find the matching \<connect> for a user, and to check them against it.
         */
        void CheckClass();
 
@@ -823,7 +814,7 @@ class CoreExport LocalUser : public User
        void FullConnect();
 
        /** Set the connect class to which this user belongs to.
-        * @param explicit_name Set this string to tie the user to a specific class name. Otherwise, the class is fitted by checking <connect> tags from the configuration file.
+        * @param explicit_name Set this string to tie the user to a specific class name. Otherwise, the class is fitted by checking \<connect> tags from the configuration file.
         * @return A reference to this user's current connect class.
         */
        void SetClass(const std::string &explicit_name = "");
@@ -835,7 +826,7 @@ class CoreExport LocalUser : public User
        /** Returns the list of channels this user has been invited to but has not yet joined.
         * @return A list of channels the user is invited to
         */
-       InvitedList* GetInviteList();
+       InviteList& GetInviteList();
 
        /** Returns true if a user is invited to a channel.
         * @param channel A channel name to look up
@@ -856,6 +847,8 @@ class CoreExport LocalUser : public User
         */
        void RemoveInvite(const irc::string &channel);
 
+       void RemoveExpiredInvites();
+
        /** Returns true or false for if a user can execute a privilaged oper command.
         * This is done by looking up their oper type from User::oper, then referencing
         * this to their oper classes and checking the commands they can execute.
@@ -940,7 +933,6 @@ class CoreExport UserResolver : public Resolver
        bool fwd;
  public:
        /** Create a resolver.
-        * @param Instance The creating instance
         * @param user The user to begin lookup on
         * @param to_resolve The IP or host to resolve
         * @param qt The query type
index bde3d3fda7e4b93b39e2df5c4eea5ac372091885..2a49d8b80efe1c49230137a847a4838a049485be 100644 (file)
@@ -104,10 +104,10 @@ class CoreExport XLine : public classbase
        virtual void DisplayExpiry() = 0;
 
        /** Returns the displayable form of the pattern for this xline,
-        * e.g. '*@foo' or '*baz*'. This must always return the full pattern
+        * e.g. '*\@foo' or '*baz*'. This must always return the full pattern
         * in a form which can be used to construct an entire derived xline,
         * even if it is stored differently internally (e.g. GLine stores the
-        * ident and host parts seperately but will still return ident@host
+        * ident and host parts seperately but will still return ident\@host
         * for its Displayable() method)
         */
        virtual const char* Displayable() = 0;
@@ -376,7 +376,6 @@ class CoreExport XLineFactory
  public:
 
        /** Create an XLine factory
-        * @param Instance creator
         * @param t Type of XLine this factory generates
         */
        XLineFactory(const std::string &t) : type(t) { }
@@ -428,7 +427,6 @@ class CoreExport XLineManager
  public:
 
        /** Constructor
-        * @param Instance A pointer to the creator object
         */
        XLineManager();
 
@@ -448,7 +446,7 @@ class CoreExport XLineManager
        /** Get all lines of a certain type to an XLineLookup (std::map<std::string, XLine*>).
         * NOTE: When this function runs any expired items are removed from the list before it
         * is returned to the caller.
-        * @param The type to look up
+        * @param type The type to look up
         * @return A list of all XLines of the given type.
         */
        XLineLookup* GetAll(const std::string &type);
@@ -531,6 +529,7 @@ class CoreExport XLineManager
        /** Handle /STATS for a given type.
         * NOTE: Any items in the list for this particular line type which have expired
         * will be expired and removed before the list is displayed.
+        * @param type The type of stats to show
         * @param numeric The numeric to give to each result line
         * @param user The username making the query
         * @param results The string_list to receive the results
index 1621c2c274566e5ca78715fd907dbc21be3665f7..ab8aae4279d1a4d45f251736bff6d5de34510800 100644 (file)
@@ -36,7 +36,7 @@ sub make_gnutls_cert()
        my $timestr = time();
        my $org = promptstring_s("Please enter the organization name", "My IRC Network");
        my $unit = promptstring_s("Please enter the unit Name", "Server Admins");
-       my $state = promptstring_s("Pleae enter your state (two letter code)", "CA");
+       my $state = promptstring_s("Please enter your state (two letter code)", "CA");
        my $country = promptstring_s("Please enter your country", "Oompa Loompa Land");
        my $commonname = promptstring_s("Please enter the certificate common name (hostname)", "irc.mynetwork.com");
        my $email = promptstring_s("Please enter a contact email address", "oompa\@loompa.com");
diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp
deleted file mode 100644 (file)
index c9aff2b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- *
- * 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/>.
- */
-
-
-/* $Core */
-
-#include "inspircd.h"
-
index 4a927cedb86afe8a6b5d728d363093493f6d5b2b..c265171b5ce85c6ced4e78d30a440a3ed4f8eb28 100644 (file)
@@ -172,6 +172,8 @@ void Channel::DelUser(User* user)
                        FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
                        ServerInstance->chanlist->erase(iter);
                }
+
+               ClearInvites();
                ServerInstance->GlobalCulls.AddItem(this);
        }
 }
@@ -969,3 +971,89 @@ void Channel::RemoveAllPrefixes(User* user)
                m->second->modes.clear();
        }
 }
+
+void Invitation::Create(Channel* c, LocalUser* u, time_t timeout)
+{
+       if ((timeout != 0) && (ServerInstance->Time() >= timeout))
+               // Expired, don't bother
+               return;
+
+       ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Create chan=%s user=%s", c->name.c_str(), u->uuid.c_str());
+
+       Invitation* inv = Invitation::Find(c, u, false);
+       if (inv)
+       {
+                if ((inv->expiry == 0) || (inv->expiry > timeout))
+                       return;
+               inv->expiry = timeout;
+               ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Create changed expiry in existing invitation %p", (void*) inv);
+       }
+       else
+       {
+               inv = new Invitation(c, u, timeout);
+               c->invites.push_back(inv);
+               u->invites.push_back(inv);
+               ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Create created new invitation %p", (void*) inv);
+       }
+}
+
+Invitation* Invitation::Find(Channel* c, LocalUser* u, bool check_expired)
+{
+       ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Find chan=%s user=%s check_expired=%d", c ? c->name.c_str() : "NULL", u ? u->uuid.c_str() : "NULL", check_expired);
+       if (!u || u->invites.empty())
+               return NULL;
+
+       InviteList locallist;
+       locallist.swap(u->invites);
+
+       Invitation* result = NULL;
+       for (InviteList::iterator i = locallist.begin(); i != locallist.end(); )
+       {
+               Invitation* inv = *i;
+               if ((check_expired) && (inv->expiry != 0) && (inv->expiry <= ServerInstance->Time()))
+               {
+                       /* Expired invite, remove it. */
+                       ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Find ecountered expired entry: %p expired %s", (void*) inv, ServerInstance->TimeString(inv->expiry).c_str());
+                       i = locallist.erase(i);
+                       inv->cull();
+                       delete inv;
+               }
+               else
+               {
+                       /* Is it what we're searching for? */
+                       if (inv->chan == c)
+                       {
+                               result = inv;
+                               break;
+                       }
+                       ++i;
+               }
+       }
+
+       locallist.swap(u->invites);
+       ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Find result=%p", (void*) result);
+       return result;
+}
+
+Invitation::~Invitation()
+{
+       // Remove this entry from both lists
+       InviteList::iterator it = std::find(chan->invites.begin(), chan->invites.end(), this);
+       if (it != chan->invites.end())
+               chan->invites.erase(it);
+       it = std::find(user->invites.begin(), user->invites.end(), this);
+       if (it != user->invites.end())
+               user->invites.erase(it);
+}
+
+void InviteBase::ClearInvites()
+{
+       ServerInstance->Logs->Log("INVITEBASE", DEBUG, "InviteBase::ClearInvites %p", (void*) this);
+       InviteList locallist;
+       locallist.swap(invites);
+       for (InviteList::const_iterator i = locallist.begin(); i != locallist.end(); ++i)
+       {
+               (*i)->cull();
+               delete *i;
+       }
+}
index cd47e49efedb71cb6499a55d7b22b1097cd1a92b..fa3f7fae942ae9dd12c38f4f08d014a8ace79024 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_AWAY_H
-#define CMD_AWAY_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /AWAY. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,9 +40,6 @@ class CommandAway : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /AWAY
  */
 CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User *user)
index b47017c07bafc2d6754497e56b727183f72566ab..5914f9a8f0ef4a21a9300ed19c9c4693fd252e29 100644 (file)
 
 #include "inspircd.h"
 
-#include "users.h"
-#include "channels.h"
-#include "ctables.h"
-
 /** Handle /CLEARCACHE. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
index 2d4d42a1f4c26611f34fd986fa9c8c598bf86e16..36408b3638ec3e3aa0eca58d3f526ca3ff157365 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_COMMANDS_H
-#define CMD_COMMANDS_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /COMMANDS. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,9 +40,6 @@ class CommandCommands : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /COMMANDS
  */
 CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
@@ -59,6 +48,10 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
        list.reserve(ServerInstance->Parser->cmdlist.size());
        for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++)
        {
+               // Don't show S2S commands to users
+               if (i->second->flags_needed == FLAG_SERVERONLY)
+                       continue;
+
                Module* src = i->second->creator;
                char buffer[MAXBUF];
                snprintf(buffer, MAXBUF, ":%s %03d %s :%s %s %d %d",
index 0523d052f35221d808e5c71c4a67590861de95b4..15487bd8e984d73356c77a19df183db20cd4c5b1 100644 (file)
 #include "inspircd.h"
 #include "xline.h"
 
-#ifndef CMD_ELINE_H
-#define CMD_ELINE_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /ELINE. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -49,9 +41,6 @@ class CommandEline : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /ELINE
  */
 CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User *user)
index 3baa9cb038c8e7b77a16d507ad628a776ae3e0a9..200cce4a3e7ffc511168e89778e91386c64a0551 100644 (file)
@@ -132,10 +132,10 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
        {
                // pinched from ircu - invite with not enough parameters shows channels
                // youve been invited to but haven't joined yet.
-               InvitedList* il = IS_LOCAL(user)->GetInviteList();
-               for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
+               InviteList& il = IS_LOCAL(user)->GetInviteList();
+               for (InviteList::const_iterator i = il.begin(); i != il.end(); ++i)
                {
-                       user->WriteNumeric(RPL_INVITELIST, "%s :%s",user->nick.c_str(),i->first.c_str());
+                       user->WriteNumeric(RPL_INVITELIST, "%s :%s",user->nick.c_str(), (*i)->chan->name.c_str());
                }
                user->WriteNumeric(RPL_ENDOFINVITELIST, "%s :End of INVITE list",user->nick.c_str());
        }
index 978c1ad5b665ef27a38f53aaf80dad43a30cc393..1a50239eeb2ff98d2536a57ef27f1feea0abc607 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_ISON_H
-#define CMD_ISON_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /ISON. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -38,7 +30,9 @@ class CommandIson : public Command
  public:
        /** Constructor for ison.
         */
-       CommandIson ( Module* parent) : Command(parent,"ISON",0,0) { syntax = "<nick> {nick}"; }
+       CommandIson ( Module* parent) : Command(parent,"ISON", 1) {
+               syntax = "<nick> {nick}";
+       }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -48,9 +42,6 @@ class CommandIson : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /ISON
  */
 CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User *user)
index 1dc1d7f9214b47f0562322f7601f29c52c3b5058..6124fcc1c7746b5975cdf049cb0d478d5448255c 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_JOIN_H
-#define CMD_JOIN_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /JOIN. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,9 +40,6 @@ class CommandJoin : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /JOIN
  */
 CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User *user)
index f4001d7dbc3aae2675cf0cb32be1c4450130af4c..3c5fb00527ae8e94d73e72b6f16cb8a35e4c2c1a 100644 (file)
@@ -40,7 +40,6 @@ class CommandKick : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-
 /** Handle /KICK
  */
 CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user)
index 80b8d7f560566970f1f94f7a9e40ed265a9e9215..f4152ebc5539e0772329679699d0e0b717cbe419 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_LINKS_H
-#define CMD_LINKS_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /LINKS. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,9 +40,6 @@ class CommandLinks : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /LINKS
  */
 CmdResult CommandLinks::Handle (const std::vector<std::string>&, User *user)
index 74bd74dd37531787092784dacd2224b5c8e88728..9d60613a2a95aa5a8da40401187aa28c86283c9f 100644 (file)
@@ -40,7 +40,6 @@ class CommandLoadmodule : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-
 /** Handle /LOADMODULE
  */
 CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters, User *user)
index a3892dbcefb5c5bdbdee8b9757f49a130ebc690b..e9e36b3d1576583e2dc4c3972817a297f0f82755 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_LUSERS_H
-#define CMD_LUSERS_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /LUSERS. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -51,9 +43,6 @@ class CommandLusers : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /LUSERS
  */
 CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
index 9a236137d7db0d098f1fc1857130ab969f0fa23c..8e227723ee57f0bcca916fd1f66e85a4a6dcb241 100644 (file)
@@ -30,7 +30,7 @@ class CommandMotd : public Command
  public:
        /** Constructor for motd.
         */
-       CommandMotd ( Module* parent) : Command(parent,"MOTD",0,1) { ServerInstance->ProcessedMotdEscapes = false; syntax = "[<servername>]"; }
+       CommandMotd ( Module* parent) : Command(parent,"MOTD",0,1) { syntax = "[<servername>]"; }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -46,61 +46,6 @@ class CommandMotd : public Command
        }
 };
 
-/*
- * Replace all color codes from the special[] array to actual
- * color code chars using C++ style escape sequences. You
- * can append other chars to replace if you like (such as %U
- * being underline). -- Justasic
- */
-void ProcessColors(ConfigFileCache::iterator &file)
-{
-  static struct special_chars
-  {
-    std::string character;
-    std::string replace;
-    special_chars(const std::string &c, const std::string &r) : character(c), replace(r) { }
-  }
-  
-  special[] = {
-    special_chars("\\002", "\002"),  // Bold
-    special_chars("\\037", "\037"),  // underline
-    special_chars("\\003", "\003"),  // Color
-    special_chars("\\0017", "\017"), // Stop colors
-    special_chars("\\u", "\037"),    // Alias for underline
-    special_chars("\\b", "\002"),    // Alias for Bold
-    special_chars("\\x", "\017"),    // Alias for stop
-    special_chars("\\c", "\003"),    // Alias for color
-    special_chars("", "")
-  };
-  
-  for(file_cache::iterator it = file->second.begin(); it != file->second.end(); it++)
-  {
-    std::string ret = *it;
-    for(int i = 0; special[i].character.empty() == false; ++i)
-    {
-      std::string::size_type pos = ret.find(special[i].character);
-      if(pos != std::string::npos && ret[pos-1] == '\\' && ret[pos] == '\\')
-       continue; // Skip double slashes.
-       
-       // Replace all our characters in the array
-       while(pos != std::string::npos)
-       {
-         ret = ret.substr(0, pos) + special[i].replace + ret.substr(pos + special[i].character.size());
-         pos = ret.find(special[i].character, pos + special[i].replace.size());
-       }
-    }
-    
-    // Replace double slashes with a single slash before we return
-    std::string::size_type pos = ret.find("\\\\");
-    while(pos != std::string::npos)
-    {
-      ret = ret.substr(0, pos) + "\\" + ret.substr(pos + 2);
-      pos = ret.find("\\\\", pos + 1);
-    }
-    *it = ret;
-  }
-}
-
 /** Handle /MOTD
  */
 CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user)
@@ -120,12 +65,6 @@ CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User
                return CMD_SUCCESS;
        }
 
-       if(!ServerInstance->ProcessedMotdEscapes)
-       {
-               ProcessColors(motd);
-               ServerInstance->ProcessedMotdEscapes = true;
-       }
-
        user->SendText(":%s %03d %s :%s message of the day", ServerInstance->Config->ServerName.c_str(),
                RPL_MOTDSTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
 
index f34afb361dfd5da334b451dc456da993022e75cd..0c06b636ffb90059463082c421d217e1974bc53d 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_NAMES_H
-#define CMD_NAMES_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /NAMES. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,9 +40,6 @@ class CommandNames : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 /** Handle /NAMES
  */
 CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User *user)
index 5e600ad1ce676581c41c6f906772488b8ad90b88..a079e59d057880fcfd8e94d33d53a506e508ad47 100644 (file)
@@ -21,7 +21,6 @@
 
 
 #include "inspircd.h"
-#include "xline.h"
 
 /** Handle /NICK. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
index 2fd7744ee969f6792a3372b1ae981e11e043647c..e3f79d3474db3524f55056710bc769d4d1e83356 100644 (file)
@@ -20,7 +20,6 @@
 
 
 #include "inspircd.h"
-#include "hashcomp.h"
 
 bool OneOfMatches(const char* host, const char* ip, const char* hostlist);
 
index ff326faf2d666d952284eb48a115b294284f61d1..1fa6e5731b8c730c07c7ac372c6ef83dee3d14c6 100644 (file)
@@ -20,7 +20,7 @@
 
 
 #include "inspircd.h"
-#include "xline.h"
+
 /** Handle /REHASH. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -88,8 +88,6 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
                /* Don't do anything with the logs here -- logs are restarted
                 * after the config thread has completed.
                 */
-
-               ServerInstance->ProcessedMotdEscapes = false; // Reprocess our motd file --Justasic
                ServerInstance->RehashUsersAndChans();
                FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
 
index 2ed5eedcdfe5e3eacdfc2ae779815e8538c8717f..6b21d0db6c8569c8f10396b66510ec80a208977b 100644 (file)
 
 
 #include "inspircd.h"
-#ifndef WIN32
-       #include <sys/resource.h>
-       /* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */
-       #ifndef RUSAGE_SELF
-       #define RUSAGE_SELF 0
-       #endif
-#else
-       #include <psapi.h>
-       #include "inspircd_win32wrapper.h"
-       #pragma comment(lib, "psapi.lib")
-#endif
-
 #include "xline.h"
+#include "commands/cmd_whowas.h"
 
 /** Handle /STATS. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
@@ -41,6 +30,7 @@
  */
 class CommandStats : public Command
 {
+       void DoStats(char statschar, User* user, string_list &results);
  public:
        /** Constructor for stats.
         */
@@ -60,13 +50,349 @@ class CommandStats : public Command
        }
 };
 
+void CommandStats::DoStats(char statschar, User* user, string_list &results)
+{
+       std::string sn(ServerInstance->Config->ServerName);
+
+       bool isPublic = ServerInstance->Config->UserStats.find(statschar) != std::string::npos;
+       bool isRemoteOper = IS_REMOTE(user) && IS_OPER(user);
+       bool isLocalOperWithPrivs = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex");
+
+       if (!isPublic && !isRemoteOper && !isLocalOperWithPrivs)
+       {
+               ServerInstance->SNO->WriteToSnoMask('t',
+                               "%s '%c' denied for %s (%s@%s)",
+                               (IS_LOCAL(user) ? "Stats" : "Remote stats"),
+                               statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+               results.push_back(sn + " 481 " + user->nick + " :Permission denied - STATS " + statschar + " requires the servers/auspex priv.");
+               return;
+       }
+
+       ModResult MOD_RESULT;
+       FIRST_MOD_RESULT(OnStats, MOD_RESULT, (statschar, user, results));
+       if (MOD_RESULT == MOD_RES_DENY)
+       {
+               results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
+               ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
+                       (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+               return;
+       }
+
+       switch (statschar)
+       {
+               /* stats p (show listening ports) */
+               case 'p':
+               {
+                       for (std::vector<ListenSocket*>::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i)
+                       {
+                               ListenSocket* ls = *i;
+                               std::string ip = ls->bind_addr;
+                               if (ip.empty())
+                                       ip.assign("*");
+                               std::string type = ls->bind_tag->getString("type", "clients");
+                               std::string hook = ls->bind_tag->getString("ssl", "plaintext");
+
+                               results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ls->bind_port)+
+                                       " (" + type + ", " + hook + ")");
+                       }
+               }
+               break;
+
+               /* These stats symbols must be handled by a linking module */
+               case 'n':
+               case 'c':
+               break;
+
+               case 'i':
+               {
+                       for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+                       {
+                               ConnectClass* c = *i;
+                               std::stringstream res;
+                               res << sn << " 215 " << user->nick << " I " << c->name << ' ';
+                               if (c->type == CC_ALLOW)
+                                       res << '+';
+                               if (c->type == CC_DENY)
+                                       res << '-';
+
+                               if (c->type == CC_NAMED)
+                                       res << '*';
+                               else
+                                       res << c->host;
+
+                               res << ' ' << c->config->getString("port", "*") << ' ';
+
+                               res << c->GetRecvqMax() << ' ' << c->GetSendqSoftMax() << ' ' << c->GetSendqHardMax()
+                                       << ' ' << c->GetCommandRate() << ' ' << c->GetPenaltyThreshold();
+                               if (c->fakelag)
+                                       res << '*';
+                               results.push_back(res.str());
+                       }
+               }
+               break;
+
+               case 'Y':
+               {
+                       int idx = 0;
+                       for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+                       {
+                               ConnectClass* c = *i;
+                               results.push_back(sn+" 215 "+user->nick+" i NOMATCH * "+c->GetHost()+" "+ConvToStr(c->limit ? c->limit : ServerInstance->SE->GetMaxFds())+" "+ConvToStr(idx)+" "+ServerInstance->Config->ServerName+" *");
+                               results.push_back(sn+" 218 "+user->nick+" Y "+ConvToStr(idx)+" "+ConvToStr(c->GetPingTime())+" 0 "+ConvToStr(c->GetSendqHardMax())+" :"+
+                                               ConvToStr(c->GetRecvqMax())+" "+ConvToStr(c->GetRegTimeout()));
+                               idx++;
+                       }
+               }
+               break;
+
+               case 'U':
+               {
+                       for(std::map<irc::string, bool>::iterator i = ServerInstance->Config->ulines.begin(); i != ServerInstance->Config->ulines.end(); ++i)
+                       {
+                               results.push_back(sn+" 248 "+user->nick+" U "+std::string(i->first.c_str()));
+                       }
+               }
+               break;
+
+               case 'P':
+               {
+                       int idx = 0;
+                       for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++)
+                       {
+                               if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->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"));
+                                       idx++;
+                               }
+                       }
+                       results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(idx)+" OPER(s)");
+               }
+               break;
+
+               case 'k':
+                       ServerInstance->XLines->InvokeStats("K",216,user,results);
+               break;
+               case 'g':
+                       ServerInstance->XLines->InvokeStats("G",223,user,results);
+               break;
+               case 'q':
+                       ServerInstance->XLines->InvokeStats("Q",217,user,results);
+               break;
+               case 'Z':
+                       ServerInstance->XLines->InvokeStats("Z",223,user,results);
+               break;
+               case 'e':
+                       ServerInstance->XLines->InvokeStats("E",223,user,results);
+               break;
+               case 'E':
+                       results.push_back(sn+" 249 "+user->nick+" :Total events: "+ConvToStr(ServerInstance->SE->TotalEvents));
+                       results.push_back(sn+" 249 "+user->nick+" :Read events:  "+ConvToStr(ServerInstance->SE->ReadEvents));
+                       results.push_back(sn+" 249 "+user->nick+" :Write events: "+ConvToStr(ServerInstance->SE->WriteEvents));
+                       results.push_back(sn+" 249 "+user->nick+" :Error events: "+ConvToStr(ServerInstance->SE->ErrorEvents));
+               break;
+
+               /* stats m (list number of times each command has been used, plus bytecount) */
+               case 'm':
+                       for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++)
+                       {
+                               if (i->second->use_count)
+                               {
+                                       /* RPL_STATSCOMMANDS */
+                                       results.push_back(sn+" 212 "+user->nick+" "+i->second->name+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes));
+                               }
+                       }
+               break;
+
+               /* stats z (debug and memory info) */
+               case 'z':
+               {
+                       results.push_back(sn+" 249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->clientlist->size()));
+                       results.push_back(sn+" 249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->chanlist->size()));
+                       results.push_back(sn+" 249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->cmdlist.size()));
+
+                       if (!ServerInstance->Config->WhoWasGroupSize == 0 && !ServerInstance->Config->WhoWasMaxGroups == 0)
+                       {
+                               Module* whowas = ServerInstance->Modules->Find("cmd_whowas.so");
+                               if (whowas)
+                               {
+                                       WhowasRequest req(NULL, whowas, WhowasRequest::WHOWAS_STATS);
+                                       req.user = user;
+                                       req.Send();
+                                       results.push_back(sn+" 249 "+user->nick+" :"+req.value);
+                               }
+                       }
+
+                       float kbitpersec_in, kbitpersec_out, kbitpersec_total;
+                       char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30];
+
+                       ServerInstance->SE->GetStats(kbitpersec_in, kbitpersec_out, kbitpersec_total);
+
+                       snprintf(kbitpersec_total_s, 30, "%03.5f", kbitpersec_total);
+                       snprintf(kbitpersec_out_s, 30, "%03.5f", kbitpersec_out);
+                       snprintf(kbitpersec_in_s, 30, "%03.5f", kbitpersec_in);
+
+                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth total:  "+ConvToStr(kbitpersec_total_s)+" kilobits/sec");
+                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth out:    "+ConvToStr(kbitpersec_out_s)+" kilobits/sec");
+                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth in:     "+ConvToStr(kbitpersec_in_s)+" kilobits/sec");
+
+#ifndef WIN32
+                       /* Moved this down here so all the not-windows stuff (look w00tie, I didn't say win32!) is in one ifndef.
+                        * Also cuts out some identical code in both branches of the ifndef. -- Om
+                        */
+                       rusage R;
+
+                       /* Not sure why we were doing '0' with a RUSAGE_SELF comment rather than just using RUSAGE_SELF -- Om */
+                       if (!getrusage(RUSAGE_SELF,&R)) /* RUSAGE_SELF */
+                       {
+                               results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
+                               results.push_back(sn+" 249 "+user->nick+" :Signals:          "+ConvToStr(R.ru_nsignals));
+                               results.push_back(sn+" 249 "+user->nick+" :Page faults:      "+ConvToStr(R.ru_majflt));
+                               results.push_back(sn+" 249 "+user->nick+" :Swaps:            "+ConvToStr(R.ru_nswap));
+                               results.push_back(sn+" 249 "+user->nick+" :Context Switches: Voluntary; "+ConvToStr(R.ru_nvcsw)+" Involuntary; "+ConvToStr(R.ru_nivcsw));
+
+                               char percent[30];
+
+                               float n_elapsed = (ServerInstance->Time() - ServerInstance->stats->LastSampled.tv_sec) * 1000000
+                                       + (ServerInstance->Time_ns() - ServerInstance->stats->LastSampled.tv_nsec) / 1000;
+                               float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats->LastCPU.tv_usec);
+                               float per = (n_eaten / n_elapsed) * 100;
+
+                               snprintf(percent, 30, "%03.5f%%", per);
+                               results.push_back(sn+" 249 "+user->nick+" :CPU Use (now):    "+percent);
+
+                               n_elapsed = ServerInstance->Time() - ServerInstance->startup_time;
+                               n_eaten = (float)R.ru_utime.tv_sec + R.ru_utime.tv_usec / 100000.0;
+                               per = (n_eaten / n_elapsed) * 100;
+                               snprintf(percent, 30, "%03.5f%%", per);
+                               results.push_back(sn+" 249 "+user->nick+" :CPU Use (total):  "+percent);
+                       }
+#else
+                       PROCESS_MEMORY_COUNTERS MemCounters;
+                       if (GetProcessMemoryInfo(GetCurrentProcess(), &MemCounters, sizeof(MemCounters)))
+                       {
+                               results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr((MemCounters.WorkingSetSize + MemCounters.PagefileUsage) / 1024)+"K");
+                               results.push_back(sn+" 249 "+user->nick+" :Pagefile usage:   "+ConvToStr(MemCounters.PagefileUsage / 1024)+"K");
+                               results.push_back(sn+" 249 "+user->nick+" :Page faults:      "+ConvToStr(MemCounters.PageFaultCount));
+                               results.push_back(sn+" 249 "+user->nick+" :CPU Usage: " + ConvToStr(getcpu()) + "%");
+                       }
+#endif
+               }
+               break;
+
+               case 'T':
+               {
+                       char buffer[MAXBUF];
+                       results.push_back(sn+" 249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused));
+                       results.push_back(sn+" 249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown));
+                       results.push_back(sn+" 249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions));
+                       results.push_back(sn+" 249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDnsGood+ServerInstance->stats->statsDnsBad)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad));
+                       results.push_back(sn+" 249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats->statsConnects));
+                       snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",
+                               user->nick.c_str(),ServerInstance->stats->statsSent / 1024.0,ServerInstance->stats->statsRecv / 1024.0);
+                       results.push_back(sn+buffer);
+               }
+               break;
+
+               /* stats o */
+               case 'o':
+               {
+                       ConfigTagList tags = ServerInstance->Config->ConfTags("oper");
+                       for(ConfigIter i = tags.first; i != tags.second; ++i)
+                       {
+                               ConfigTag* tag = i->second;
+                               results.push_back(sn+" 243 "+user->nick+" O "+tag->getString("host")+" * "+
+                                       tag->getString("name") + " " + tag->getString("type")+" 0");
+                       }
+               }
+               break;
+               case 'O':
+               {
+                       for(OperIndex::iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); i++)
+                       {
+                               // just the types, not the actual oper blocks...
+                               if (i->first[0] != ' ')
+                                       continue;
+                               OperInfo* tag = i->second;
+                               tag->init();
+                               std::string umodes;
+                               std::string cmodes;
+                               for(char c='A'; c < 'z'; c++)
+                               {
+                                       ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
+                                       if (mh && mh->NeedsOper() && tag->AllowedUserModes[c - 'A'])
+                                               umodes.push_back(c);
+                                       mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
+                                       if (mh && mh->NeedsOper() && tag->AllowedChanModes[c - 'A'])
+                                               cmodes.push_back(c);
+                               }
+                               results.push_back(sn+" 243 "+user->nick+" O "+tag->NameStr() + " " + umodes + " " + cmodes);
+                       }
+               }
+               break;
+
+               /* stats l (show user I/O stats) */
+               case 'l':
+                       results.push_back(sn+" 211 "+user->nick+" :nick[ident@host] sendq cmds_out bytes_out cmds_in bytes_in time_open");
+                       for (std::vector<LocalUser*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
+                       {
+                               LocalUser* i = *n;
+                               results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
+                       }
+               break;
+
+               /* stats L (show user I/O stats with IP addresses) */
+               case 'L':
+                       results.push_back(sn+" 211 "+user->nick+" :nick[ident@ip] sendq cmds_out bytes_out cmds_in bytes_in time_open");
+                       for (std::vector<LocalUser*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
+                       {
+                               LocalUser* i = *n;
+                               results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
+                       }
+               break;
+
+               /* stats u (show server uptime) */
+               case 'u':
+               {
+                       time_t current_time = 0;
+                       current_time = ServerInstance->Time();
+                       time_t server_uptime = current_time - ServerInstance->startup_time;
+                       struct tm* stime;
+                       stime = gmtime(&server_uptime);
+                       /* i dont know who the hell would have an ircd running for over a year nonstop, but
+                        * Craig suggested this, and it seemed a good idea so in it went */
+                       if (stime->tm_year > 70)
+                       {
+                               char buffer[MAXBUF];
+                               snprintf(buffer,MAXBUF," 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick.c_str(),(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+                               results.push_back(sn+buffer);
+                       }
+                       else
+                       {
+                               char buffer[MAXBUF];
+                               snprintf(buffer,MAXBUF," 242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick.c_str(),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+                               results.push_back(sn+buffer);
+                       }
+               }
+               break;
+
+               default:
+               break;
+       }
+
+       results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
+       ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
+               (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+       return;
+}
+
 CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
 {
        if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
                return CMD_SUCCESS;
        string_list values;
        char search = parameters[0][0];
-       ServerInstance->DoStats(search, user, values);
+       DoStats(search, user, values);
        for (size_t i = 0; i < values.size(); i++)
                user->SendText(":%s", values[i].c_str());
 
index c19ad5b6f4be657b955b56d2d529cbd013cd6bf8..af7d3ceca65ba34903dc6aef65a5ee98a7cc07a2 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_USERHOST_H
-#define CMD_USERHOST_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /USERHOST. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -38,7 +30,9 @@ class CommandUserhost : public Command
  public:
        /** Constructor for userhost.
         */
-       CommandUserhost ( Module* parent) : Command(parent,"USERHOST",0,1) { syntax = "<nick>{,<nick>}"; }
+       CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1, 5) {
+               syntax = "<nick> {<nick>}";
+       }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -48,9 +42,6 @@ class CommandUserhost : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
 CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user)
 {
        std::string retbuf = std::string("302 ") + user->nick + " :";
@@ -64,13 +55,9 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
                        retbuf = retbuf + u->nick;
 
                        if (IS_OPER(u))
-                       {
-                               retbuf = retbuf + "*=";
-                       }
-                       else
-                       {
-                               retbuf = retbuf + "=";
-                       }
+                               retbuf = retbuf + "*";
+
+                       retbuf = retbuf + "=";
 
                        if (IS_AWAY(u))
                                retbuf += "-";
index 9b19c0ee06c2cca53d42122a26a56b6b4d9b9e23..6fae329bd06f17a41211235ace24c780e8ba1816 100644 (file)
 
 #include "inspircd.h"
 
-#ifndef CMD_VERSION_H
-#define CMD_VERSION_H
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
 /** Handle /VERSION. These command handlers can be reloaded by the core,
  * and handle basic RFC1459 commands. Commands within modules work
  * the same way, however, they can be fully unloaded, where these
@@ -48,11 +40,6 @@ class CommandVersion : public Command
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
 
-#endif
-
-
-
-
 CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
 {
        user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ServerInstance->GetVersionString(IS_OPER(user)).c_str());
index a8e36f6e0048c1c1c2a91a719ee81d575dcccbcb..b6e3f7187e2814e7276056de0d5898eec8633469 100644 (file)
@@ -307,7 +307,7 @@ void ParseStack::DoReadFile(const std::string& key, const std::string& name, int
        if (exec && (flags & FLAG_NO_EXEC))
                throw CoreException("Invalid <execfiles> tag in file included with noexec=\"yes\"");
 
-       FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(name.c_str(), "r"));
+       FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(name.c_str(), "r"), exec);
        if (!file)
                throw CoreException("Could not read \"" + name + "\" for \"" + key + "\" file");
 
@@ -364,7 +364,7 @@ bool ParseStack::ParseExec(const std::string& name, int flags)
 
        /* It's not already included, add it to the list of files we've loaded */
 
-       FileWrapper file(popen(name.c_str(), "r"));
+       FileWrapper file(popen(name.c_str(), "r"), true);
        if (!file)
                throw CoreException("Could not open executable \"" + name + "\" for include");
 
index b0bb6a92feb8455ee8b4c76edf2cc7f77415721c..166e124ca6ae400972e7bbea225616bed8a8ef6e 100644 (file)
@@ -436,8 +436,11 @@ static const Deprecated ChangedConfig[] = {
        {"options", "somaxconn",                "has been moved to <performance:somaxconn> as of 1.2a3"},
        {"options", "netbuffersize",    "has been moved to <performance:netbuffersize> as of 1.2a3"},
        {"options", "maxwho",           "has been moved to <performance:maxwho> as of 1.2a3"},
-       {"options",     "loglevel",             "1.2 does not use the loglevel value. Please define <log> tags instead."},
+       {"options",     "loglevel",             "1.2+ does not use the loglevel value. Please define <log> tags instead."},
        {"die",     "value",            "you need to reread your config"},
+       {"bind",    "transport",                "has been moved to <bind:ssl> as of 2.0a1"},
+       {"link",    "transport",                "has been moved to <link:ssl> as of 2.0a1"},
+       
 };
 
 void ServerConfig::Fill()
@@ -720,6 +723,24 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
        errstr.clear();
        errstr.str(std::string());
 
+       // Re-parse our MOTD and RULES files for colors -- Justasic
+       for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
+       {
+               ConfigTag *tag = (*it)->config;
+               // Make sure our connection class allows motd colors
+               if(!tag->getBool("allowmotdcolors"))
+                     continue;
+
+               ConfigFileCache::iterator motdfile = this->Files.find(tag->getString("motd", "motd"));
+               ConfigFileCache::iterator rulesfile = this->Files.find(tag->getString("rules", "rules"));
+
+               if(motdfile != this->Files.end())
+                     this->ProcessColors(motdfile);
+
+               if(rulesfile != this->Files.end())
+                     this->ProcessColors(rulesfile);
+       }
+
        /* No old configuration -> initial boot, nothing more to do here */
        if (!old)
        {
@@ -731,6 +752,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
                return;
        }
 
+
        // If there were errors processing configuration, don't touch modules.
        if (!valid)
                return;
@@ -837,6 +859,63 @@ ConfigTagList ServerConfig::ConfTags(const std::string& tag)
        return config_data.equal_range(tag);
 }
 
+/*
+ * Replace all color codes from the special[] array to actual
+ * color code chars using C++ style escape sequences. You
+ * can append other chars to replace if you like -- Justasic
+ */
+void ServerConfig::ProcessColors(ConfigFileCache::iterator &file)
+{
+       static struct special_chars
+       {
+               std::string character;
+               std::string replace;
+               special_chars(const std::string &c, const std::string &r) : character(c), replace(r) { }
+       }
+
+       special[] = {
+               special_chars("\\002", "\002"),  // Bold
+               special_chars("\\037", "\037"),  // underline
+               special_chars("\\003", "\003"),  // Color
+               special_chars("\\017", "\017"), // Stop colors
+               special_chars("\\u", "\037"),    // Alias for underline
+               special_chars("\\b", "\002"),    // Alias for Bold
+               special_chars("\\x", "\017"),    // Alias for stop
+               special_chars("\\c", "\003"),    // Alias for color
+               special_chars("", "")
+       };
+
+       for(file_cache::iterator it = file->second.begin(), it_end = file->second.end(); it != it_end; it++)
+       {
+               std::string ret = *it;
+               for(int i = 0; special[i].character.empty() == false; ++i)
+               {
+                       std::string::size_type pos = ret.find(special[i].character);
+                       if(pos == std::string::npos) // Couldn't find the character, skip this line
+                               continue;
+                       
+                       if((pos > 0) && (ret[pos-1] == '\\') && (ret[pos] == '\\'))
+                               continue; // Skip double slashes.
+
+                       // Replace all our characters in the array
+                       while(pos != std::string::npos)
+                       {
+                               ret = ret.substr(0, pos) + special[i].replace + ret.substr(pos + special[i].character.size());
+                               pos = ret.find(special[i].character, pos + special[i].replace.size());
+                       }
+               }
+
+               // Replace double slashes with a single slash before we return
+               std::string::size_type pos = ret.find("\\\\");
+               while(pos != std::string::npos)
+               {
+                       ret = ret.substr(0, pos) + "\\" + ret.substr(pos + 2);
+                       pos = ret.find("\\\\", pos + 1);
+               }
+               *it = ret;
+       }
+}
+
 bool ServerConfig::FileExists(const char* file)
 {
        struct stat sb;
index 8c34c8a5603984f9f1a5cc5731beb73200ec5d17..2cb6fb972326984582d81d1d4ecdf15acfd31c61 100644 (file)
@@ -451,7 +451,7 @@ int irc::modestacker::GetStackedLine(std::vector<std::string> &result, int max_l
 irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector<std::string> &sequence, int begin, int end)
 {
        if (end < begin)
-               throw "stringjoiner logic error, this causes problems.";
+               return; // nothing to do here
 
        for (int v = begin; v < end; v++)
                joined.append(sequence[v]).append(seperator);
@@ -461,7 +461,7 @@ irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector<
 irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque<std::string> &sequence, int begin, int end)
 {
        if (end < begin)
-               throw "stringjoiner logic error, this causes problems.";
+               return; // nothing to do here
 
        for (int v = begin; v < end; v++)
                joined.append(sequence[v]).append(seperator);
@@ -471,7 +471,7 @@ irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque<s
 irc::stringjoiner::stringjoiner(const std::string &seperator, const char* const* sequence, int begin, int end)
 {
        if (end < begin)
-               throw "stringjoiner logic error, this causes problems.";
+               return; // nothing to do here
 
        for (int v = begin; v < end; v++)
                joined.append(sequence[v]).append(seperator);
@@ -483,29 +483,17 @@ std::string& irc::stringjoiner::GetJoined()
        return joined;
 }
 
-irc::portparser::portparser(const std::string &source, bool allow_overlapped) : in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped)
+irc::portparser::portparser(const std::string &source, bool allow_overlapped)
+       : sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped)
 {
-       sep = new irc::commasepstream(source);
-       overlap_set.clear();
-}
-
-irc::portparser::~portparser()
-{
-       delete sep;
 }
 
 bool irc::portparser::Overlaps(long val)
 {
-       if (!overlapped)
+       if (overlapped)
                return false;
 
-       if (overlap_set.find(val) == overlap_set.end())
-       {
-               overlap_set[val] = true;
-               return false;
-       }
-       else
-               return true;
+       return (!overlap_set.insert(val).second);
 }
 
 long irc::portparser::GetToken()
@@ -533,14 +521,14 @@ long irc::portparser::GetToken()
        }
 
        std::string x;
-       sep->GetToken(x);
+       sep.GetToken(x);
 
        if (x.empty())
                return 0;
 
        while (Overlaps(atoi(x.c_str())))
        {
-               if (!sep->GetToken(x))
+               if (!sep.GetToken(x))
                        return 0;
        }
 
index 005a11dd7c239e502932e956905defbfa7fc059c..aa03d62dee4835f8d67300ea1c0e3ff6bb2fe992 100644 (file)
@@ -195,24 +195,21 @@ void InspIRCd::ResetMaxBans()
 void InspIRCd::RehashUsersAndChans()
 {
        user_hash* old_users = Users->clientlist;
-       user_hash* old_uuid  = Users->uuidlist;
-       chan_hash* old_chans = chanlist;
-
-       Users->clientlist = new user_hash();
-       Users->uuidlist = new user_hash();
-       chanlist = new chan_hash();
-
+       Users->clientlist = new user_hash;
        for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
                Users->clientlist->insert(*n);
+       delete old_users;
 
+       user_hash* old_uuid = Users->uuidlist;
+       Users->uuidlist = new user_hash;
        for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++)
                Users->uuidlist->insert(*n);
+       delete old_uuid;
 
+       chan_hash* old_chans = chanlist;
+       chanlist = new chan_hash;
        for (chan_hash::const_iterator n = old_chans->begin(); n != old_chans->end(); n++)
                chanlist->insert(*n);
-
-       delete old_users;
-       delete old_uuid;
        delete old_chans;
 
        // Reset the already_sent IDs so we don't wrap it around and drop a message
@@ -220,6 +217,7 @@ void InspIRCd::RehashUsersAndChans()
        for (std::vector<LocalUser*>::const_iterator i = Users->local_users.begin(); i != Users->local_users.end(); i++)
        {
                (**i).already_sent = 0;
+               (**i).RemoveExpiredInvites();
        }
 }
 
index 5efc98250d7e1851b93d88cce54d6a900e1e6145..083445cefba7b00694a3d74ff09e4d6b76430adb 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2012 Shawn Smith <shawn@inspircd.org>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
  *   Copyright (C) 2006-2008 Robin Burchell <robin+git@viroteck.net>
@@ -132,47 +133,39 @@ bool ModeHandler::ResolveModeConflict(std::string& theirs, const std::string& ou
 
 ModeAction SimpleUserModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
 {
-       if (adding)
-       {
-               if (!dest->IsModeSet(this->GetModeChar()))
-               {
-                       dest->SetMode(this->GetModeChar(),true);
-                       return MODEACTION_ALLOW;
-               }
-       }
-       else
-       {
-               if (dest->IsModeSet(this->GetModeChar()))
-               {
-                       dest->SetMode(this->GetModeChar(),false);
-                       return MODEACTION_ALLOW;
-               }
-       }
+       /* We're either trying to add a mode we already have or
+               remove a mode we don't have, deny. */
+       if (dest->IsModeSet(this->GetModeChar()) == adding)
+               return MODEACTION_DENY;
 
-       return MODEACTION_DENY;
+       /* adding will be either true or false, depending on if we
+               are adding or removing the mode, since we already checked
+               to make sure we aren't adding a mode we have or that we
+               aren't removing a mode we don't have, we don't have to do any
+               other checks here to see if it's true or false, just add or
+               remove the mode */
+       dest->SetMode(this->GetModeChar(), adding);
+
+       return MODEACTION_ALLOW;
 }
 
 
 ModeAction SimpleChannelModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
 {
-       if (adding)
-       {
-               if (!channel->IsModeSet(this->GetModeChar()))
-               {
-                       channel->SetMode(this->GetModeChar(),true);
-                       return MODEACTION_ALLOW;
-               }
-       }
-       else
-       {
-               if (channel->IsModeSet(this->GetModeChar()))
-               {
-                       channel->SetMode(this->GetModeChar(),false);
-                       return MODEACTION_ALLOW;
-               }
-       }
+       /* We're either trying to add a mode we already have or
+               remove a mode we don't have, deny. */
+       if (channel->IsModeSet(this->GetModeChar()) == adding)
+               return MODEACTION_DENY;
 
-       return MODEACTION_DENY;
+       /* adding will be either true or false, depending on if we
+               are adding or removing the mode, since we already checked
+               to make sure we aren't adding a mode we have or that we
+               aren't removing a mode we don't have, we don't have to do any
+               other checks here to see if it's true or false, just add or
+               remove the mode */
+       channel->SetMode(this->GetModeChar(), adding);
+
+       return MODEACTION_ALLOW;
 }
 
 ModeAction ParamChannelModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
index 034a93a859feeba9b85f04d9677edfe4b1c550a7..660b0c27559a5cac64975b70a1a32270ec3046bb 100644 (file)
@@ -116,7 +116,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan
                return dest;
 
        long maxbans = chan->GetMaxBans();
-       if (!IS_LOCAL(user) && ((unsigned)chan->bans.size() > (unsigned)maxbans))
+       if (IS_LOCAL(user) && ((unsigned)chan->bans.size() > (unsigned)maxbans))
        {
                user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick.c_str(), chan->name.c_str(), chan->name.c_str(), maxbans);
                dest = "";
index 8306ff6af1abc21c3f03470247386cecc15cd8b6..ccd78a8f028c63d6790c04fa499a50c5d2ae9696 100644 (file)
@@ -176,7 +176,6 @@ ModResult   Module::OnNumeric(User*, unsigned int, const std::string&) { return MO
 void           Module::OnHookIO(StreamSocket*, ListenSocket*) { }
 ModResult   Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
 void           Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, std::string&) { }
-void           Module::OnSetClientIP(User *) { }
 
 ModuleManager::ModuleManager() : ModCount(0)
 {
index 6bd834dc80541f13c3b6f12233628236f8f2020c..6eade1fbdc1d45404ff8256e9eadce2b000d25c4 100644 (file)
@@ -32,7 +32,7 @@
 # pragma comment(lib, "lber.lib")
 #endif
 
-/* $ModDesc: Allow/Deny connections based upon answer from LDAP server */
+/* $ModDesc: Adds the ability to authenticate opers via LDAP */
 /* $LinkerFlags: -lldap */
 
 class ModuleLDAPAuth : public Module
@@ -181,7 +181,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("Allow/Deny connections based upon answer from LDAP server", VF_VENDOR);
+               return Version("Adds the ability to authenticate opers via LDAP", VF_VENDOR);
        }
 
 };
index 6ca876d4ccfb354694cc777f87d593e074b25a90..c631642cee610e74f030117af62f35200df63f62 100644 (file)
 #include "ssl.h"
 #include "m_cap.h"
 
+#ifdef WINDOWS
+# pragma comment(lib, "libgnutls.lib")
+# pragma comment(lib, "libgcrypt.lib")
+# pragma comment(lib, "libgpg-error.lib")
+# pragma comment(lib, "user32.lib")
+# pragma comment(lib, "advapi32.lib")
+# pragma comment(lib, "libgcc.lib")
+# pragma comment(lib, "libmingwex.lib")
+# pragma comment(lib, "gdi32.lib")
+#endif
+
 /* $ModDesc: Provides SSL support for clients */
 /* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") */
 /* $LinkerFlags: rpath("pkg-config --libs gnutls") pkgconflibs("gnutls","/libgnutls.so","-lgnutls") -lgcrypt */
index aba8fe7fe1489223b5b0b044d7029728e710511b..7012fde7ec78698d765da7fd58acf614d17626a0 100644 (file)
@@ -38,7 +38,7 @@ class CommandAlltime : public Command
                time_t now = ServerInstance->Time();
                strftime(fmtdate, sizeof(fmtdate), "%Y-%m-%d %H:%M:%S", gmtime(&now));
 
-               std::string msg = ":" + std::string(ServerInstance->Config->ServerName.c_str()) + " NOTICE " + user->nick + " :System time is " + fmtdate + "(" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
+               std::string msg = ":" + std::string(ServerInstance->Config->ServerName.c_str()) + " NOTICE " + user->nick + " :System time is " + fmtdate + " (" + ConvToStr(ServerInstance->Time()) + ") on " + ServerInstance->Config->ServerName;
 
                user->SendText(msg);
 
index 1d26b7639344340f83f9727b9cc2f9b024cd4ab7..8160fcf542ad9fcb12d0f0984bae5c7b8b36fe82 100644 (file)
@@ -98,8 +98,8 @@ class ModuleBlockAmsg : public Module
 
        virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
        {
-               // Don't do anything with unregistered users, or remote ones.
-               if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
+               // Don't do anything with unregistered users
+               if (user->registered != REG_ALL)
                        return MOD_RES_PASSTHRU;
 
                // We want case insensitive command comparison.
index f2ba0603f6bd0d46ae63bf11d7d012107f6491aa..19b5c9231456a7ad9127c54495c286dcc3908fba 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style channel mode +c */
+/* $ModDesc: Provides channel mode +c to block color */
 
 /** Handles the +c channel mode
  */
@@ -95,7 +95,7 @@ class ModuleBlockColor : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for unreal-style channel mode +c",VF_VENDOR);
+               return Version("Provides channel mode +c to block color",VF_VENDOR);
        }
 };
 
index c7a51beb9e08c7e7021a4b6e5277ca97bd9046c4..5871b92278d11f8793625af90c30977279e04ffc 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style umode +B */
+/* $ModDesc: Provides user mode +B to mark the user as a bot */
 
 /** Handles user mode +B
  */
@@ -51,7 +51,7 @@ class ModuleBotMode : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for unreal-style umode +B",VF_VENDOR);
+               return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR);
        }
 
        virtual void OnWhois(User* src, User* dst)
index 416ede9a1ba8f05cb6381b9c5f975cb4aa29f439..f24c38b653acbfa074eee188a393497e84dd25e8 100644 (file)
 
 
 #include "inspircd.h"
-#include <set>
-#include <sstream>
-#include <algorithm>
 
-/* $ModDesc: Implementation of callerid (umode +g & /accept, ala hybrid etc) */
+/* $ModDesc: Implementation of callerid, usermode +g, /accept */
 
 class callerid_data
 {
@@ -57,11 +54,8 @@ class callerid_data
                        }
 
                        User *u = ServerInstance->FindNick(tok);
-                       if (!u)
-                       {
-                               continue;
-                       }
-                       accepting.insert(u);
+                       if ((u) && (u->registered == REG_ALL) && (!u->quitting) && (!IS_SERVER(u)))
+                               accepting.insert(u);
                }
        }
 
@@ -121,14 +115,9 @@ struct CallerIDExtInfo : public ExtensionItem
                        if (!targ)
                                continue; // shouldn't happen, but oh well.
 
-                       for (std::list<callerid_data *>::iterator it2 = targ->wholistsme.begin(); it2 != targ->wholistsme.end(); it2++)
-                       {
-                               if (*it2 == dat)
-                               {
-                                       targ->wholistsme.erase(it2);
-                                       break;
-                               }
-                       }
+                       std::list<callerid_data*>::iterator it2 = std::find(targ->wholistsme.begin(), targ->wholistsme.end(), dat);
+                       if (it2 != targ->wholistsme.end())
+                               targ->wholistsme.erase(it2);
                }
        }
 };
@@ -173,18 +162,12 @@ public:
                                tok.erase(0, 1); // Remove the dash.
                        }
                        User* u = ServerInstance->FindNick(tok);
-                       if (u)
-                       {
-                               if (dash)
-                                       out.append("-");
-                               out.append(u->uuid);
-                       }
-                       else
-                       {
-                               if (dash)
-                                       out.append("-");
-                               out.append(tok);
-                       }
+                       if ((!u) || (u->registered != REG_ALL) || (u->quitting) || (IS_SERVER(u)))
+                               continue;
+
+                       if (dash)
+                               out.append("-");
+                       out.append(u->uuid);
                }
                parameter = out;
        }
@@ -213,15 +196,15 @@ public:
                {
                        User* whotoremove = ServerInstance->FindNick(tok.substr(1));
                        if (whotoremove)
-                               return (RemoveAccept(user, whotoremove, false) ? CMD_SUCCESS : CMD_FAILURE);
+                               return (RemoveAccept(user, whotoremove) ? CMD_SUCCESS : CMD_FAILURE);
                        else
                                return CMD_FAILURE;
                }
                else
                {
                        User* whotoadd = ServerInstance->FindNick(tok[0] == '+' ? tok.substr(1) : tok);
-                       if (whotoadd)
-                               return (AddAccept(user, whotoadd, false) ? CMD_SUCCESS : CMD_FAILURE);
+                       if ((whotoadd) && (whotoadd->registered == REG_ALL) && (!whotoadd->quitting) && (!IS_SERVER(whotoadd)))
+                               return (AddAccept(user, whotoadd) ? CMD_SUCCESS : CMD_FAILURE);
                        else
                        {
                                user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), tok.c_str());
@@ -246,22 +229,18 @@ public:
                user->WriteNumeric(282, "%s :End of ACCEPT list", user->nick.c_str());
        }
 
-       bool AddAccept(User* user, User* whotoadd, bool quiet)
+       bool AddAccept(User* user, User* whotoadd)
        {
                // Add this user to my accept list first, so look me up..
                callerid_data* dat = extInfo.get(user, true);
                if (dat->accepting.size() >= maxaccepts)
                {
-                       if (!quiet)
-                               user->WriteNumeric(456, "%s :Accept list is full (limit is %d)", user->nick.c_str(), maxaccepts);
-
+                       user->WriteNumeric(456, "%s :Accept list is full (limit is %d)", user->nick.c_str(), maxaccepts);
                        return false;
                }
                if (!dat->accepting.insert(whotoadd).second)
                {
-                       if (!quiet)
-                               user->WriteNumeric(457, "%s %s :is already on your accept list", user->nick.c_str(), whotoadd->nick.c_str());
-
+                       user->WriteNumeric(457, "%s %s :is already on your accept list", user->nick.c_str(), whotoadd->nick.c_str());
                        return false;
                }
 
@@ -273,23 +252,19 @@ public:
                return true;
        }
 
-       bool RemoveAccept(User* user, User* whotoremove, bool quiet)
+       bool RemoveAccept(User* user, User* whotoremove)
        {
                // Remove them from my list, so look up my list..
                callerid_data* dat = extInfo.get(user, false);
                if (!dat)
                {
-                       if (!quiet)
-                               user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
-
+                       user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
                        return false;
                }
                std::set<User*>::iterator i = dat->accepting.find(whotoremove);
                if (i == dat->accepting.end())
                {
-                       if (!quiet)
-                               user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
-
+                       user->WriteNumeric(458, "%s %s :is not on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
                        return false;
                }
 
@@ -303,15 +278,10 @@ public:
                        return false;
                }
 
-               for (std::list<callerid_data *>::iterator it = dat2->wholistsme.begin(); it != dat2->wholistsme.end(); it++)
-               {
+               std::list<callerid_data*>::iterator it = std::find(dat2->wholistsme.begin(), dat2->wholistsme.end(), dat);
+               if (it != dat2->wholistsme.end())
                        // Found me!
-                       if (*it == dat)
-                       {
-                               dat2->wholistsme.erase(it);
-                               break;
-                       }
-               }
+                       dat2->wholistsme.erase(it);
 
                user->WriteServ("NOTICE %s :%s is no longer on your accept list", user->nick.c_str(), whotoremove->nick.c_str());
                return true;
@@ -367,7 +337,7 @@ public:
                ServerInstance->Modules->AddService(cmd);
                ServerInstance->Modules->AddService(cmd.extInfo);
 
-               Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
+               Implementation eventlist[] = { I_OnRehash, I_OnUserPostNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
                ServerInstance->Modules->Attach(eventlist, this, 6);
        }
 
@@ -377,7 +347,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR);
+               return Version("Implementation of callerid, usermode +g, /accept", VF_COMMON | VF_VENDOR);
        }
 
        virtual void On005Numeric(std::string& output)
@@ -385,7 +355,7 @@ public:
                output += " CALLERID=g";
        }
 
-       ModResult PreText(User* user, User* dest, std::string& text, bool notice)
+       ModResult PreText(User* user, User* dest, std::string& text)
        {
                if (!dest->IsModeSet('g'))
                        return MOD_RES_PASSTHRU;
@@ -416,7 +386,7 @@ public:
        virtual ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list)
        {
                if (IS_LOCAL(user) && target_type == TYPE_USER)
-                       return PreText(user, (User*)dest, text, true);
+                       return PreText(user, (User*)dest, text);
 
                return MOD_RES_PASSTHRU;
        }
@@ -424,16 +394,15 @@ public:
        virtual ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list)
        {
                if (IS_LOCAL(user) && target_type == TYPE_USER)
-                       return PreText(user, (User*)dest, text, true);
+                       return PreText(user, (User*)dest, text);
 
                return MOD_RES_PASSTHRU;
        }
 
-       ModResult OnUserPreNick(User* user, const std::string& newnick)
+       void OnUserPostNick(User* user, const std::string& oldnick)
        {
                if (!tracknick)
                        RemoveFromAllAccepts(user);
-               return MOD_RES_PASSTHRU;
        }
 
        void OnUserQuit(User* user, const std::string& message, const std::string& oper_message)
index 36674b9c5a41c41f5f88629e65d3a2cadcaca470..662e128a4aa18c385ef2ef1e182bc07a355dd341 100644 (file)
@@ -55,19 +55,14 @@ class CommandCAP : public Command
 
                if (subcommand == "REQ")
                {
-                       CapEvent Data(creator, "cap_req");
-
-                       Data.type = subcommand;
-                       Data.user = user;
-                       Data.creator = this->creator;
-
                        if (parameters.size() < 2)
                                return CMD_FAILURE;
 
+                       CapEvent Data(creator, user, CapEvent::CAPEVENT_REQ);
+
                        // tokenize the input into a nice list of requested caps
-                       std::string param = parameters[1];
                        std::string cap_;
-                       irc::spacesepstream cap_stream(param);
+                       irc::spacesepstream cap_stream(parameters[1]);
 
                        while (cap_stream.GetToken(cap_))
                        {
@@ -95,11 +90,7 @@ class CommandCAP : public Command
                }
                else if ((subcommand == "LS") || (subcommand == "LIST"))
                {
-                       CapEvent Data(creator, subcommand == "LS" ? "cap_ls" : "cap_list");
-
-                       Data.type = subcommand;
-                       Data.user = user;
-                       Data.creator = this->creator;
+                       CapEvent Data(creator, user, subcommand == "LS" ? CapEvent::CAPEVENT_LS : CapEvent::CAPEVENT_LIST);
 
                        reghold.set(user, 1);
                        Data.Send();
@@ -107,31 +98,28 @@ class CommandCAP : public Command
                        std::string Result;
                        if (Data.wanted.size() > 0)
                                Result = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
-                       else
-                               Result = "";
 
                        user->WriteServ("CAP %s %s :%s", user->nick.c_str(), subcommand.c_str(), Result.c_str());
                }
                else if (subcommand == "CLEAR")
                {
-                       CapEvent Data(creator, "cap_clear");
-
-                       Data.type = subcommand;
-                       Data.user = user;
-                       Data.creator = this->creator;
+                       CapEvent Data(creator, user, CapEvent::CAPEVENT_CLEAR);
 
                        reghold.set(user, 1);
                        Data.Send();
 
-                       std::string Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
+                       std::string Result;
+                       if (!Data.ack.empty())
+                               Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
                        user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), Result.c_str());
                }
                else
                {
                        user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.c_str());
+                       return CMD_FAILURE;
                }
 
-               return CMD_FAILURE;
+               return CMD_SUCCESS;
        }
 };
 
index 604fdb0efcd6dd2e5e845b2d5a9c806f2a40a8bc..ce7e7f3943c9611954aa94a0776e034a0b3f3a65 100644 (file)
 #ifndef M_CAP_H
 #define M_CAP_H
 
-#include <map>
-#include <string>
-
 class CapEvent : public Event
 {
  public:
-       irc::string type;
+       enum CapEventType
+       {
+               CAPEVENT_REQ,
+               CAPEVENT_LS,
+               CAPEVENT_LIST,
+               CAPEVENT_CLEAR
+       };
+
+       CapEventType type;
        std::vector<std::string> wanted;
        std::vector<std::string> ack;
        User* user;
-       Module* creator;
-       CapEvent(Module* sender, const std::string& t) : Event(sender, t) {}
+       CapEvent(Module* sender, User* u, CapEventType capevtype) : Event(sender, "cap_request"), type(capevtype), user(u) {}
 };
 
 class GenericCap
@@ -47,28 +51,37 @@ class GenericCap
 
        void HandleEvent(Event& ev)
        {
+               if (ev.id != "cap_request")
+                       return;
+
                CapEvent *data = static_cast<CapEvent*>(&ev);
-               if (ev.id == "cap_req")
+               if (data->type == CapEvent::CAPEVENT_REQ)
                {
-                       std::vector<std::string>::iterator it;
-                       if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end())
+                       for (std::vector<std::string>::iterator it = data->wanted.begin(); it != data->wanted.end(); ++it)
                        {
-                               // we can handle this, so ACK it, and remove it from the wanted list
-                               data->ack.push_back(*it);
-                               data->wanted.erase(it);
-                               ext.set(data->user, 1);
+                               if (it->empty())
+                                       continue;
+                               bool enablecap = ((*it)[0] != '-');
+                               if (((enablecap) && (*it == cap)) || (*it == "-" + cap))
+                               {
+                                       // we can handle this, so ACK it, and remove it from the wanted list
+                                       data->ack.push_back(*it);
+                                       data->wanted.erase(it);
+                                       ext.set(data->user, enablecap ? 1 : 0);
+                                       break;
+                               }
                        }
                }
-               else if (ev.id == "cap_ls")
+               else if (data->type == CapEvent::CAPEVENT_LS)
                {
                        data->wanted.push_back(cap);
                }
-               else if (ev.id == "cap_list")
+               else if (data->type == CapEvent::CAPEVENT_LIST)
                {
                        if (ext.get(data->user))
                                data->wanted.push_back(cap);
                }
-               else if (ev.id == "cap_clear")
+               else if (data->type == CapEvent::CAPEVENT_CLEAR)
                {
                        data->ack.push_back("-" + cap);
                        ext.set(data->user, 0);
index 9275152ea505dbba9368130cede3516697197e1a..16eba953f544fb05323c2fd3f269c760497e9305 100644 (file)
@@ -37,9 +37,23 @@ struct HistoryList
 
 class HistoryMode : public ModeHandler
 {
+       bool IsValidDuration(const std::string duration)
+       {
+               for (std::string::const_iterator i = duration.begin(); i != duration.end(); ++i)
+               {
+                       unsigned char c = *i;
+                       if (((c >= '0') && (c <= '9')) || (c == 's') || (c != 'S'))
+                               continue;
+
+                       if (duration_multi[c] == 1)
+                               return false;
+               }
+               return true;
+       }
+
  public:
        SimpleExtItem<HistoryList> ext;
-       int maxlines;
+       unsigned int maxlines;
        HistoryMode(Module* Creator) : ModeHandler(Creator, "history", 'H', PARAM_SETONLY, MODETYPE_CHANNEL),
                ext("history", Creator) { }
 
@@ -50,9 +64,14 @@ class HistoryMode : public ModeHandler
                        std::string::size_type colon = parameter.find(':');
                        if (colon == std::string::npos)
                                return MODEACTION_DENY;
-                       int len = atoi(parameter.substr(0, colon).c_str());
-                       int time = ServerInstance->Duration(parameter.substr(colon+1));
-                       if (len <= 0 || time < 0)
+
+                       std::string duration = parameter.substr(colon+1);
+                       if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!IsValidDuration(duration))))
+                               return MODEACTION_DENY;
+
+                       unsigned int len = ConvToInt(parameter.substr(0, colon));
+                       int time = ServerInstance->Duration(duration);
+                       if (len == 0 || time < 0)
                                return MODEACTION_DENY;
                        if (len > maxlines && IS_LOCAL(source))
                                return MODEACTION_DENY;
@@ -60,7 +79,21 @@ class HistoryMode : public ModeHandler
                                len = maxlines;
                        if (parameter == channel->GetModeParameter(this))
                                return MODEACTION_DENY;
-                       ext.set(channel, new HistoryList(len, time));
+
+                       HistoryList* history = ext.get(channel);
+                       if (history)
+                       {
+                               // Shrink the list if the new line number limit is lower than the old one
+                               if (len < history->lines.size())
+                                       history->lines.erase(history->lines.begin(), history->lines.begin() + (history->lines.size() - len));
+
+                               history->maxlen = len;
+                               history->maxtime = time;
+                       }
+                       else
+                       {
+                               ext.set(channel, new HistoryList(len, time));
+                       }
                        channel->SetModeParam('H', parameter);
                }
                else
@@ -77,6 +110,7 @@ class HistoryMode : public ModeHandler
 class ModuleChanHistory : public Module
 {
        HistoryMode m;
+       bool sendnotice;
  public:
        ModuleChanHistory() : m(this)
        {
@@ -93,12 +127,9 @@ class ModuleChanHistory : public Module
 
        void OnRehash(User*)
        {
-               m.maxlines = ServerInstance->Config->ConfValue("chanhistory")->getInt("maxlines", 50);
-       }
-
-       ~ModuleChanHistory()
-       {
-               ServerInstance->Modes->DelMode(&m);
+               ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory");
+               m.maxlines = tag->getInt("maxlines", 50);
+               sendnotice = tag->getBool("notice", true);
        }
 
        void OnUserMessage(User* user,void* dest,int target_type, const std::string &text, char status, const CUList&)
@@ -121,14 +152,22 @@ class ModuleChanHistory : public Module
 
        void OnPostJoin(Membership* memb)
        {
+               if (IS_REMOTE(memb->user))
+                       return;
+
                HistoryList* list = m.ext.get(memb->chan);
                if (!list)
                        return;
                time_t mintime = 0;
                if (list->maxtime)
                        mintime = ServerInstance->Time() - list->maxtime;
-               memb->user->WriteServ("NOTICE %s :Replaying up to %d lines of pre-join history spanning up to %d seconds",
-                       memb->chan->name.c_str(), list->maxlen, list->maxtime);
+
+               if (sendnotice)
+               {
+                       memb->user->WriteServ("NOTICE %s :Replaying up to %d lines of pre-join history spanning up to %d seconds",
+                               memb->chan->name.c_str(), list->maxlen, list->maxtime);
+               }
+
                for(std::deque<HistoryItem>::iterator i = list->lines.begin(); i != list->lines.end(); ++i)
                {
                        if (i->ts >= mintime)
index ed5063fadc12880cce3d1d4e514e0c149409a436..29385b8e2aae07dcdb55574dc0caac88f4e4c5f1 100644 (file)
@@ -28,7 +28,8 @@ class ModuleChanLog : public Module
        /*
         * Multimap so people can redirect a snomask to multiple channels.
         */
-       std::multimap<char, std::string> logstreams;
+       typedef std::multimap<char, std::string> ChanLogTargets;
+       ChanLogTargets logstreams;
 
  public:
        ModuleChanLog()         {
@@ -72,30 +73,21 @@ class ModuleChanLog : public Module
 
        virtual ModResult OnSendSnotice(char &sno, std::string &desc, const std::string &msg)
        {
-               std::multimap<char, std::string>::const_iterator it = logstreams.find(sno);
-               char buf[MAXBUF];
-
-               if (it == logstreams.end())
+               std::pair<ChanLogTargets::const_iterator, ChanLogTargets::const_iterator> itpair = logstreams.equal_range(sno);
+               if (itpair.first == itpair.second)
                        return MOD_RES_PASSTHRU;
 
+               char buf[MAXBUF];
                snprintf(buf, MAXBUF, "\2%s\2: %s", desc.c_str(), msg.c_str());
 
-               while (it != logstreams.end())
+               for (ChanLogTargets::const_iterator it = itpair.first; it != itpair.second; ++it)
                {
-                       if (it->first != sno)
-                       {
-                               it++;
-                               continue;
-                       }
-
                        Channel *c = ServerInstance->FindChan(it->second);
                        if (c)
                        {
                                c->WriteChannelWithServ(ServerInstance->Config->ServerName.c_str(), "PRIVMSG %s :%s", c->name.c_str(), buf);
                                ServerInstance->PI->SendChannelPrivmsg(c, 0, buf);
                        }
-
-                       it++;
                }
 
                return MOD_RES_PASSTHRU;
index 194ecf80eacb375007f5a6451e673c743ee7ef21..2ac24c5d512bc2e90a3bb8da332a5e8b95a4c4ae 100644 (file)
@@ -44,16 +44,22 @@ class CommandChgname : public Command
                        return CMD_FAILURE;
                }
 
+               if (parameters[1].empty())
+               {
+                       user->WriteServ("NOTICE %s :*** CHGNAME: GECOS must be specified", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
                {
-                       user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str());
+                       user->WriteServ("NOTICE %s :*** CHGNAME: GECOS too long", user->nick.c_str());
                        return CMD_FAILURE;
                }
 
                if (IS_LOCAL(dest))
                {
                        dest->ChangeName(parameters[1].c_str());
-                       ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's real name to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
+                       ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's GECOS to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
                }
 
                return CMD_SUCCESS;
index ac8a7ba29d71b985af51725212e68da551eb10ed..877ba87d7fcb297dc2eff272cb4a04d369a14371 100644 (file)
 
 /** Handles user mode +c
  */
-class PrivacyMode : public ModeHandler
+class PrivacyMode : public SimpleUserModeHandler
 {
  public:
-       PrivacyMode(Module* Creator) : ModeHandler(Creator, "deaf_commonchan", 'c', PARAM_NONE, MODETYPE_USER) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('c'))
-                       {
-                               dest->SetMode('c',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('c'))
-                       {
-                               dest->SetMode('c',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       PrivacyMode(Module* Creator) : SimpleUserModeHandler(Creator, "deaf_commonchan", 'c') { }
 };
 
 class ModulePrivacyMode : public Module
index 8c2a5f73e3e3e68c1167b33960631d39c8c8a83c..0cea96154d4d8d5e1af49a57314d4e6d48d1c373 100644 (file)
@@ -102,7 +102,7 @@ class CommandDccallow : public Command
                        std::string nick = parameters[0].substr(1);
                        User *target = ServerInstance->FindNickOnly(nick);
 
-                       if (target)
+                       if ((target) && (!IS_SERVER(target)) && (!target->quitting) && (target->registered == REG_ALL))
                        {
 
                                if (action == '-')
@@ -257,7 +257,7 @@ class ModuleDCCAllow : public Module
                ServerInstance->Extensions.Register(ext);
                ServerInstance->AddCommand(&cmd);
                ReadFileConf();
-               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash };
+               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPostNick, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 5);
        }
 
@@ -274,7 +274,9 @@ class ModuleDCCAllow : public Module
                // remove their DCCALLOW list if they have one
                if (udl)
                {
-                       RemoveFromUserlist(user);
+                       userlist::iterator it = std::find(ul.begin(), ul.end(), user);
+                       if (it != ul.end())
+                               ul.erase(it);
                }
 
                // remove them from any DCCALLOW lists
@@ -282,10 +284,9 @@ class ModuleDCCAllow : public Module
                RemoveNick(user);
        }
 
-       virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
+       virtual void OnUserPostNick(User* user, const std::string &oldnick)
        {
                RemoveNick(user);
-               return MOD_RES_PASSTHRU;
        }
 
        virtual ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
@@ -381,7 +382,7 @@ class ModuleDCCAllow : public Module
 
        void Expire()
        {
-               for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
+               for (userlist::iterator iter = ul.begin(); iter != ul.end();)
                {
                        User* u = (User*)(*iter);
                        dl = ext->get(u);
@@ -403,10 +404,11 @@ class ModuleDCCAllow : public Module
                                                }
                                        }
                                }
+                               ++iter;
                        }
                        else
                        {
-                               RemoveFromUserlist(u);
+                               iter = ul.erase(iter);
                        }
                }
        }
@@ -414,7 +416,7 @@ class ModuleDCCAllow : public Module
        void RemoveNick(User* user)
        {
                /* Iterate through all DCCALLOW lists and remove user */
-               for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
+               for (userlist::iterator iter = ul.begin(); iter != ul.end();)
                {
                        User *u = (User*)(*iter);
                        dl = ext->get(u);
@@ -434,10 +436,11 @@ class ModuleDCCAllow : public Module
                                                }
                                        }
                                }
+                               ++iter;
                        }
                        else
                        {
-                               RemoveFromUserlist(u);
+                               iter = ul.erase(iter);
                        }
                }
        }
index 0a002bd07716633e2ae84b3dbef2324d79cfafa4..3e0d205bae2fa8347f42ee8759a1b24c8ae46c65 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for ircu style usermode +d (deaf to channel messages and channel notices) */
+/* $ModDesc: Provides usermode +d to block channel messages and channel notices */
 
 /** User mode +d - filter out channel messages and channel notices
  */
@@ -163,7 +163,7 @@ class ModuleDeaf : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for ircu style usermode +d (deaf to channel messages and channel notices)", VF_VENDOR);
+               return Version("Provides usermode +d to block channel messages and channel notices", VF_VENDOR);
        }
 
 };
index 6ef955a9f1526d9830e15e5c07047195a455a97c..1a0734ed9b01506f3ec3d4949f5ad02602576847 100644 (file)
 
 
 #include "inspircd.h"
-#include <stdarg.h>
 
 /* $ModDesc: Provides channelmode +d <int>, to deny messages to a channel until <int> seconds. */
 
 class DelayMsgMode : public ModeHandler
 {
- private:
-       CUList empty;
  public:
        LocalIntExt jointime;
        DelayMsgMode(Module* Parent) : ModeHandler(Parent, "delaymsg", 'd', PARAM_SETONLY, MODETYPE_CHANNEL)
@@ -55,7 +52,6 @@ class ModuleDelayMsg : public Module
                Implementation eventlist[] = { I_OnUserJoin, I_OnUserPreMessage};
                ServerInstance->Modules->Attach(eventlist, this, 2);
        }
-       ~ModuleDelayMsg();
        Version GetVersion();
        void OnUserJoin(Membership* memb, bool sync, bool created, CUList&);
        ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list);
@@ -65,6 +61,9 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
 {
        if (adding)
        {
+               if ((channel->IsModeSet('d')) && (channel->GetModeParameter('d') == parameter))
+                       return MODEACTION_DENY;
+
                /* Setting a new limit, sanity check */
                long limit = atoi(parameter.c_str());
 
@@ -76,6 +75,9 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
        }
        else
        {
+               if (!channel->IsModeSet('d'))
+                       return MODEACTION_DENY;
+
                /*
                 * Clean up metadata
                 */
@@ -87,10 +89,6 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel
        return MODEACTION_ALLOW;
 }
 
-ModuleDelayMsg::~ModuleDelayMsg()
-{
-}
-
 Version ModuleDelayMsg::GetVersion()
 {
        return Version("Provides channelmode +d <int>, to deny messages to a channel until <int> seconds.", VF_VENDOR);
@@ -98,7 +96,7 @@ Version ModuleDelayMsg::GetVersion()
 
 void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CUList&)
 {
-       if (memb->chan->IsModeSet('d'))
+       if ((IS_LOCAL(memb->user)) && (memb->chan->IsModeSet('d')))
        {
                djm.jointime.set(memb, ServerInstance->Time());
        }
@@ -107,7 +105,7 @@ void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CULis
 ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
 {
        /* Server origin */
-       if (!user)
+       if ((!user) || (!IS_LOCAL(user)))
                return MOD_RES_PASSTHRU;
 
        if (target_type != TYPE_CHANNEL)
@@ -118,7 +116,7 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty
 
        if (!memb)
                return MOD_RES_PASSTHRU;
-       
+
        time_t ts = djm.jointime.get(memb);
 
        if (ts == 0)
index 6a41c484f880e4d4d4dfbed20a4d46f5257191d7..2160b02dc68fcbd51a47d14b126b3ef582f74f0b 100644 (file)
@@ -243,7 +243,7 @@ class ModuleDNSBL : public Module
                ReadConf();
                ServerInstance->Modules->AddService(nameExt);
                ServerInstance->Modules->AddService(countExt);
-               Implementation eventlist[] = { I_OnRehash, I_OnSetClientIP, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
+               Implementation eventlist[] = { I_OnRehash, I_OnUserInit, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
                ServerInstance->Modules->Attach(eventlist, this, 5);
        }
 
@@ -348,24 +348,22 @@ class ModuleDNSBL : public Module
                ReadConf();
        }
 
-       void OnSetClientIP(User* user)
+       void OnUserInit(LocalUser* user)
        {
-               LocalUser *luser = IS_LOCAL(user);
-
-               if (!luser || luser->exempt)
+               if (user->exempt)
                        return;
 
                unsigned char a, b, c, d;
                char reversedipbuf[128];
                std::string reversedip;
 
-               if (luser->client_sa.sa.sa_family != AF_INET)
+               if (user->client_sa.sa.sa_family != AF_INET)
                        return;
 
-               d = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
-               c = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
-               b = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
-               a = (unsigned char) luser->client_sa.in4.sin_addr.s_addr & 0xFF;
+               d = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
+               c = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
+               b = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
+               a = (unsigned char) user->client_sa.in4.sin_addr.s_addr & 0xFF;
 
                snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a);
                reversedip = std::string(reversedipbuf);
@@ -379,11 +377,11 @@ class ModuleDNSBL : public Module
 
                        /* now we'd need to fire off lookups for `hostname'. */
                        bool cached;
-                       DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, luser, DNSBLConfEntries[i], cached);
+                       DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, user, DNSBLConfEntries[i], cached);
                        ServerInstance->AddResolver(r, cached);
                        i++;
                }
-               countExt.set(luser, i);
+               countExt.set(user, i);
        }
 
        ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass)
index db55858d661565986d2b7a3bec8463b240bd5b02..d9dd8f2acfe33e4d7e2ed774c2de85ad76860107 100644 (file)
@@ -38,13 +38,7 @@ class CommandGlobops : public Command
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
-               std::string line = "From " + std::string(user->nick) + ": ";
-               for (int i = 0; i < (int)parameters.size(); i++)
-               {
-                       line = line + parameters[i] + " ";
-               }
-               ServerInstance->SNO->WriteGlobalSno('g',line);
-
+               ServerInstance->SNO->WriteGlobalSno('g', "From " + user->nick + ": " + parameters[0]);
                return CMD_SUCCESS;
        }
 };
index f0eda3e5698fa3a86b924bc02db0cce14cf5c53a..7a43f024169f8cc95805bd33362c046ac62affd1 100644 (file)
@@ -92,11 +92,6 @@ class ModuleHalfop : public Module
                        throw ModuleException("Could not add new modes!");
        }
 
-       ~ModuleHalfop()
-       {
-               ServerInstance->Modes->DelMode(&mh);
-       }
-
        Version GetVersion()
        {
                return Version("Channel half-operator mode provider", VF_VENDOR);
index a7bd4a8c56969addd51d5bb8b80c940c21186939..60c23f45bd44820c39b5e01496a804551c535a1c 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 
-/* $ModDesc: Provides the /HELPOP command, works like UnrealIRCd's helpop */
+/* $ModDesc: Provides the /HELPOP command for useful information */
 
 #include "inspircd.h"
 
@@ -29,35 +29,13 @@ static std::map<irc::string, std::string> helpop_map;
 
 /** Handles user mode +h
  */
-class Helpop : public ModeHandler
+class Helpop : public SimpleUserModeHandler
 {
  public:
-       Helpop(Module* Creator) : ModeHandler(Creator, "helpop", 'h', PARAM_NONE, MODETYPE_USER)
+       Helpop(Module* Creator) : SimpleUserModeHandler(Creator, "helpop", 'h')
        {
                oper = true;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('h'))
-                       {
-                               dest->SetMode('h',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
 };
 
 /** Handles /HELPOP
@@ -188,7 +166,7 @@ class ModuleHelpop : public Module
 
                Version GetVersion()
                {
-                       return Version("Provides the /HELPOP command, works like UnrealIRCd's helpop", VF_VENDOR);
+                       return Version("Provides the /HELPOP command for useful information", VF_VENDOR);
                }
 };
 
index 17e2e86054db6561c21c9a816efbdfc6ac13f92d..9c582551b7dfcab396a3611110d70aed3e4c5484 100644 (file)
 
 /** Handles user mode +I
  */
-class HideChans : public ModeHandler
+class HideChans : public SimpleUserModeHandler
 {
  public:
-       HideChans(Module* Creator) : ModeHandler(Creator, "hidechans", 'I', PARAM_NONE, MODETYPE_USER) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('I'))
-                       {
-                               dest->SetMode('I',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('I'))
-                       {
-                               dest->SetMode('I',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       HideChans(Module* Creator) : SimpleUserModeHandler(Creator, "hidechans", 'I') { }
 };
 
 class ModuleHideChans : public Module
index cde50b1a951f88e3dee6f1aeca3ca936020370b5..998a57bb3c59b4d8a5b818a867ad71d15c6f5089 100644 (file)
 
 /** Handles user mode +H
  */
-class HideOper : public ModeHandler
+class HideOper : public SimpleUserModeHandler
 {
  public:
-       HideOper(Module* Creator) : ModeHandler(Creator, "hideoper", 'H', PARAM_NONE, MODETYPE_USER)
+       HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H')
        {
                oper = true;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('H'))
-                       {
-                               dest->SetMode('H',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('H'))
-                       {
-                               dest->SetMode('H',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
 };
 
 class ModuleHideOper : public Module
index b7c9c1cfdef7ca8c481225093ddc66f9c4a53c5f..c30e4d200fe305cc1f5c73d9ef0561e50691111b 100644 (file)
@@ -216,15 +216,17 @@ class IdentRequestSocket : public EventHandler
                char ibuf[MAXBUF];
                int recvresult = ServerInstance->SE->Recv(this, ibuf, MAXBUF-1, 0);
 
+               /* Close (but don't delete from memory) our socket
+                * and flag as done since the ident lookup has finished
+                */
+               Close();
+               done = true;
+
                /* Cant possibly be a valid response shorter than 3 chars,
                 * because the shortest possible response would look like: '1,1'
                 */
                if (recvresult < 3)
-               {
-                       Close();
-                       done = true;
                        return;
-               }
 
                ServerInstance->Logs->Log("m_ident",DEBUG,"ReadResponse()");
 
@@ -263,13 +265,6 @@ class IdentRequestSocket : public EventHandler
 
                        break;
                }
-
-               /* Close (but dont delete from memory) our socket
-                * and flag as done
-                */
-               Close();
-               done = true;
-               return;
        }
 };
 
@@ -388,7 +383,11 @@ class ModuleIdent : public Module
        {
                /* Module unloading, tidy up users */
                if (target_type == TYPE_USER)
-                       OnUserDisconnect((LocalUser*)item);
+               {
+                       LocalUser* user = IS_LOCAL((User*) item);
+                       if (user)
+                               OnUserDisconnect(user);
+               }
        }
 
        virtual void OnUserDisconnect(LocalUser *user)
index 1ecec735e0ac69ef00fd1556940f1692774253c3..5e6628e6d859dc27f36f138386905e9397745c5e 100644 (file)
@@ -47,6 +47,7 @@ class InviteException : public ListModeBase
 
 class ModuleInviteException : public Module
 {
+       bool invite_bypass_key;
        InviteException ie;
 public:
        ModuleInviteException() : ie(this)
@@ -54,9 +55,10 @@ public:
                if (!ServerInstance->Modes->AddMode(&ie))
                        throw ModuleException("Could not add new modes!");
 
+               OnRehash(NULL);
                ie.DoImplements(this);
-               Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite, I_OnCheckKey };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               Implementation eventlist[] = { I_On005Numeric, I_OnCheckInvite, I_OnCheckKey, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, 4);
        }
 
        void On005Numeric(std::string &output)
@@ -66,17 +68,14 @@ public:
 
        ModResult OnCheckInvite(User* user, Channel* chan)
        {
-               if(chan != NULL)
+               modelist* list = ie.extItem.get(chan);
+               if (list)
                {
-                       modelist* list = ie.extItem.get(chan);
-                       if (list)
+                       for (modelist::iterator it = list->begin(); it != list->end(); it++)
                        {
-                               for (modelist::iterator it = list->begin(); it != list->end(); it++)
+                               if (chan->CheckBan(user, it->mask))
                                {
-                                       if (chan->CheckBan(user, it->mask))
-                                       {
-                                               return MOD_RES_ALLOW;
-                                       }
+                                       return MOD_RES_ALLOW;
                                }
                        }
                }
@@ -86,7 +85,7 @@ public:
 
        ModResult OnCheckKey(User* user, Channel* chan, const std::string& key)
        {
-               if (ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true))
+               if (invite_bypass_key)
                        return OnCheckInvite(user, chan);
                return MOD_RES_PASSTHRU;
        }
@@ -103,6 +102,7 @@ public:
 
        void OnRehash(User* user)
        {
+               invite_bypass_key = ServerInstance->Config->ConfValue("inviteexception")->getBool("bypasskey", true);
                ie.DoRehash();
        }
 
index cc2e253081999d596eb151be0df82e9b2e464e60..3408e4621f278d630d859a2dcc7289588f3de3ac 100644 (file)
@@ -34,15 +34,20 @@ class CommandLockserv : public Command
 public:
        CommandLockserv(Module* Creator, bool& lock) : Command(Creator, "LOCKSERV", 0), locked(lock)
        {
-               flags_needed = 'o'; syntax.clear();
+               flags_needed = 'o';
        }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
+               if (locked)
+               {
+                       user->WriteServ("NOTICE %s :The server is already locked.", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                locked = true;
                user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server.c_str());
-               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
-               /* Dont send to the network */
+               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
 };
@@ -55,15 +60,20 @@ private:
 public:
        CommandUnlockserv(Module* Creator, bool &lock) : Command(Creator, "UNLOCKSERV", 0), locked(lock)
        {
-               flags_needed = 'o'; syntax.clear();
+               flags_needed = 'o';
        }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
+               if (!locked)
+               {
+                       user->WriteServ("NOTICE %s :The server isn't locked.", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                locked = false;
                user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server.c_str());
-               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
-               /* Dont send to the network */
+               ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str());
                return CMD_SUCCESS;
        }
 };
index e9ca3bfd0c0dc042f2a5b81466df755d977de252..3fb60a3d273ae029aa50209a7a6e2059999532d1 100644 (file)
@@ -54,17 +54,15 @@ public:
                        return MOD_RES_PASSTHRU;
 
                std::string *mlock_str = mlock.get(channel);
-               if (!mlock_str || mlock_str->empty())
+               if (!mlock_str)
                        return MOD_RES_PASSTHRU;
 
-               for (const char *modes = parameters[1].c_str(); *modes; modes++)
+               std::string::size_type p = parameters[1].find_first_of(*mlock_str);
+               if (p != std::string::npos)
                {
-                       if (mlock_str->find(*modes) != std::string::npos)
-                       {
-                               source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
-                                                    channel->name.c_str(), *modes, mlock_str->c_str());
-                               return MOD_RES_DENY;
-                       }
+                       source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
+                                            channel->name.c_str(), parameters[1][p], mlock_str->c_str());
+                       return MOD_RES_DENY;
                }
 
                return MOD_RES_PASSTHRU;
index 0b4e39764151486e9b12d9a1318cd2abd5689a66..8c8e1c473b387723ee0a3d8e3ff65a5068f160d1 100644 (file)
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style channel mode +C */
+/* $ModDesc: Provides channel mode +C to block CTCPs */
 
-class NoCTCP : public ModeHandler
+class NoCTCP : public SimpleChannelModeHandler
 {
  public:
-       NoCTCP(Module* Creator) : ModeHandler(Creator, "noctcp", 'C', PARAM_NONE, MODETYPE_CHANNEL) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('C'))
-                       {
-                               channel->SetMode('C',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('C'))
-                       {
-                               channel->SetMode('C',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       NoCTCP(Module* Creator) : SimpleChannelModeHandler(Creator, "noctcp", 'C') { }
 };
 
 class ModuleNoCTCP : public Module
@@ -73,7 +51,7 @@ class ModuleNoCTCP : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for unreal-style channel mode +C", VF_VENDOR);
+               return Version("Provides channel mode +C to block CTCPs", VF_VENDOR);
        }
 
        virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
@@ -86,21 +64,20 @@ class ModuleNoCTCP : public Module
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
+                       if (!c->IsModeSet('C'))
+                               return MOD_RES_PASSTHRU;
+
+                       if ((text.empty()) || (text[0] != '\001') || (strncmp(text.c_str(),"\1ACTION ",8)))
+                               return MOD_RES_PASSTHRU;
 
+                       ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
 
-                       if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet('C')))
+                       if (!c->GetExtBanStatus(user, 'C'))
                        {
-                               if ((text.length()) && (text[0] == '\1'))
-                               {
-                                       if (strncmp(text.c_str(),"\1ACTION ",8))
-                                       {
-                                               user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
-                                               return MOD_RES_DENY;
-                                       }
-                               }
+                               user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
+                               return MOD_RES_DENY;
                        }
                }
                return MOD_RES_PASSTHRU;
index 4d56ad35f0ef18ed38bfdeb8009e0defbb6558de..f5c404682d1df7b524630d74035898a8653dd804 100644 (file)
 
 /* $ModDesc: Provides support for channel mode +N & extban +b N: which prevents nick changes on channel */
 
-class NoNicks : public ModeHandler
+class NoNicks : public SimpleChannelModeHandler
 {
  public:
-       NoNicks(Module* Creator) : ModeHandler(Creator, "nonick", 'N', PARAM_NONE, MODETYPE_CHANNEL) { }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('N'))
-                       {
-                               channel->SetMode('N',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('N'))
-                       {
-                               channel->SetMode('N',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
+       NoNicks(Module* Creator) : SimpleChannelModeHandler(Creator, "nonick", 'N') { }
 };
 
 class ModuleNoNickChange : public Module
index 4aa51ef48bad4c1d093af84ca9df06055c6fe40e..ccb44ccde70ff1e8f33a43a13645ff5d2f00fc34 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style channel mode +T */
+/* $ModDesc: Provides channel mode +T to block notices to the channel */
 
 class NoNotice : public SimpleChannelModeHandler
 {
@@ -80,7 +80,7 @@ class ModuleNoNotice : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for unreal-style channel mode +T", VF_VENDOR);
+               return Version("Provides channel mode +T to block notices to the channel", VF_VENDOR);
        }
 };
 
index 074c644e13d0130a631b861bd7c25204aa8a9567..2e6fad79f05b6a7e234c1dd426a172cd367e34f7 100644 (file)
 
 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
 
-class OperChans : public ModeHandler
+class OperChans : public SimpleChannelModeHandler
 {
  public:
        /* This is an oper-only mode */
-       OperChans(Module* Creator) : ModeHandler(Creator, "operonly", 'O', PARAM_NONE, MODETYPE_CHANNEL) { oper = true; }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       OperChans(Module* Creator) : SimpleChannelModeHandler(Creator, "operonly", 'O')
        {
-               if (adding)
-               {
-                       if (!channel->IsModeSet('O'))
-                       {
-                               channel->SetMode('O',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (channel->IsModeSet('O'))
-                       {
-                               channel->SetMode('O',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
+               oper = true;
        }
 };
 
index da506dd582e0c164cc240a68e4b24d9b483fa318..7e28f6c21f2fad732df147dc16c84feb79f9fa98 100644 (file)
@@ -29,17 +29,7 @@ class ModuleOperLevels : public Module
        public:
                ModuleOperLevels()
                {
-                       Implementation eventlist[] = { I_OnRehash, I_OnKill };
-                       ServerInstance->Modules->Attach(eventlist, this, 2);
-               }
-
-               virtual ~ModuleOperLevels()
-               {
-               }
-
-
-               virtual void OnRehash(User* user)
-               {
+                       ServerInstance->Modules->Attach(I_OnKill, this);
                }
 
                virtual Version GetVersion()
@@ -64,7 +54,6 @@ class ModuleOperLevels : public Module
                        }
                        return MOD_RES_PASSTHRU;
                }
-
 };
 
 MODULE_INIT(ModuleOperLevels)
index d029fda64e8de92b3ed2e43c53e7b3d483c02b81..0b04ff57615472b0d41d438c9ee19bb18dc35b73 100644 (file)
@@ -29,13 +29,7 @@ class ModuleModesOnOper : public Module
  public:
        ModuleModesOnOper()
        {
-               Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
-       }
-
-
-       virtual void OnRehash(User* user)
-       {
+               ServerInstance->Modules->Attach(I_OnPostOper, this);
        }
 
        virtual ~ModuleModesOnOper()
@@ -49,6 +43,9 @@ class ModuleModesOnOper : public Module
 
        virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
        {
+               if (!IS_LOCAL(user))
+                       return;
+
                // whenever a user opers, go through the oper types, find their <type:modes>,
                // and if they have one apply their modes. The mode string can contain +modes
                // to add modes to the user or -modes to take modes from the user.
@@ -67,22 +64,14 @@ class ModuleModesOnOper : public Module
 
                std::string buf;
                std::stringstream ss(smodes);
-               std::vector<std::string> tokens;
+               std::vector<std::string> modes;
 
+               modes.push_back(u->nick);
                // split into modes and mode params
                while (ss >> buf)
-                       tokens.push_back(buf);
-
-               std::vector<std::string> modes;
-               modes.push_back(u->nick);
-
-               // process mode params
-               for (unsigned int k = 0; k < tokens.size(); k++)
-               {
-                       modes.push_back(tokens[k]);
-               }
+                       modes.push_back(buf);
 
-               ServerInstance->SendGlobalMode(modes, u);
+               ServerInstance->SendMode(modes, u);
        }
 };
 
index 1e875a3d67456d656df3c0db9e32a61827611a8d..76d6ee469635d0c4fbbcfd852f86664996cd7a4e 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style oper-override */
+/* $ModDesc: Provides support for allowing opers to override certain things. */
 
 class ModuleOverride : public Module
 {
@@ -194,7 +194,7 @@ class ModuleOverride : public Module
 
        Version GetVersion()
        {
-               return Version("Provides support for unreal-style oper-override",VF_VENDOR);
+               return Version("Provides support for allowing opers to override certain things",VF_VENDOR);
        }
 };
 
index 9ea3f72f16b0ccffe72116b2506637be92e04f94..6830f18cee1724f6cd0192848b08662b6a3a17b4 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2012 Shawn Smith <ShawnSmith0828@gmail.com>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
@@ -23,7 +24,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides channel mode +L (limit redirection) */
+/* $ModDesc: Provides channel mode +L (limit redirection) and usermode +L (no forced redirection) */
 
 /** Handle channel mode +L
  */
@@ -86,19 +87,44 @@ class Redirect : public ModeHandler
        }
 };
 
+/** Handles usermode +L to stop forced redirection and print an error.
+*/
+class AntiRedirect : public SimpleUserModeHandler
+{
+       public:
+               AntiRedirect(Module* Creator) : SimpleUserModeHandler(Creator, "antiredirect", 'L') {}
+};
+
 class ModuleRedirect : public Module
 {
 
        Redirect re;
+       AntiRedirect re_u;
+       bool UseUsermode;
 
  public:
 
        ModuleRedirect()
-               : re(this)
+               : re(this), re_u(this)
        {
+               /* Setting this here so it isn't changable by rehasing the config later. */
+               UseUsermode = ServerInstance->Config->ConfValue("redirect")->getBool("antiredirect");
 
+               /* Channel mode */
                if (!ServerInstance->Modes->AddMode(&re))
                        throw ModuleException("Could not add new modes!");
+
+               /* Check to see if the usermode is enabled in the config */
+               if (UseUsermode)
+               {
+                       /* Log noting that this breaks compatability. */
+                       ServerInstance->Logs->Log("m_redirect", DEFAULT, "REDIRECT: Enabled usermode +L. This breaks linking with servers that do not have this enabled. This is disabled by default in the 2.0 branch but will be enabled in the next version.");
+
+                       /* Try to add the usermode */
+                       if (!ServerInstance->Modes->AddMode(&re_u))
+                               throw ModuleException("Could not add new modes!");
+               }
+
                Implementation eventlist[] = { I_OnUserPreJoin };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
@@ -122,10 +148,20 @@ class ModuleRedirect : public Module
                                                user->WriteNumeric(470, "%s %s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", user->nick.c_str(), cname);
                                                return MOD_RES_DENY;
                                        }
-
-                                       user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname, channel.c_str());
-                                       Channel::JoinUser(user, channel.c_str(), false, "", false, ServerInstance->Time());
-                                       return MOD_RES_DENY;
+                                       /* We check the bool value here to make sure we have it enabled, if we don't then
+                                               usermode +L might be assigned to something else. */
+                                       if (UseUsermode && user->IsModeSet('L'))
+                                       {
+                                               user->WriteNumeric(470, "%s %s %s :Force redirection stopped.",
+                                               user->nick.c_str(), cname, channel.c_str());
+                                               return MOD_RES_DENY;
+                                       }
+                                       else
+                                       {
+                                               user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname, channel.c_str());
+                                               Channel::JoinUser(user, channel.c_str(), false, "", false, ServerInstance->Time());
+                                               return MOD_RES_DENY;
+                                       }
                                }
                        }
                }
@@ -138,7 +174,7 @@ class ModuleRedirect : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides channel mode +L (limit redirection)", VF_VENDOR);
+               return Version("Provides channel mode +L (limit redirection) and user mode +L (no forced redirection)", VF_VENDOR);
        }
 };
 
index 3d351313da7923c0f355984173990fd6b0d726ae..46732b6a67bf36a0f34da7a88def06495c44d62b 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides support for unreal-style SAJOIN command */
+/* $ModDesc: Provides command SAJOIN to allow opers to force-join users to channels */
 
 /** Handle /SAJOIN
  */
@@ -117,7 +117,7 @@ class ModuleSajoin : public Module
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for unreal-style SAJOIN command", VF_OPTCOMMON | VF_VENDOR);
+               return Version("Provides command SAJOIN to allow opers to force-join users to channels", VF_OPTCOMMON | VF_VENDOR);
        }
 
 };
index 5d088cf12257706544a82084fbb92d199df435df..d9c75adf79d394520f8501acff5582ce400a723c 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 
-/* $ModDesc: Provides more advanced UnrealIRCd SAMODE command */
+/* $ModDesc: Provides command SAMODE to allow opers to change modes on channels and users */
 
 #include "inspircd.h"
 
@@ -64,7 +64,7 @@ class ModuleSaMode : public Module
 
        Version GetVersion()
        {
-               return Version("Provides more advanced UnrealIRCd SAMODE command", VF_VENDOR);
+               return Version("Provides command SAMODE to allow opers to change modes on channels and users", VF_VENDOR);
        }
 
        ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector<std::string>& parameters)
index bf65cc5d5e9ab2a1e61b0c1380b19e3e091d1ee8..a0e3319af25d95d44e7df7e1143748b07823c1af 100644 (file)
@@ -44,8 +44,7 @@ class CommandSATopic : public Command
 
                        // 3rd parameter overrides access checks
                        target->SetTopic(user, newTopic, true);
-                       ServerInstance->SNO->WriteToSnoMask('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
-                       ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
+                       ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
 
                        return CMD_SUCCESS;
                }
index cd34e955a596392a106085e54e0107e09a198e2f..a28be61dccbd652b2bf9abfee5e35ed92c890492 100644 (file)
@@ -39,19 +39,17 @@ class Channel_r : public ModeHandler
                if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
                {
                        // Only change the mode if it's not redundant
-                       if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r')))
+                       if ((adding != channel->IsModeSet('r')))
                        {
                                channel->SetMode('r',adding);
                                return MODEACTION_ALLOW;
                        }
-
-                       return MODEACTION_DENY;
                }
                else
                {
                        source->WriteNumeric(500, "%s :Only a server may modify the +r channel mode", source->nick.c_str());
-                       return MODEACTION_DENY;
                }
+               return MODEACTION_DENY;
        }
 };
 
@@ -67,18 +65,17 @@ class User_r : public ModeHandler
        {
                if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
                {
-                       if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r')))
+                       if ((adding != dest->IsModeSet('r')))
                        {
                                dest->SetMode('r',adding);
                                return MODEACTION_ALLOW;
                        }
-                       return MODEACTION_DENY;
                }
                else
                {
                        source->WriteNumeric(500, "%s :Only a server may modify the +r user mode", source->nick.c_str());
-                       return MODEACTION_DENY;
                }
+               return MODEACTION_DENY;
        }
 };
 
index 0d6b1d9f3f55237e506e5c6715545e196935ce3f..32c1d5dc3c55789db3b53734fd47832fa1f3d6ed 100644 (file)
@@ -36,7 +36,7 @@ class CommandSetname : public Command
 
        CmdResult Handle (const std::vector<std::string>& parameters, User *user)
        {
-               if (parameters.size() == 0)
+               if (parameters[0].empty())
                {
                        user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick.c_str());
                        return CMD_FAILURE;
@@ -50,8 +50,7 @@ class CommandSetname : public Command
 
                if (user->ChangeName(parameters[0].c_str()))
                {
-                       ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to %s", user->nick.c_str(), parameters[0].c_str());
-                       return CMD_SUCCESS;
+                       ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to '%s'", user->nick.c_str(), parameters[0].c_str());
                }
 
                return CMD_SUCCESS;
index 6eec64bd5e5daf0e92a032ab0584efcf27ccd9b7..d81dd553d2743f641c9c2281a05e4e15fc6dfba1 100644 (file)
 
 /** Handle user mode +W
  */
-class SeeWhois : public ModeHandler
+class SeeWhois : public SimpleUserModeHandler
 {
  public:
-       SeeWhois(Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, "showwhois", 'W', PARAM_NONE, MODETYPE_USER)
+       SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
        {
                oper = IsOpersOnly;
        }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-       {
-               if (adding)
-               {
-                       if (!dest->IsModeSet('W'))
-                       {
-                               dest->SetMode('W',true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet('W'))
-                       {
-                               dest->SetMode('W',false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-
-               return MODEACTION_DENY;
-       }
 };
 
 class WhoisNoticeCmd : public Command
index fe1c41162b8300157bee3272557a7f44a7306951..197bbc1bf9823a26086c44f6b2c0978baf07113c 100644 (file)
@@ -158,7 +158,7 @@ class CommandShun : public Command
                        else
                        {
                                delete r;
-                               user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), expr.c_str());
+                               user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), target.c_str());
                                return CMD_FAILURE;
                        }
                }
index db9a7f2d6e49fc4cfdfecf91f371d7f6a3bee0e6..5c3ad548d4cebd5c967f09805bb61803e18c0d60 100644 (file)
@@ -30,7 +30,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
 {
        if (params.size() < 6)
        {
-               ServerInstance->SNO->WriteToSnoMask('d',"%s sent me a malformed ADDLINE of type %s.",prefix.c_str(),params[0].c_str());
+               ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", MyRoot->GetName().c_str());
                return true;
        }
 
index 50775be1d30f7f9931cb279f4bb162182b8bf6fd..929ace474f1296271c18c1dd94eb3b098b33402a 100644 (file)
@@ -105,6 +105,7 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
                        // while the name is equal in case-insensitive compare, it might differ in case; use the remote version
                        chan->name = channel;
                        chan->age = TS;
+                       chan->ClearInvites();
                        param_list.push_back(channel);
                        this->RemoveStatus(ServerInstance->FakeClient, param_list);
                }
index 7edc720af4a9e4c53b816f7e3f618deb52398019..35bce781d0561f596a322ffadf352a3c68e50435 100644 (file)
 
 CmdResult CommandSVSPart::Handle(const std::vector<std::string>& parameters, User *user)
 {
-       std::string reason = "Services forced part";
+       User* u = ServerInstance->FindUUID(parameters[0]);
+       if (!u)
+               return CMD_FAILURE;
 
-       if (parameters.size() == 3)
-               reason = parameters[2];
-
-       User* u = ServerInstance->FindNick(parameters[0]);
        Channel* c = ServerInstance->FindChan(parameters[1]);
+       if (!c)
+               return CMD_FAILURE;
 
-       if (u && IS_LOCAL(u))
+       if (IS_LOCAL(u))
+       {
+               std::string reason = (parameters.size() == 3) ? parameters[2] : "Services forced part";
                c->PartUser(u, reason);
-
+       }
        return CMD_SUCCESS;
 }
 
index be5455bce9102d99828acea1d74ace8fa4624fa8..13dfad3f10dba57897462011d1077eab94ebe94a 100644 (file)
@@ -315,6 +315,10 @@ class TreeSocket : public BufferedSocket
        /** Handle server quit on close
         */
        virtual void Close();
+
+       /** Returns true if this server was introduced to the rest of the network
+        */
+       bool Introduced();
 };
 
 #endif
index dcb35af31731fbbf68341258ce7865090cf224d8..7804c870d408cfb038ac2839e612fe1714056f56 100644 (file)
@@ -183,7 +183,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
        {
                DelServerEvent(Utils->Creator, Current->GetName());
 
-               if (!Current->GetSocket() || Current->GetSocket()->GetLinkState() == CONNECTED)
+               if (!Current->GetSocket() || Current->GetSocket()->Introduced())
                {
                        parameterlist params;
                        params.push_back(Current->GetName());
@@ -245,3 +245,8 @@ void TreeSocket::OnDataReady()
                SendError("RecvQ overrun (line too long)");
        Utils->Creator->loopCall = false;
 }
+
+bool TreeSocket::Introduced()
+{
+       return (capab == NULL);
+}
index cb49d92c92d66f23cfd556aaeedbeffc026535d5..e6fbad4c6dd512fda116944ac5b8e40dd303ebc3 100644 (file)
@@ -440,6 +440,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
                        ServerInstance->Logs->Log("m_spanningtree", SPARSE, "Unrecognised S2S command :%s %s %s",
                                who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
                        SendError("Unrecognised command '" + command + "' -- possibly loaded mismatched modules");
+                       return;
                }
 
                if (params.size() < cmd->min_params)
@@ -448,6 +449,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
                        ServerInstance->Logs->Log("m_spanningtree", SPARSE, "Insufficient parameters for S2S command :%s %s %s",
                                who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
                        SendError("Insufficient parameters for command '" + command + "'");
+                       return;
                }
 
                CmdResult res = cmd->Handle(params, who);
@@ -459,7 +461,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
                                who->uuid.c_str(), command.c_str(), pmlist.GetJoined().c_str());
                        SendError("Error handling '" + command + "' -- possibly loaded mismatched modules");
                }
-               if (res == CMD_SUCCESS)
+               else if (res == CMD_SUCCESS)
                        Utils->RouteCommand(route_back_again, command, params, who);
        }
 }
index 0a8f4dbfc717991db2799a0baad6372c3b6adce6..7dd2cad1df9a081d1d233ca46a49f631bfd01403 100644 (file)
@@ -67,7 +67,7 @@ CmdResult CommandUID::Handle(const parameterlist &params, User* serversrc)
                /*
                 * Nick collision.
                 */
-               int collide = sock->DoCollision(iter->second, age_t, params[5], modestr, params[0]);
+               int collide = sock->DoCollision(iter->second, age_t, params[5], params[6], params[0]);
                ServerInstance->Logs->Log("m_spanningtree",DEBUG,"*** Collision on %s, collide=%d", params[2].c_str(), collide);
 
                if (collide != 1)
index 504f1840b1c7f109e8993ce7b7676c0ebd0df745..ef63b2511733b8369155b2a3678989acaf9357e8 100644 (file)
@@ -24,7 +24,7 @@
 #include "inspircd.h"
 #include "ssl.h"
 
-/* $ModDesc: Provides support for unreal-style channel mode +z */
+/* $ModDesc: Provides channel mode +z to allow for Secure/SSL only channels */
 
 /** Handle channel mode +z
  */
@@ -134,7 +134,7 @@ class ModuleSSLModes : public Module
 
        Version GetVersion()
        {
-               return Version("Provides support for unreal-style channel mode +z", VF_VENDOR);
+               return Version("Provides channel mode +z to allow for Secure/SSL only channels", VF_VENDOR);
        }
 };
 
index cd4f35c4b11899982a5805b2689f460120f31bde..86f307bae2ed4e494bccb87555cf75ef3f2f6e1e 100644 (file)
@@ -72,8 +72,8 @@ class ModuleStripColor : public Module
        {
                /* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */
                int seq = 0;
-               std::string::iterator i,safei;
-               for (i = sentence.begin(); i != sentence.end();)
+
+               for (std::string::iterator i = sentence.begin(); i != sentence.end();)
                {
                        if (*i == 3)
                                seq = 1;
@@ -89,20 +89,7 @@ class ModuleStripColor : public Module
                                seq = 0;
 
                        if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31)))
-                       {
-                               if (i != sentence.begin())
-                               {
-                                       safei = i;
-                                       --i;
-                                       sentence.erase(safei);
-                                       ++i;
-                               }
-                               else
-                               {
-                                       sentence.erase(i);
-                                       i = sentence.begin();
-                               }
-                       }
+                               i = sentence.erase(i);
                        else
                                ++i;
                }
index dc53f2f0c22d74baa3584a1719108d747914c3e1..a98c06c7509d8dedd3904a7ef994a21744abe130 100644 (file)
@@ -90,7 +90,7 @@ class ModuleSWhois : public Module
        ModuleSWhois() : cmd(this)
        {
                ServerInstance->AddCommand(&cmd);
-               Implementation eventlist[] = { I_OnWhoisLine, I_OnPostCommand };
+               Implementation eventlist[] = { I_OnWhoisLine, I_OnPostOper };
                ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
@@ -112,11 +112,10 @@ class ModuleSWhois : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       void OnPostCommand(const std::string &command, const std::vector<std::string> &params, LocalUser *user, CmdResult result, const std::string &original_line)
+       void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
        {
-               if ((command != "OPER") || (result != CMD_SUCCESS))
+               if (!IS_LOCAL(user))
                        return;
-               ConfigReader Conf;
 
                std::string swhois = user->oper->getConfig("swhois");
 
index 365602b7ebe937518777eb853fcf8dfa43ce2991..683c14afa408fedf96fcdd82ddad23d8dc4a37fc 100644 (file)
@@ -235,6 +235,8 @@ class ModuleXLineDB : public Module
                                {
                                        ServerInstance->SNO->WriteToSnoMask('x', "database: Added a line of type %s", command_p[1].c_str());
                                }
+                               else
+                                       delete xl;
                        }
                }
 
index adaaa7d2cbeb767644704f712b70c7a06b013271..4bd81a6d1ba970bd09b3f4b24d5fd64bc6d64998 100644 (file)
@@ -86,7 +86,7 @@ void InspIRCd::BuildISupport()
        std::stringstream v;
        v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax;
        v << " CASEMAPPING=rfc1459 STATUSMSG=" << Modes->BuildPrefixes(false) << " CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic << " KICKLEN=" << Config->Limits.MaxKick << " MAXTARGETS=" << Config->MaxTargets;
-       v << " AWAYLEN=" << Config->Limits.MaxAway << " CHANMODES=" << this->Modes->GiveModeList(MASK_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
+       v << " AWAYLEN=" << Config->Limits.MaxAway << " CHANMODES=" << this->Modes->GiveModeList(MASK_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU" << " CHANNELLEN=" << Config->Limits.ChanMax;
        Config->data005 = v.str();
        FOREACH_MOD(I_On005Numeric,On005Numeric(Config->data005));
        Config->Update005();
index 648ad3ac103007923b89e46cf38fad3e1db7be68..5fc645bb10270e1ea43edc69a39d68fbfaac0b94 100644 (file)
@@ -47,7 +47,6 @@ private:
        port_event_t* events;
 public:
        /** Create a new PortsEngine
-        * @param Instance The creator of this object
         */
        PortsEngine();
        /** Delete a PortsEngine
diff --git a/src/stats.cpp b/src/stats.cpp
deleted file mode 100644 (file)
index e5ea94b..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@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"
-#include "xline.h"
-#include "commands/cmd_whowas.h"
-
-void InspIRCd::DoStats(char statschar, User* user, string_list &results)
-{
-       std::string sn(this->Config->ServerName);
-
-       bool isPublic = Config->UserStats.find(statschar) != std::string::npos;
-       bool isRemoteOper = IS_REMOTE(user) && IS_OPER(user);
-       bool isLocalOperWithPrivs = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex");
-
-       if (!isPublic && !isRemoteOper && !isLocalOperWithPrivs)
-       {
-               this->SNO->WriteToSnoMask('t',
-                               "%s '%c' denied for %s (%s@%s)",
-                               (IS_LOCAL(user) ? "Stats" : "Remote stats"),
-                               statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
-               results.push_back(sn + " 481 " + user->nick + " :Permission denied - STATS " + statschar + " requires the servers/auspex priv.");
-               return;
-       }
-
-       ModResult MOD_RESULT;
-       FIRST_MOD_RESULT(OnStats, MOD_RESULT, (statschar, user, results));
-       if (MOD_RESULT == MOD_RES_DENY)
-       {
-               results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
-               this->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
-                       (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
-               return;
-       }
-
-       switch (statschar)
-       {
-               /* stats p (show listening ports) */
-               case 'p':
-               {
-                       for (size_t i = 0; i < this->ports.size(); i++)
-                       {
-                               std::string ip = this->ports[i]->bind_addr;
-                               if (ip.empty())
-                                       ip.assign("*");
-                               std::string type = ports[i]->bind_tag->getString("type", "clients");
-                               std::string hook = ports[i]->bind_tag->getString("ssl", "plaintext");
-
-                               results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ports[i]->bind_port)+
-                                       " (" + type + ", " + hook + ")");
-                       }
-               }
-               break;
-
-               /* These stats symbols must be handled by a linking module */
-               case 'n':
-               case 'c':
-               break;
-
-               case 'i':
-               {
-                       for (ClassVector::iterator i = this->Config->Classes.begin(); i != this->Config->Classes.end(); i++)
-                       {
-                               ConnectClass* c = *i;
-                               std::stringstream res;
-                               res << sn << " 215 " << user->nick << " I " << c->name << ' ';
-                               if (c->type == CC_ALLOW)
-                                       res << '+';
-                               if (c->type == CC_DENY)
-                                       res << '-';
-
-                               if (c->type == CC_NAMED)
-                                       res << '*';
-                               else
-                                       res << c->host;
-
-                               res << ' ' << c->config->getString("port", "*") << ' ';
-
-                               res << c->GetRecvqMax() << ' ' << c->GetSendqSoftMax() << ' ' << c->GetSendqHardMax()
-                                       << ' ' << c->GetCommandRate() << ' ' << c->GetPenaltyThreshold();
-                               if (c->fakelag)
-                                       res << '*';
-                               results.push_back(res.str());
-                       }
-               }
-               break;
-
-               case 'Y':
-               {
-                       int idx = 0;
-                       for (ClassVector::iterator i = this->Config->Classes.begin(); i != this->Config->Classes.end(); i++)
-                       {
-                               ConnectClass* c = *i;
-                               results.push_back(sn+" 215 "+user->nick+" i NOMATCH * "+c->GetHost()+" "+ConvToStr(c->limit ? c->limit : this->SE->GetMaxFds())+" "+ConvToStr(idx)+" "+this->Config->ServerName+" *");
-                               results.push_back(sn+" 218 "+user->nick+" Y "+ConvToStr(idx)+" "+ConvToStr(c->GetPingTime())+" 0 "+ConvToStr(c->GetSendqHardMax())+" :"+
-                                               ConvToStr(c->GetRecvqMax())+" "+ConvToStr(c->GetRegTimeout()));
-                               idx++;
-                       }
-               }
-               break;
-
-               case 'U':
-               {
-                       for(std::map<irc::string, bool>::iterator i = Config->ulines.begin(); i != Config->ulines.end(); ++i)
-                       {
-                               results.push_back(sn+" 248 "+user->nick+" U "+std::string(i->first.c_str()));
-                       }
-               }
-               break;
-
-               case 'P':
-               {
-                       int idx = 0;
-                       for (user_hash::iterator i = this->Users->clientlist->begin(); i != this->Users->clientlist->end(); i++)
-                       {
-                               if (IS_OPER(i->second) && !this->ULine(i->second->server))
-                               {
-                                       results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+
-                                                       (IS_LOCAL(i->second) ? ConvToStr(this->Time() - i->second->idle_lastmsg) + " secs" : "unavailable"));
-                                       idx++;
-                               }
-                       }
-                       results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(idx)+" OPER(s)");
-               }
-               break;
-
-               case 'k':
-                       this->XLines->InvokeStats("K",216,user,results);
-               break;
-               case 'g':
-                       this->XLines->InvokeStats("G",223,user,results);
-               break;
-               case 'q':
-                       this->XLines->InvokeStats("Q",217,user,results);
-               break;
-               case 'Z':
-                       this->XLines->InvokeStats("Z",223,user,results);
-               break;
-               case 'e':
-                       this->XLines->InvokeStats("E",223,user,results);
-               break;
-               case 'E':
-                       results.push_back(sn+" 249 "+user->nick+" :Total events: "+ConvToStr(this->SE->TotalEvents));
-                       results.push_back(sn+" 249 "+user->nick+" :Read events:  "+ConvToStr(this->SE->ReadEvents));
-                       results.push_back(sn+" 249 "+user->nick+" :Write events: "+ConvToStr(this->SE->WriteEvents));
-                       results.push_back(sn+" 249 "+user->nick+" :Error events: "+ConvToStr(this->SE->ErrorEvents));
-               break;
-
-               /* stats m (list number of times each command has been used, plus bytecount) */
-               case 'm':
-                       for (Commandtable::iterator i = this->Parser->cmdlist.begin(); i != this->Parser->cmdlist.end(); i++)
-                       {
-                               if (i->second->use_count)
-                               {
-                                       /* RPL_STATSCOMMANDS */
-                                       results.push_back(sn+" 212 "+user->nick+" "+i->second->name+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes));
-                               }
-                       }
-               break;
-
-               /* stats z (debug and memory info) */
-               case 'z':
-               {
-                       results.push_back(sn+" 249 "+user->nick+" :Users: "+ConvToStr(this->Users->clientlist->size()));
-                       results.push_back(sn+" 249 "+user->nick+" :Channels: "+ConvToStr(this->chanlist->size()));
-                       results.push_back(sn+" 249 "+user->nick+" :Commands: "+ConvToStr(this->Parser->cmdlist.size()));
-
-                       if (!this->Config->WhoWasGroupSize == 0 && !this->Config->WhoWasMaxGroups == 0)
-                       {
-                               Module* whowas = Modules->Find("cmd_whowas.so");
-                               if (whowas)
-                               {
-                                       WhowasRequest req(NULL, whowas, WhowasRequest::WHOWAS_STATS);
-                                       req.user = user;
-                                       req.Send();
-                                       results.push_back(sn+" 249 "+user->nick+" :"+req.value);
-                               }
-                       }
-
-                       float kbitpersec_in, kbitpersec_out, kbitpersec_total;
-                       char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30];
-
-                       this->SE->GetStats(kbitpersec_in, kbitpersec_out, kbitpersec_total);
-
-                       snprintf(kbitpersec_total_s, 30, "%03.5f", kbitpersec_total);
-                       snprintf(kbitpersec_out_s, 30, "%03.5f", kbitpersec_out);
-                       snprintf(kbitpersec_in_s, 30, "%03.5f", kbitpersec_in);
-
-                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth total:  "+ConvToStr(kbitpersec_total_s)+" kilobits/sec");
-                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth out:    "+ConvToStr(kbitpersec_out_s)+" kilobits/sec");
-                       results.push_back(sn+" 249 "+user->nick+" :Bandwidth in:     "+ConvToStr(kbitpersec_in_s)+" kilobits/sec");
-
-#ifndef WIN32
-                       /* Moved this down here so all the not-windows stuff (look w00tie, I didn't say win32!) is in one ifndef.
-                        * Also cuts out some identical code in both branches of the ifndef. -- Om
-                        */
-                       rusage R;
-
-                       /* Not sure why we were doing '0' with a RUSAGE_SELF comment rather than just using RUSAGE_SELF -- Om */
-                       if (!getrusage(RUSAGE_SELF,&R)) /* RUSAGE_SELF */
-                       {
-                               results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
-                               results.push_back(sn+" 249 "+user->nick+" :Signals:          "+ConvToStr(R.ru_nsignals));
-                               results.push_back(sn+" 249 "+user->nick+" :Page faults:      "+ConvToStr(R.ru_majflt));
-                               results.push_back(sn+" 249 "+user->nick+" :Swaps:            "+ConvToStr(R.ru_nswap));
-                               results.push_back(sn+" 249 "+user->nick+" :Context Switches: Voluntary; "+ConvToStr(R.ru_nvcsw)+" Involuntary; "+ConvToStr(R.ru_nivcsw));
-
-                               char percent[30];
-
-                               float n_elapsed = (ServerInstance->Time() - this->stats->LastSampled.tv_sec) * 1000000
-                                       + (ServerInstance->Time_ns() - this->stats->LastSampled.tv_nsec) / 1000;
-                               float n_eaten = ((R.ru_utime.tv_sec - this->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - this->stats->LastCPU.tv_usec);
-                               float per = (n_eaten / n_elapsed) * 100;
-
-                               snprintf(percent, 30, "%03.5f%%", per);
-                               results.push_back(sn+" 249 "+user->nick+" :CPU Use (now):    "+percent);
-
-                               n_elapsed = ServerInstance->Time() - ServerInstance->startup_time;
-                               n_eaten = (float)R.ru_utime.tv_sec + R.ru_utime.tv_usec / 100000.0;
-                               per = (n_eaten / n_elapsed) * 100;
-                               snprintf(percent, 30, "%03.5f%%", per);
-                               results.push_back(sn+" 249 "+user->nick+" :CPU Use (total):  "+percent);
-                       }
-#else
-                       PROCESS_MEMORY_COUNTERS MemCounters;
-                       if (GetProcessMemoryInfo(GetCurrentProcess(), &MemCounters, sizeof(MemCounters)))
-                       {
-                               results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr((MemCounters.WorkingSetSize + MemCounters.PagefileUsage) / 1024)+"K");
-                               results.push_back(sn+" 249 "+user->nick+" :Pagefile usage:   "+ConvToStr(MemCounters.PagefileUsage / 1024)+"K");
-                               results.push_back(sn+" 249 "+user->nick+" :Page faults:      "+ConvToStr(MemCounters.PageFaultCount));
-                               results.push_back(sn+" 249 "+user->nick+" :CPU Usage: " + ConvToStr(getcpu()) + "%");
-                       }
-#endif
-               }
-               break;
-
-               case 'T':
-               {
-                       char buffer[MAXBUF];
-                       results.push_back(sn+" 249 "+user->nick+" :accepts "+ConvToStr(this->stats->statsAccept)+" refused "+ConvToStr(this->stats->statsRefused));
-                       results.push_back(sn+" 249 "+user->nick+" :unknown commands "+ConvToStr(this->stats->statsUnknown));
-                       results.push_back(sn+" 249 "+user->nick+" :nick collisions "+ConvToStr(this->stats->statsCollisions));
-                       results.push_back(sn+" 249 "+user->nick+" :dns requests "+ConvToStr(this->stats->statsDnsGood+this->stats->statsDnsBad)+" succeeded "+ConvToStr(this->stats->statsDnsGood)+" failed "+ConvToStr(this->stats->statsDnsBad));
-                       results.push_back(sn+" 249 "+user->nick+" :connection count "+ConvToStr(this->stats->statsConnects));
-                       snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",
-                               user->nick.c_str(),this->stats->statsSent / 1024.0,this->stats->statsRecv / 1024.0);
-                       results.push_back(sn+buffer);
-               }
-               break;
-
-               /* stats o */
-               case 'o':
-               {
-                       ConfigTagList tags = ServerInstance->Config->ConfTags("oper");
-                       for(ConfigIter i = tags.first; i != tags.second; ++i)
-                       {
-                               ConfigTag* tag = i->second;
-                               results.push_back(sn+" 243 "+user->nick+" O "+tag->getString("host")+" * "+
-                                       tag->getString("name") + " " + tag->getString("type")+" 0");
-                       }
-               }
-               break;
-               case 'O':
-               {
-                       for(OperIndex::iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); i++)
-                       {
-                               // just the types, not the actual oper blocks...
-                               if (i->first[0] != ' ')
-                                       continue;
-                               OperInfo* tag = i->second;
-                               tag->init();
-                               std::string umodes;
-                               std::string cmodes;
-                               for(char c='A'; c < 'z'; c++)
-                               {
-                                       ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
-                                       if (mh && mh->NeedsOper() && tag->AllowedUserModes[c - 'A'])
-                                               umodes.push_back(c);
-                                       mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
-                                       if (mh && mh->NeedsOper() && tag->AllowedChanModes[c - 'A'])
-                                               cmodes.push_back(c);
-                               }
-                               results.push_back(sn+" 243 "+user->nick+" O "+tag->NameStr() + " " + umodes + " " + cmodes);
-                       }
-               }
-               break;
-
-               /* stats l (show user I/O stats) */
-               case 'l':
-                       results.push_back(sn+" 211 "+user->nick+" :nick[ident@host] sendq cmds_out bytes_out cmds_in bytes_in time_open");
-                       for (std::vector<LocalUser*>::iterator n = this->Users->local_users.begin(); n != this->Users->local_users.end(); n++)
-                       {
-                               LocalUser* i = *n;
-                               results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(this->Time() - i->age));
-                       }
-               break;
-
-               /* stats L (show user I/O stats with IP addresses) */
-               case 'L':
-                       results.push_back(sn+" 211 "+user->nick+" :nick[ident@ip] sendq cmds_out bytes_out cmds_in bytes_in time_open");
-                       for (std::vector<LocalUser*>::iterator n = this->Users->local_users.begin(); n != this->Users->local_users.end(); n++)
-                       {
-                               LocalUser* i = *n;
-                               results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(this->Time() - i->age));
-                       }
-               break;
-
-               /* stats u (show server uptime) */
-               case 'u':
-               {
-                       time_t current_time = 0;
-                       current_time = this->Time();
-                       time_t server_uptime = current_time - this->startup_time;
-                       struct tm* stime;
-                       stime = gmtime(&server_uptime);
-                       /* i dont know who the hell would have an ircd running for over a year nonstop, but
-                        * Craig suggested this, and it seemed a good idea so in it went */
-                       if (stime->tm_year > 70)
-                       {
-                               char buffer[MAXBUF];
-                               snprintf(buffer,MAXBUF," 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick.c_str(),(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
-                               results.push_back(sn+buffer);
-                       }
-                       else
-                       {
-                               char buffer[MAXBUF];
-                               snprintf(buffer,MAXBUF," 242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick.c_str(),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
-                               results.push_back(sn+buffer);
-                       }
-               }
-               break;
-
-               default:
-               break;
-       }
-
-       results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
-       this->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
-               (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
-       return;
-}
index 7da57646fa207b36895c3d350eb3f4dd8197231b..785d23625d83d6bf4a42c403e777dd6595636b56 100644 (file)
@@ -37,7 +37,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        }
        catch (...)
        {
-               ServerInstance->Logs->Log("USERS", DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed.");
+               ServerInstance->Logs->Log("USERS", DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkeys have been unleashed.");
                ServerInstance->SNO->WriteToSnoMask('a', "WARNING *** Duplicate UUID allocated!");
                return;
        }
index 39be8127227195af848f68d261db67adb27c1bf8..9c3d645f72c0a64b2ea6491269fedc18a32724db 100644 (file)
@@ -224,8 +224,7 @@ LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::so
 {
        lastping = 0;
        eh.SetFd(myfd);
-
-       SetClientIP(client);
+       memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
        memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
 }
 
@@ -333,75 +332,45 @@ const std::string& User::GetFullRealHost()
 
 bool LocalUser::IsInvited(const irc::string &channel)
 {
-       time_t now = ServerInstance->Time();
-       InvitedList::iterator safei;
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (channel == i->first)
-               {
-                       if (i->second != 0 && now > i->second)
-                       {
-                               /* Expired invite, remove it. */
-                               safei = i;
-                               --i;
-                               invites.erase(safei);
-                               continue;
-                       }
-                       return true;
-               }
-       }
-       return false;
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (!chan)
+               return false;
+
+       return (Invitation::Find(chan, this) != NULL);
 }
 
-InvitedList* LocalUser::GetInviteList()
+InviteList& LocalUser::GetInviteList()
 {
-       time_t now = ServerInstance->Time();
-       /* Weed out expired invites here. */
-       InvitedList::iterator safei;
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (i->second != 0 && now > i->second)
-               {
-                       /* Expired invite, remove it. */
-                       safei = i;
-                       --i;
-                       invites.erase(safei);
-               }
-       }
-       return &invites;
+       RemoveExpiredInvites();
+       return invites;
 }
 
 void LocalUser::InviteTo(const irc::string &channel, time_t invtimeout)
 {
-       time_t now = ServerInstance->Time();
-       if (invtimeout != 0 && now > invtimeout) return; /* Don't add invites that are expired from the get-go. */
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (channel == i->first)
-               {
-                       if (i->second != 0 && invtimeout > i->second)
-                       {
-                               i->second = invtimeout;
-                       }
-
-                       return;
-               }
-       }
-       invites.push_back(std::make_pair(channel, invtimeout));
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (chan)
+               Invitation::Create(chan, this, invtimeout);
 }
 
 void LocalUser::RemoveInvite(const irc::string &channel)
 {
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (chan)
        {
-               if (channel == i->first)
+               Invitation* inv = Invitation::Find(chan, this);
+               if (inv)
                {
-                       invites.erase(i);
-                       return;
-               }
+                       inv->cull();
+                       delete inv;
+               }
        }
 }
 
+void LocalUser::RemoveExpiredInvites()
+{
+       Invitation::Find(NULL, this);
+}
+
 bool User::HasModePermission(unsigned char, ModeType)
 {
        return true;
@@ -560,8 +529,6 @@ CullResult User::cull()
                ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
        PurgeEmptyChannels();
 
-       this->InvalidateCache();
-
        if (client_sa.sa.sa_family != AF_UNSPEC)
                ServerInstance->Users->RemoveCloneCounts(this);
 
@@ -576,6 +543,7 @@ CullResult LocalUser::cull()
        else
                ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
 
+       ClearInvites();
        eh.cull();
        return User::cull();
 }
@@ -1009,24 +977,10 @@ irc::sockets::cidr_mask User::GetCIDRMask()
        return irc::sockets::cidr_mask(client_sa, range);
 }
 
-bool User::SetClientIP(irc::sockets::sockaddrs *sa)
-{
-       memcpy(&client_sa, sa, sizeof(irc::sockets::sockaddrs));
-
-       FOREACH_MOD(I_OnSetClientIP, OnSetClientIP(this));
-
-       return true;
-}
-
 bool User::SetClientIP(const char* sip)
 {
-       irc::sockets::sockaddrs sa;
-
        this->cachedip = "";
-       if (!irc::sockets::aptosa(sip, 0, sa))
-               return false;
-
-       return SetClientIP(&sa);
+       return irc::sockets::aptosa(sip, 0, client_sa);
 }
 
 static std::string wide_newline("\r\n");
index ce9cc035dedde8f5f752cf1c8bbfcc7a9c2c46a2..08ee179047b591e1aa627cce0052c0188ba14fbd 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "InspIRCd-2.0.5"
+echo "InspIRCd-2.0.8"
index 78f73ef0919e4817fd1711169415145edb2808f2..1fa21c6f931fba52c3c97a03fcee93274640021f 100644 (file)
@@ -152,7 +152,11 @@ SectionEnd
 
 Section "Config Files" SEC02
   SetOutPath "$INSTDIR\conf"
-  File "..\docs\*.example"
+  File "..\docs\conf\*.example"
+  SetOutPath "$INSTDIR\conf\aliases"
+  File "..\docs\conf\aliases\*.example"
+  SetOutPath "$INSTDIR\conf\modules"
+  File "..\docs\conf\modules\modules.*"
 SectionEnd
 
 Section "Command Handlers" SEC03
@@ -163,6 +167,10 @@ SectionEnd
 Section "Modules" SEC04
   SetOutPath "$INSTDIR\modules"
   File "..\bin\${BUILD}\modules\m_*.so"
+  ; Copy DLLs required for modules
+  SetOutPath "$INSTDIR"
+  File /nonfatal "*.dll"
+  File "make_gnutls_cert.bat"
 SectionEnd
 
 Section -AdditionalIcons
@@ -216,9 +224,13 @@ Section Uninstall
   Delete "$INSTDIR\uninst.exe"
   Delete "$INSTDIR\modules\*.so"
   Delete "$INSTDIR\conf\*.example"
+  Delete "$INSTDIR\conf\aliases\*.example"
+  Delete "$INSTDIR\conf\modules\*.example"
   Delete "$INSTDIR\*.log"
   Delete "$INSTDIR\logs\*"
   Delete "$INSTDIR\data\*"
+  Delete "$INSTDIR\*.dll"
+  Delete "$INSTDIR\make_gnutls_cert.bat"
   Delete "$INSTDIR\inspircd.exe"
   Delete "$SMPROGRAMS\InspIRCd\Uninstall.lnk"
   Delete "$SMPROGRAMS\InspIRCd\InspIRCd Website.lnk"
index e77a918a0f9cb7ec48a978a2fbb9783b488b7610..03bacaad3a69c041c450ab3032c452d7fc3edf38 100644 (file)
@@ -268,7 +268,6 @@ nmake -f modules.mak
   <ItemGroup>
     <ClCompile Include="..\src\bancache.cpp" />
     <ClCompile Include="..\src\base.cpp" />
-    <ClCompile Include="..\src\channelmanager.cpp" />
     <ClCompile Include="..\src\channels.cpp" />
     <ClCompile Include="..\src\cidr.cpp" />
     <ClCompile Include="..\src\commands.cpp" />
@@ -335,7 +334,6 @@ nmake -f modules.mak
     <ClInclude Include="..\include\bancache.h" />
     <ClInclude Include="..\include\base.h" />
     <ClInclude Include="..\include\caller.h" />
-    <ClInclude Include="..\include\channelmanager.h" />
     <ClInclude Include="..\include\channels.h" />
     <ClInclude Include="..\include\command_parse.h" />
     <ClInclude Include="..\include\configreader.h" />
index 85572fd64fdd6595768b073e8910d82808bf4b3e..bc716526273cae05a19ee26d09b75d1ecfd4dfab 100644 (file)
@@ -231,7 +231,6 @@ CoreExport int clock_gettime(int clock, struct timespec * tv);
 typedef unsigned char uint8_t;
 typedef unsigned long long uint64_t;
 typedef signed char int8_t;
-typedef signed long int32_t;
 typedef signed long long int64_t;
 typedef signed long ssize_t;
 
diff --git a/win/make_gnutls_cert.bat b/win/make_gnutls_cert.bat
new file mode 100644 (file)
index 0000000..97792cc
--- /dev/null
@@ -0,0 +1,14 @@
+@echo off\r
+\r
+echo This program will generate SSL certificates for m_ssl_gnutls.so\r
+echo Ensure certtool.exe is in your system path. It can be downloaded\r
+echo at ftp://ftp.gnu.org/gnu/gnutls/w32/. If you do not know the answer\r
+echo to one of the questions just press enter.\r
+echo.\r
+\r
+pause\r
+\r
+certtool --generate-privkey --outfile conf/key.pem\r
+certtool --generate-self-signed --load-privkey conf/key.pem --outfile conf/cert.pem\r
+\r
+pause
\ No newline at end of file