summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/CMakeLists.txt26
-rw-r--r--include/access.h19
-rw-r--r--include/account.h129
-rw-r--r--include/anope.h288
-rw-r--r--include/base.h106
-rw-r--r--include/bots.h11
-rw-r--r--include/botserv.h79
-rw-r--r--include/channels.h22
-rw-r--r--include/commands.h7
-rw-r--r--include/config.h51
-rw-r--r--include/defs.h52
-rw-r--r--include/dns.h21
-rw-r--r--include/extensible.h3
-rw-r--r--include/extern.h98
-rw-r--r--include/hashcomp.h15
-rw-r--r--include/lists.h94
-rw-r--r--include/logger.h16
-rw-r--r--include/mail.h15
-rw-r--r--include/memo.h63
-rw-r--r--include/modes.h57
-rw-r--r--include/module.h52
-rw-r--r--include/modules.h136
-rw-r--r--include/oper.h4
-rw-r--r--include/opertype.h5
-rw-r--r--include/protocol.h155
-rw-r--r--include/regchannel.h31
-rw-r--r--include/serialize.h162
-rw-r--r--include/servers.h3
-rw-r--r--include/service.h110
-rw-r--r--include/services.h913
-rw-r--r--include/signals.h49
-rw-r--r--include/socketengine.h2
-rw-r--r--include/sockets.h12
-rw-r--r--include/threadengine.h3
-rw-r--r--include/timers.h10
-rw-r--r--include/uplink.h44
-rw-r--r--include/users.h24
-rw-r--r--modules/commands/hs_del.cpp4
-rw-r--r--modules/commands/hs_group.cpp12
-rw-r--r--modules/commands/hs_list.cpp24
-rw-r--r--modules/commands/hs_off.cpp2
-rw-r--r--modules/commands/hs_on.cpp18
-rw-r--r--modules/commands/hs_request.cpp2
-rw-r--r--modules/commands/hs_set.cpp8
-rw-r--r--modules/commands/ms_ignore.cpp1
-rw-r--r--modules/commands/ns_info.cpp8
-rw-r--r--modules/commands/os_forbid.cpp2
-rw-r--r--modules/commands/os_list.cpp2
-rw-r--r--modules/commands/os_session.cpp2
-rw-r--r--modules/commands/os_session.h8
-rw-r--r--modules/database/db_old.cpp2
-rw-r--r--modules/database/db_plain.cpp6
-rw-r--r--modules/extra/m_dnsbl.cpp18
-rw-r--r--modules/extra/m_proxyscan.cpp7
-rw-r--r--modules/extra/m_ssl.cpp1
-rw-r--r--modules/extra/m_xmlrpc.cpp1
-rw-r--r--modules/extra/m_xmlrpc_main.cpp4
-rw-r--r--modules/protocol/bahamut.cpp5
-rw-r--r--modules/protocol/inspircd11.cpp5
-rw-r--r--modules/protocol/inspircd12.cpp5
-rw-r--r--modules/protocol/inspircd20.cpp5
-rw-r--r--modules/protocol/plexus.cpp5
-rw-r--r--modules/protocol/ratbox.cpp5
-rw-r--r--modules/protocol/unreal.cpp5
-rw-r--r--modules/pseudoclients/hostserv.cpp27
-rw-r--r--modules/pseudoclients/nickserv.cpp54
-rw-r--r--modules/pseudoclients/operserv.cpp4
-rw-r--r--src/access.cpp7
-rw-r--r--src/actions.cpp4
-rw-r--r--src/base.cpp8
-rw-r--r--src/base64.cpp1
-rw-r--r--src/bots.cpp11
-rw-r--r--src/botserv.cpp9
-rw-r--r--src/channels.cpp84
-rw-r--r--src/chanserv.cpp35
-rw-r--r--src/command.cpp6
-rw-r--r--src/config.cpp9
-rw-r--r--src/configreader.cpp1
-rw-r--r--src/dns.cpp33
-rw-r--r--src/hashcomp.cpp2
-rw-r--r--src/hostserv.cpp79
-rw-r--r--src/init.cpp15
-rw-r--r--src/language.cpp17
-rw-r--r--src/logger.cpp11
-rw-r--r--src/mail.cpp14
-rw-r--r--src/main.cpp26
-rw-r--r--src/memoserv.cpp5
-rw-r--r--src/messages.cpp6
-rw-r--r--src/misc.cpp13
-rw-r--r--src/modes.cpp23
-rw-r--r--src/module.cpp14
-rw-r--r--src/modulemanager.cpp13
-rw-r--r--src/modules.cpp13
-rw-r--r--src/nickalias.cpp151
-rw-r--r--src/nickcore.cpp13
-rw-r--r--src/nickserv.cpp87
-rw-r--r--src/operserv.cpp16
-rw-r--r--src/opertype.cpp4
-rw-r--r--src/process.cpp1
-rw-r--r--src/protocol.cpp19
-rw-r--r--src/regchannel.cpp11
-rw-r--r--src/serialize.cpp138
-rw-r--r--src/servers.cpp7
-rw-r--r--src/socket_clients.cpp5
-rw-r--r--src/socket_transport.cpp2
-rw-r--r--src/socketengines/pipeengine_eventfd.cpp13
-rw-r--r--src/socketengines/pipeengine_pipe.cpp16
-rw-r--r--src/socketengines/socketengine_epoll.cpp19
-rw-r--r--src/socketengines/socketengine_kqueue.cpp19
-rw-r--r--src/socketengines/socketengine_poll.cpp20
-rw-r--r--src/socketengines/socketengine_select.cpp18
-rw-r--r--src/sockets.cpp27
-rw-r--r--src/threadengine.cpp15
-rw-r--r--src/timers.cpp2
-rw-r--r--src/users.cpp29
-rw-r--r--src/win32/pipe/pipe.cpp4
-rw-r--r--src/win32/resource.h (renamed from include/resource.h)0
117 files changed, 2415 insertions, 1819 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index c7d5456c7..5579fdf30 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -20,11 +20,24 @@ endif(NOT WIN32)
set(PCH_SOURCES_GCH "")
if(CMAKE_COMPILER_IS_GNUCXX)
string(REPLACE " " ";" PCH_CXXFLAGS ${CXXFLAGS})
- file(GLOB INCLUDE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
- remove_item_from_list(INCLUDE_SRCS "version.h")
- set(PCH_SOURCES "module.h;modules.h;services.h")
+ file(GLOB PCH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
+ sort_list(PCH_SOURCES)
+
foreach(PCH_SOURCE ${PCH_SOURCES})
+ find_includes(${PCH_SOURCE} INCLUDES)
+ set(INCLUDES_LIST)
+ foreach(INCLUDE ${INCLUDES})
+ # Extract the filename from the #include line
+ extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
+ if(QUOTE_TYPE STREQUAL "quotes")
+ find_in_list(PCH_SOURCES "${FILENAME}" FOUND)
+ if(NOT FOUND EQUAL -1)
+ append_to_list(INCLUDES_LIST ${FILENAME})
+ endif(NOT FOUND EQUAL -1)
+ endif(QUOTE_TYPE STREQUAL "quotes")
+ endforeach(INCLUDE)
+
set(PCH_EXTRAFLAGS "")
if(DEBUG_BUILD)
set(PCH_EXTRAFLAGS "-g")
@@ -33,13 +46,14 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
endif(PCH_SOURCE STREQUAL "module.h")
if(GETTEXT_INCLUDE)
- set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
+ set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
endif(GETTEXT_INCLUDE)
set(PCH_SOURCES_GCH "${PCH_SOURCES_GCH};${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS} ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- DEPENDS ${INCLUDE_SRCS} VERBATIM
+ COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS}
+ ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} -I${Anope_SOURCE_DIR}/modules/pseudoclients ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
+ DEPENDS ${INCLUDES_LIST} VERBATIM
)
endforeach(PCH_SOURCE ${PCH_SOURCES})
endif(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/include/access.h b/include/access.h
index 8b380895d..e19c15a76 100644
--- a/include/access.h
+++ b/include/access.h
@@ -1,6 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef ACCESS_H
#define ACCESS_H
+#include "services.h"
+#include "anope.h"
+#include "serialize.h"
+#include "service.h"
+
enum
{
ACCESS_INVALID = -10000,
@@ -28,7 +46,6 @@ class CoreExport PrivilegeManager
static void ClearPrivileges();
};
-class ChanAccess;
class CoreExport AccessProvider : public Service
{
diff --git a/include/account.h b/include/account.h
index 516bcace5..ffdc7b18f 100644
--- a/include/account.h
+++ b/include/account.h
@@ -1,10 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef ACCOUNT_H
#define ACCOUNT_H
+#include "extensible.h"
+#include "serialize.h"
#include "anope.h"
-
-class NickAlias;
-class NickCore;
+#include "memo.h"
+#include "base.h"
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
typedef Anope::insensitive_map<NickCore *> nickcore_map;
@@ -93,8 +107,11 @@ const Anope::string NickCoreFlagStrings[] = {
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", ""
};
-class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
+class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
{
+ Anope::string vhost_ident, vhost_host, vhost_creator;
+ time_t vhost_created;
+
public:
/** Default constructor
* @param nickname The nick
@@ -114,7 +131,6 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
time_t time_registered; /* When the nick was registered */
time_t last_seen; /* When it was seen online for the last time */
NickCore *nc; /* I'm an alias of this */
- HostInfo hostinfo;
Anope::string serialize_name() const;
serialized_data serialize();
@@ -131,9 +147,46 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
* @param u The user
*/
void OnCancel(User *u);
+
+ /** Set a vhost for the user
+ * @param ident The ident
+ * @param host The host
+ * @param creator Who created the vhost
+ * @param time When the vhost was craated
+ */
+ void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
+
+ /** Remove a users vhost
+ **/
+ void RemoveVhost();
+
+ /** Check if the user has a vhost
+ * @return true or false
+ */
+ bool HasVhost() const;
+
+ /** Retrieve the vhost ident
+ * @return the ident
+ */
+ const Anope::string &GetVhostIdent() const;
+
+ /** Retrieve the vhost host
+ * @return the host
+ */
+ const Anope::string &GetVhostHost() const;
+
+ /** Retrieve the vhost creator
+ * @return the creator
+ */
+ const Anope::string &GetVhostCreator() const;
+
+ /** Retrieve when the vhost was created
+ * @return the time it was created
+ */
+ time_t GetVhostCreated() const;
};
-class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
+class CoreExport NickCore : public Base, public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
{
public:
/** Default constructor
@@ -254,65 +307,11 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
};
-/** Timer for colliding nicks to force people off of nicknames
- */
-class CoreExport NickServCollide : public Timer
-{
- dynamic_reference<User> u;
- Anope::string nick;
-
- public:
- /** Default constructor
- * @param nick The nick we're colliding
- * @param delay How long to delay before kicking the user off the nick
- */
- NickServCollide(User *user, time_t delay);
-
- /** Default destructor
- */
- virtual ~NickServCollide();
-
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t);
-};
-
-/** Timers for removing HELD status from nicks.
- */
-class NickServHeld : public Timer
-{
- dynamic_reference<NickAlias> na;
- Anope::string nick;
- public:
- NickServHeld(NickAlias *n, long t);
-
- ~NickServHeld();
-
- void Tick(time_t);
-};
-
-/** Timers for releasing nicks to be available for use
- */
-class CoreExport NickServRelease : public User, public Timer
-{
- Anope::string nick;
-
- public:
- /** Default constructor
- * @param na The nick
- * @param delay The delay before the nick is released
- */
- NickServRelease(NickAlias *na, time_t delay);
-
- /** Default destructor
- */
- virtual ~NickServRelease();
+extern void change_core_display(NickCore *nc);
+extern void change_core_display(NickCore *nc, const Anope::string &newdisplay);
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t);
-};
+extern NickAlias *findnick(const Anope::string &nick);
+extern NickCore *findcore(const Anope::string &nick);
+extern bool is_on_access(const User *u, const NickCore *nc);
#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index ac7aa0740..992662650 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -11,13 +11,8 @@
#ifndef ANOPE_H
#define ANOPE_H
-#include <string>
-#include <vector>
-#include <set>
#include "hashcomp.h"
-class Message;
-
namespace Anope
{
template<typename T> class map : public std::map<string, T> { };
@@ -353,7 +348,7 @@ namespace Anope
* @param mask The pattern to check (e.g. foo*bar)
* @param case_sensitive Whether or not the match is case sensitive, default false.
*/
- extern CoreExport bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false);
+ extern CoreExport bool Match(const string &str, const string &mask, bool case_sensitive = false);
/** Find a message in the message table
* @param name The name of the message were looking for
@@ -372,20 +367,20 @@ namespace Anope
* @param src The data to be converted
* @param dest The destination string
*/
- extern CoreExport void Unhex(const Anope::string &src, Anope::string &dest);
- extern CoreExport void Unhex(const Anope::string &src, char *dest);
+ extern CoreExport void Unhex(const string &src, string &dest);
+ extern CoreExport void Unhex(const string &src, char *dest);
/** Base 64 encode a string
* @param src The string to encode
* @param target Where the encoded string is placed
*/
- extern CoreExport void B64Encode(const Anope::string &src, Anope::string &target);
+ extern CoreExport void B64Encode(const string &src, string &target);
/** Base 64 decode a string
* @param src The base64 encoded string
* @param target The plain text result
*/
- extern CoreExport void B64Decode(const Anope::string &src, Anope::string &target);
+ extern CoreExport void B64Decode(const string &src, string &target);
/** Returns a sequence of data formatted as the format argument specifies.
** After the format parameter, the function expects at least as many
@@ -404,7 +399,7 @@ namespace Anope
/** Return the last error, uses errno/GetLastError() to determine this
* @return An error message
*/
- extern CoreExport const Anope::string LastError();
+ extern CoreExport const string LastError();
}
/** sepstream allows for splitting token seperated lists.
@@ -470,95 +465,250 @@ class spacesepstream : public sepstream
spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
};
-/** The base class that most classes in Anope inherit from
+/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
+ * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
+ * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
+ * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
+ * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
*/
-class dynamic_reference_base;
-class CoreExport Base
+class CoreException : public std::exception
+{
+ protected:
+ /** Holds the error message to be displayed
+ */
+ Anope::string err;
+ /** Source of the exception
+ */
+ Anope::string source;
+ public:
+ /** Default constructor, just uses the error mesage 'Core threw an exception'.
+ */
+ CoreException() : err("Core threw an exception"), source("The core") { }
+ /** This constructor can be used to specify an error message before throwing.
+ */
+ CoreException(const Anope::string &message) : err(message), source("The core") { }
+ /** This constructor can be used to specify an error message before throwing,
+ * and to specify the source of the exception.
+ */
+ CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
+ /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+ * Actually no, it does nothing. Never mind.
+ * @throws Nothing!
+ */
+ virtual ~CoreException() throw() { }
+ /** Returns the reason for the exception.
+ * The module should probably put something informative here as the user will see this upon failure.
+ */
+ virtual const Anope::string &GetReason() const
+ {
+ return err;
+ }
+
+ virtual const Anope::string &GetSource() const
+ {
+ return source;
+ }
+};
+
+class FatalException : public CoreException
{
- /* References to this base class */
- std::set<dynamic_reference_base *> References;
public:
- Base();
- virtual ~Base();
- void AddReference(dynamic_reference_base *r);
- void DelReference(dynamic_reference_base *r);
+ FatalException(const Anope::string &reason = "") : CoreException(reason) { }
+
+ virtual ~FatalException() throw() { }
};
-class dynamic_reference_base
+class ModuleException : public CoreException
{
- protected:
- bool invalid;
public:
- dynamic_reference_base() : invalid(false) { }
- virtual ~dynamic_reference_base() { }
- inline void Invalidate() { this->invalid = true; }
+ /** Default constructor, just uses the error mesage 'Module threw an exception'.
+ */
+ ModuleException() : CoreException("Module threw an exception", "A Module") { }
+
+ /** This constructor can be used to specify an error message before throwing.
+ */
+ ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
+ /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+ * Actually no, it does nothing. Never mind.
+ * @throws Nothing!
+ */
+ virtual ~ModuleException() throw() { }
+};
+
+class ConvertException : public CoreException
+{
+ public:
+ ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
+
+ virtual ~ConvertException() throw() { }
};
-template<typename T>
-class dynamic_reference : public dynamic_reference_base
+/** Convert something to a string
+ */
+template<typename T> inline Anope::string stringify(const T &x)
+{
+ std::ostringstream stream;
+
+ if (!(stream << x))
+ throw ConvertException("Stringify fail");
+
+ return stream.str();
+}
+
+template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
+{
+ leftover.clear();
+ std::istringstream i(s.str());
+ char c;
+ bool res = i >> x;
+ if (!res)
+ throw ConvertException("Convert fail");
+ if (failIfLeftoverChars)
+ {
+ if (i.get(c))
+ throw ConvertException("Convert fail");
+ }
+ else
+ {
+ std::string left;
+ getline(i, left);
+ leftover = left;
+ }
+}
+
+template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
+{
+ Anope::string Unused;
+ convert(s, x, Unused, failIfLeftoverChars);
+}
+
+template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
+{
+ T x;
+ convert(s, x, leftover, failIfLeftoverChars);
+ return x;
+}
+
+template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
+{
+ T x;
+ convert(s, x, failIfLeftoverChars);
+ return x;
+}
+
+/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast
+ * for debug builds and static_cast on releass builds to speed up the program
+ * because dynamic_cast relies on RTTI.
+ */
+#ifdef DEBUG_BUILD
+# include <typeinfo>
+#endif
+template<typename T, typename O> inline T debug_cast(O ptr)
+{
+#ifdef DEBUG_BUILD
+ T ret = dynamic_cast<T>(ptr);
+ if (ptr != NULL && ret == NULL)
+ throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
+ return ret;
+#else
+ return static_cast<T>(ptr);
+#endif
+}
+
+/*************************************************************************/
+
+/** Class with the ability to keep flags on items, they should extend from this
+ * where T is an enum.
+ */
+template<typename T, size_t Size = 32> class Flags
{
protected:
- T *ref;
+ std::bitset<Size> Flag_Values;
+ const Anope::string *Flag_Strings;
+
public:
- dynamic_reference(T *obj) : ref(obj)
+ Flags() : Flag_Strings(NULL) { }
+ Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
+
+ /** Add a flag to this item
+ * @param Value The flag
+ */
+ void SetFlag(T Value)
{
- if (ref)
- ref->AddReference(this);
+ Flag_Values[Value] = true;
}
- dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
+ /** Remove a flag from this item
+ * @param Value The flag
+ */
+ void UnsetFlag(T Value)
{
- if (ref)
- ref->AddReference(this);
+ Flag_Values[Value] = false;
}
- virtual ~dynamic_reference()
+ /** Check if this item has a flag
+ * @param Value The flag
+ * @return true or false
+ */
+ bool HasFlag(T Value) const
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- else if (this->operator bool())
- ref->DelReference(this);
+ return Flag_Values.test(Value);
}
- virtual operator bool()
+ /** Check how many flags are set
+ * @return The number of flags set
+ */
+ size_t FlagCount() const
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- return this->ref != NULL;
+ return Flag_Values.count();
}
- virtual inline operator T*()
+ /** Unset all of the flags
+ */
+ void ClearFlags()
{
- if (this->operator bool())
- return this->ref;
- return NULL;
+ Flag_Values.reset();
}
- virtual inline T *operator->()
+ Anope::string ToString()
{
- if (this->operator bool())
- return this->ref;
- return NULL;
+ std::vector<Anope::string> v = ToVector();
+ Anope::string flag_buf;
+ for (unsigned i = 0; i < v.size(); ++i)
+ flag_buf += v[i] + " ";
+ flag_buf.trim();
+ return flag_buf;
}
- virtual inline void operator=(T *newref)
+ void FromString(const Anope::string &str)
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- else if (this->operator bool())
- this->ref->DelReference(this);
- this->ref = newref;
- if (this->operator bool())
- this->ref->AddReference(this);
+ spacesepstream sep(str);
+ Anope::string buf;
+ std::vector<Anope::string> v;
+
+ while (sep.GetToken(buf))
+ v.push_back(buf);
+
+ FromVector(v);
+ }
+
+ std::vector<Anope::string> ToVector()
+ {
+ std::vector<Anope::string> ret;
+ for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
+ if (this->HasFlag(static_cast<T>(i)))
+ ret.push_back(this->Flag_Strings[i]);
+ return ret;
+ }
+
+ void FromVector(const std::vector<Anope::string> &strings)
+ {
+ this->ClearFlags();
+
+ for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
+ for (unsigned j = 0; j < strings.size(); ++j)
+ if (this->Flag_Strings[i] == strings[j])
+ this->SetFlag(static_cast<T>(i));
}
};
diff --git a/include/base.h b/include/base.h
new file mode 100644
index 000000000..2a7cb5147
--- /dev/null
+++ b/include/base.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright (C) 2008-2011 Adam <Adam@anope.org>
+ * Copyright (C) 2008-2012 Anope Team <team@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#ifndef BASE_H
+#define BASE_H
+
+#include "services.h"
+
+/** The base class that most classes in Anope inherit from
+ */
+class CoreExport Base
+{
+ /* References to this base class */
+ std::set<dynamic_reference_base *> References;
+ public:
+ Base();
+ virtual ~Base();
+ void AddReference(dynamic_reference_base *r);
+ void DelReference(dynamic_reference_base *r);
+};
+
+class dynamic_reference_base
+{
+ protected:
+ bool invalid;
+ public:
+ dynamic_reference_base() : invalid(false) { }
+ virtual ~dynamic_reference_base() { }
+ inline void Invalidate() { this->invalid = true; }
+};
+
+template<typename T>
+class dynamic_reference : public dynamic_reference_base
+{
+ protected:
+ T *ref;
+ public:
+ dynamic_reference(T *obj) : ref(obj)
+ {
+ if (ref)
+ ref->AddReference(this);
+ }
+
+ dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
+ {
+ if (ref)
+ ref->AddReference(this);
+ }
+
+ virtual ~dynamic_reference()
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ else if (this->operator bool())
+ ref->DelReference(this);
+ }
+
+ virtual operator bool()
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ return this->ref != NULL;
+ }
+
+ virtual inline operator T*()
+ {
+ if (this->operator bool())
+ return this->ref;
+ return NULL;
+ }
+
+ virtual inline T *operator->()
+ {
+ if (this->operator bool())
+ return this->ref;
+ return NULL;
+ }
+
+ virtual inline void operator=(T *newref)
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ else if (this->operator bool())
+ this->ref->DelReference(this);
+ this->ref = newref;
+ if (this->operator bool())
+ this->ref->AddReference(this);
+ }
+};
+
+#endif // BASE_H
+
diff --git a/include/bots.h b/include/bots.h
index 93ca7d9b9..243ae7556 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -8,7 +8,11 @@
#ifndef BOTS_H
#define BOTS_H
-class BotInfo;
+#include "users.h"
+#include "anope.h"
+#include "serialize.h"
+#include "commands.h"
+
extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick;
extern CoreExport Anope::map<BotInfo *> BotListByUID;
@@ -123,4 +127,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
CommandInfo *GetCommand(const Anope::string &cname);
};
+extern BotInfo *findbot(const Anope::string &nick);
+
+extern void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+extern void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+
#endif // BOTS_H
diff --git a/include/botserv.h b/include/botserv.h
new file mode 100644
index 000000000..e5ef2c8ba
--- /dev/null
+++ b/include/botserv.h
@@ -0,0 +1,79 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef BOTSERV_H
+#define BOTSERV_H
+
+#include "anope.h"
+
+/* BotServ SET flags */
+enum BotServFlag
+{
+ BS_BEGIN,
+ /* BotServ won't kick ops */
+ BS_DONTKICKOPS,
+ /* BotServ won't kick voices */
+ BS_DONTKICKVOICES,
+ /* BotServ bot accepts fantasy commands */
+ BS_FANTASY,
+ /* BotServ should show greets */
+ BS_GREET,
+ /* BotServ bots are not allowed to be in this channel */
+ BS_NOBOT,
+ /* BotServ kicks for bolds */
+ BS_KICK_BOLDS,
+ /* BotServ kicks for colors */
+ BS_KICK_COLORS,
+ /* BOtServ kicks for reverses */
+ BS_KICK_REVERSES,
+ /* BotServ kicks for underlines */
+ BS_KICK_UNDERLINES,
+ /* BotServ kicks for badwords */
+ BS_KICK_BADWORDS,
+ /* BotServ kicks for caps */
+ BS_KICK_CAPS,
+ /* BotServ kicks for flood */
+ BS_KICK_FLOOD,
+ /* BotServ kicks for repeating */
+ BS_KICK_REPEAT,
+ /* BotServ kicks for italics */
+ BS_KICK_ITALICS,
+ /* BotServ kicks for amsgs */
+ BS_KICK_AMSGS,
+ BS_END
+};
+
+const Anope::string BotServFlagStrings[] = {
+ "BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
+ "KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
+ "KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
+ "MSG_NOTICEOPS", ""
+};
+
+/* Indices for TTB (Times To Ban) */
+enum
+{
+ TTB_BOLDS,
+ TTB_COLORS,
+ TTB_REVERSES,
+ TTB_UNDERLINES,
+ TTB_BADWORDS,
+ TTB_CAPS,
+ TTB_FLOOD,
+ TTB_REPEAT,
+ TTB_ITALICS,
+ TTB_AMSGS,
+ TTB_SIZE
+};
+
+#endif // BOTSERV_H
diff --git a/include/channels.h b/include/channels.h
index 2aa4fc765..a4803fe00 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -9,6 +9,11 @@
#ifndef CHANNELS_H
#define CHANNELS_H
+#include "anope.h"
+#include "extensible.h"
+#include "modes.h"
+
+
typedef Anope::insensitive_map<Channel *> channel_map;
extern CoreExport channel_map ChannelList;
@@ -35,7 +40,7 @@ enum ChannelFlag
const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" };
-class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
+class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag, 3>
{
public:
typedef std::multimap<ChannelModeName, Anope::string> ModeList;
@@ -229,6 +234,21 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
* @param ts The time when the new topic is being set
*/
void ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
+
+ /** Hold the channel open using ChanServ
+ */
+ void Hold();
};
+extern Channel *findchan(const Anope::string &chan);
+
+extern User *nc_on_chan(Channel *c, const NickCore *nc);
+
+extern void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
+extern void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
+extern void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
+extern void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
+
+extern void chan_set_correct_modes(User *user, Channel *c, int give_modes);
+
#endif // CHANNELS_H
diff --git a/include/commands.h b/include/commands.h
index c0812620f..cfd46d644 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -12,11 +12,8 @@
#ifndef COMMAND_H
#define COMMAND_H
-#include "services.h"
-
-class Module;
-class BotInfo;
-class Command;
+#include "service.h"
+#include "anope.h"
enum CommandFlag
{
diff --git a/include/config.h b/include/config.h
index 0482aac69..d53b7f41c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,14 +1,22 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef CONFIG_H
#define CONFIG_H
-#include <string>
-#include <fstream>
-#include <sstream>
-#include <vector>
-#include <map>
-#include <deque>
-
-#include "anope.h"
+#include "account.h"
+#include "regchannel.h"
+#include "users.h"
/** A configuration key and value pair
*/
@@ -23,7 +31,6 @@ typedef std::vector<KeyVal> KeyValList;
typedef std::multimap<Anope::string, KeyValList> ConfigDataHash;
// Required forward definitions
-class ServerConfig;
/** Types of data in the core config
*/
@@ -341,6 +348,29 @@ class CoreExport ServerConfig
void ValidateIP(const Anope::string &p, const Anope::string &, const Anope::string &, bool) const;
void ValidateNoSpaces(const Anope::string &, const Anope::string &, const Anope::string &) const;
+ struct Uplink
+ {
+ Anope::string host;
+ unsigned port;
+ Anope::string password;
+ bool ipv6;
+
+ Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
+ bool operator==(const Uplink &other) const
+ {
+ if (this->host != other.host)
+ return false;
+ if (this->port != other.port)
+ return false;
+ if (this->password != other.password)
+ return false;
+ if (this->ipv6 != other.ipv6)
+ return false;
+ return true;
+ }
+ inline bool operator!=(const Uplink &other) const { return !(*this == other); }
+ };
+
/** Below here is a list of variables which contain the config files values
*/
/* Host to bind to */
@@ -760,4 +790,7 @@ class CoreExport ConfigReader
int EnumerateValues(const Anope::string &, int);
};
+extern ConfigurationFile services_conf;
+extern ServerConfig *Config;
+
#endif // CONFIG_H
diff --git a/include/defs.h b/include/defs.h
new file mode 100644
index 000000000..0a248daf7
--- /dev/null
+++ b/include/defs.h
@@ -0,0 +1,52 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ */
+
+
+class AccessGroup;
+class AutoKick;
+class BotInfo;
+class CallBack;
+class ChanAccess;
+class Channel;
+class ChannelInfo;
+class ChannelStatus;
+class ClientSocket;
+class Command;
+class ConnectionSocket;
+class DNSPacket;
+class dynamic_reference_base;
+class Entry;
+class InfoFormatter;
+class ListenSocket;
+class Log;
+class LogInfo;
+class Memo;
+class Message;
+class Module;
+class NickAlias;
+class NickCore;
+class OperType;
+class Server;
+class ServerConfig;
+class Socket;
+class Thread;
+class User;
+class XLineManager;
+struct BadWord;
+struct CommandSource;
+struct DNSQuery;
+struct Exception;
+struct MemoInfo;
+struct ModeLock;
+struct Oper;
+struct XLine;
+
diff --git a/include/dns.h b/include/dns.h
index 7d668cda7..c70b6b7b3 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -1,6 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef DNS_H
#define DNS_H
+#include "sockets.h"
+#include "timers.h"
+#include "extern.h"
+#include "config.h"
+
/** Valid query types
*/
enum QueryType
@@ -48,9 +66,6 @@ enum DNSError
DNS_ERROR_INVALIDTYPE
};
-class Module;
-struct DNSQuery;
-class DNSPacket;
struct CoreExport Question
{
diff --git a/include/extensible.h b/include/extensible.h
index 21a1513a1..1416e1983 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -8,7 +8,6 @@
#define EXTENSIBLE_H
#include "anope.h"
-#include "hashcomp.h"
class CoreExport ExtensibleItem
{
@@ -24,7 +23,7 @@ class ExtensibleString : public Anope::string, public ExtensibleItem
ExtensibleString(const Anope::string &s) : Anope::string(s), ExtensibleItem() { }
};
-class CoreExport Extensible : public Base
+class CoreExport Extensible
{
private:
typedef Anope::map<ExtensibleItem *> extensible_map;
diff --git a/include/extern.h b/include/extern.h
index 0670f285c..aff091913 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -12,32 +12,19 @@
#ifndef EXTERN_H
#define EXTERN_H
+#include "modes.h"
+
#define E extern CoreExport
#define EI extern DllExport
-#include "hashcomp.h"
-
-/* IRC Variables */
-
-E IRCDVar *ircd;
-E IRCDProto *ircdproto;
-E IRCdMessage *ircdmessage;
/**** actions.c ****/
E bool bad_password(User *u);
E void common_unban(ChannelInfo *ci, User *u, bool full = false);
-/**** botserv.c ****/
-
-E BotInfo *findbot(const Anope::string &nick);
-
-E void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
-E void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
-
/**** channels.c ****/
-
E Channel *findchan(const Anope::string &chan);
E User *nc_on_chan(Channel *c, const NickCore *nc);
@@ -49,26 +36,11 @@ E void do_part(const Anope::string &source, const Anope::string &channels, const
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
-/**** chanserv.c ****/
-
-E void check_modes(Channel *c);
-
-E ChannelInfo *cs_findchan(const Anope::string &chan);
-E bool IsFounder(User *user, ChannelInfo *ci);
-E void update_cs_lastseen(User *user, ChannelInfo *ci);
-E int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret);
-
-/**** config.c ****/
-
-E ConfigurationFile services_conf;
-E ServerConfig *Config;
-
/**** encrypt.c ****/
+
E void enc_encrypt(const Anope::string &src, Anope::string &dest);
E bool enc_decrypt(const Anope::string &src, Anope::string &dest);
-/**** hostserv.c ****/
-
/**** init.c ****/
E void introduce_user(const Anope::string &user);
@@ -78,12 +50,8 @@ E bool AtTerm();
E void Fork();
E void Init(int ac, char **av);
-/**** ircd.c ****/
-E void pmodule_ircd_proto(IRCDProto *);
-E void pmodule_ircd_var(IRCDVar *ircdvar);
-E void pmodule_ircd_message(IRCdMessage *message);
-
/**** language.cpp ****/
+
E std::vector<Anope::string> languages;
E std::vector<Anope::string> domains;
E void InitLanguages();
@@ -109,31 +77,6 @@ E bool restarting;
E Anope::string quitmsg;
E time_t start_time;
-class UplinkSocket : public ConnectionSocket, public BufferedSocket
-{
- public:
- UplinkSocket();
- ~UplinkSocket();
- bool Read(const Anope::string &);
- void OnConnect();
- void OnError(const Anope::string &);
-
- class CoreExport Message
- {
- Anope::string source;
- std::stringstream buffer;
- public:
- Message();
- Message(const Anope::string &);
- ~Message();
- template<typename T> Message &operator<<(const T &val)
- {
- this->buffer << val;
- return *this;
- }
- };
-};
-E UplinkSocket *UplinkSock;
E int CurrentUplink;
E void save_databases();
@@ -191,45 +134,14 @@ E bool str_is_pure_wildcard(const Anope::string &str);
E Anope::string normalizeBuffer(const Anope::string &);
/**** modes.cpp ****/
+
/* Number of generic modes we support */
E unsigned GenericChannelModes, GenericUserModes;
E std::multimap<ChannelModeName, ModeLock> def_mode_locks;
E void SetDefaultMLock(ServerConfig *config);
-/**** nickserv.c ****/
-
-E void change_core_display(NickCore *nc);
-E void change_core_display(NickCore *nc, const Anope::string &newdisplay);
-
-E NickAlias *findnick(const Anope::string &nick);
-E NickCore *findcore(const Anope::string &nick);
-E bool is_on_access(const User *u, const NickCore *nc);
-
/**** process.c ****/
E void process(const Anope::string &buf);
-/**** sockets.cpp ****/
-
-E int32_t TotalRead;
-E int32_t TotalWritten;
-E SocketIO normalSocketIO;
-
-/**** users.c ****/
-
-E int32_t opcnt;
-E uint32_t maxusercnt, usercnt;
-E time_t maxusertime;
-
-E User *finduser(const Anope::string &nick);
-
-E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
-
-E void do_umode(const Anope::string &user, const Anope::string &modes);
-E void do_kill(User *user, const Anope::string &reason);
-
-E bool matches_list(Channel *c, User *user, ChannelModeName mode);
-
-E Anope::string create_mask(User *u);
-
#endif /* EXTERN_H */
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 3ed90d5cb..0a9df7139 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -13,21 +13,10 @@
#ifndef HASHCOMP_H
#define HASHCOMP_H
-#ifdef _WIN32
-# ifdef MODULE_COMPILE
-# define CoreExport __declspec(dllimport)
-# define DllExport __declspec(dllexport)
-# else
-# define CoreExport __declspec(dllexport)
-# define DllExport __declspec(dllimport)
-# endif
-#else
-# define CoreExport
-# define DllExport
-#endif
-
#include <string>
+#include "services.h"
+
namespace Anope
{
class string;
diff --git a/include/lists.h b/include/lists.h
new file mode 100644
index 000000000..308080c93
--- /dev/null
+++ b/include/lists.h
@@ -0,0 +1,94 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef LISTS_H
+#define LISTS_H
+
+#include "services.h"
+#include "anope.h"
+
+/** A class to process numbered lists (passed to most DEL/LIST/VIEW commands).
+ * The function HandleNumber is called for every number in the list. Note that
+ * if descending is true it gets called in descending order. This is so deleting
+ * the index passed to the function from an array will not cause the other indexes
+ * passed to the function to be incorrect. This keeps us from having to have an
+ * 'in use' flag on everything.
+ */
+class CoreExport NumberList
+{
+ private:
+ bool is_valid;
+
+ std::set<unsigned> numbers;
+
+ bool desc;
+ public:
+ /** Processes a numbered list
+ * @param list The list
+ * @param descending True to make HandleNumber get called with numbers in descending order
+ */
+ NumberList(const Anope::string &list, bool descending);
+
+ /** Destructor, does nothing
+ */
+ virtual ~NumberList();
+
+ /** Should be called after the constructors are done running. This calls the callbacks.
+ */
+ void Process();
+
+ /** Called with a number from the list
+ * @param Number The number
+ */
+ virtual void HandleNumber(unsigned Number);
+
+ /** Called when there is an error with the numbered list
+ * Return false to immediatly stop processing the list and return
+ * This is all done before we start calling HandleNumber, so no numbers will have been processed yet
+ * @param list The list
+ * @return false to stop processing
+ */
+ virtual bool InvalidRange(const Anope::string &list);
+};
+
+/** This class handles formatting LIST/VIEW replies.
+ */
+class CoreExport ListFormatter
+{
+ public:
+ typedef std::map<Anope::string, Anope::string> ListEntry;
+ private:
+ std::vector<Anope::string> columns;
+ std::vector<ListEntry> entries;
+ public:
+ ListFormatter &addColumn(const Anope::string &name);
+ void addEntry(const ListEntry &entry);
+ bool isEmpty() const;
+ void Process(std::vector<Anope::string> &);
+};
+
+/** This class handles formatting INFO replies
+ */
+class CoreExport InfoFormatter
+{
+ User *user;
+ std::vector<std::pair<Anope::string, Anope::string> > replies;
+ unsigned longest;
+ public:
+ InfoFormatter(User *u);
+ void Process(std::vector<Anope::string> &);
+ Anope::string &operator[](const Anope::string &key);
+};
+
+#endif // LISTS_H
+
diff --git a/include/logger.h b/include/logger.h
index 3ba93a1e9..a6e3ca113 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -1,6 +1,21 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ */
+
#ifndef LOGGER_H
#define LOGGER_H
+#include "anope.h"
+#include "defs.h"
+
enum LogType
{
LOG_ADMIN,
@@ -29,7 +44,6 @@ struct LogFile
Anope::string GetName() const;
};
-class Command;
class CoreExport Log
{
diff --git a/include/mail.h b/include/mail.h
index 31f35d92d..06cfe4b39 100644
--- a/include/mail.h
+++ b/include/mail.h
@@ -1,7 +1,22 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
#ifndef MAIL_H
#define MAIL_H
#include "anope.h"
+#include "threadengine.h"
+
extern CoreExport bool Mail(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message);
extern CoreExport bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message);
diff --git a/include/memo.h b/include/memo.h
new file mode 100644
index 000000000..a6df46861
--- /dev/null
+++ b/include/memo.h
@@ -0,0 +1,63 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef MEMO_H
+#define MEMO_H
+
+#include "anope.h"
+#include "serialize.h"
+
+/** Memo Flags
+ */
+enum MemoFlag
+{
+ /* Memo is unread */
+ MF_UNREAD,
+ /* Sender requests a receipt */
+ MF_RECEIPT
+};
+
+const Anope::string MemoFlagStrings[] = {
+ "MF_UNREAD", "MF_RECEIPT", ""
+};
+
+/* Memo info structures. Since both nicknames and channels can have memos,
+ * we encapsulate memo data in a MemoList to make it easier to handle. */
+class CoreExport Memo : public Flags<MemoFlag>, public Serializable
+{
+ public:
+ Memo();
+
+ Anope::string serialize_name() const;
+ serialized_data serialize();
+ static void unserialize(serialized_data &);
+
+ Anope::string owner;
+ time_t time; /* When it was sent */
+ Anope::string sender;
+ Anope::string text;
+};
+
+struct CoreExport MemoInfo
+{
+ int16_t memomax;
+ std::vector<Memo *> memos;
+ std::vector<Anope::string> ignores;
+
+ unsigned GetIndex(Memo *m) const;
+ void Del(unsigned index);
+ void Del(Memo *m);
+ bool HasIgnore(User *u);
+};
+
+#endif // MEMO_H
diff --git a/include/modes.h b/include/modes.h
index 2743a23a6..b1195d27d 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -9,6 +9,9 @@
#ifndef MODES_H
#define MODES_H
+#include "anope.h"
+#include "base.h"
+
/** All of the valid user mode names
*/
enum UserModeName
@@ -375,16 +378,6 @@ class StackerInfo
class CoreExport ModeManager
{
protected:
- class ModePipe : public Pipe
- {
- public:
- /** Called when there are modes to be set
- */
- void OnNotify();
- };
-
- static ModePipe *mpipe;
-
/* List of pairs of user/channels and their stacker info */
static std::list<std::pair<Base *, StackerInfo *> > StackerObjects;
@@ -497,4 +490,48 @@ class CoreExport ModeManager
static void StackerDel(Base *b);
};
+/** Entry flags
+ */
+enum EntryType
+{
+ ENTRYTYPE_NONE,
+ ENTRYTYPE_CIDR,
+ ENTRYTYPE_NICK_WILD,
+ ENTRYTYPE_NICK,
+ ENTRYTYPE_USER_WILD,
+ ENTRYTYPE_USER,
+ ENTRYTYPE_HOST_WILD,
+ ENTRYTYPE_HOST
+};
+
+/** Represents a mask set on a channel (b/e/I)
+ */
+class CoreExport Entry : public Flags<EntryType>
+{
+ ChannelModeName modename;
+
+ public:
+ unsigned char cidr_len;
+ Anope::string mask;
+ Anope::string nick, user, host;
+
+ /** Constructor
+ * @param _host A full nick!ident@host/cidr mask
+ * @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode
+ */
+ Entry(ChannelModeName mode, const Anope::string &_host);
+
+ /** Get the banned mask for this entry
+ * @return The mask
+ */
+ const Anope::string GetMask();
+
+ /** Check if this entry matches a user
+ * @param u The user
+ * @param full True to match against a users real host and IP
+ * @return true on match
+ */
+ bool Matches(User *u, bool full = false) const;
+};
+
#endif // MODES_H
diff --git a/include/module.h b/include/module.h
index 6435f9b7f..02f0e61c4 100644
--- a/include/module.h
+++ b/include/module.h
@@ -1,9 +1,57 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#ifndef MODULE_H
#define MODULE_H
-#include "services.h"
+/* Just include everything for now */
+#include "access.h"
+#include "account.h"
+#include "anope.h"
+#include "base.h"
+#include "bots.h"
+#include "botserv.h"
+#include "channels.h"
+#include "commands.h"
+#include "config.h"
+#include "dns.h"
+#include "extensible.h"
+#include "extern.h"
+#include "hashcomp.h"
+#include "language.h"
+#include "lists.h"
+#include "logger.h"
+#include "mail.h"
+#include "memo.h"
+#include "modes.h"
#include "modules.h"
#include "oper.h"
-#include "commands.h"
+#include "opertype.h"
+#include "protocol.h"
+#include "pstdint.h"
+#include "regchannel.h"
+#include "serialize.h"
+#include "servers.h"
+#include "service.h"
+#include "services.h"
+#include "signals.h"
+#include "socketengine.h"
+#include "sockets.h"
+#include "threadengine.h"
+#include "timers.h"
+#include "uplink.h"
+#include "users.h"
+
+#include "global.h"
+#include "memoserv.h"
+#include "nickserv.h"
#endif // MODULE_H
diff --git a/include/modules.h b/include/modules.h
index d251be353..722526382 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -12,20 +12,43 @@
#ifndef MODULES_H
#define MODULES_H
-#include <time.h>
-#include "services.h"
-#include <stdio.h>
+#include "extensible.h"
+#include "base.h"
+#include "modes.h"
#include "timers.h"
-#include "hashcomp.h"
+#include "logger.h"
-/** Possible return types from events.
+/** This definition is used as shorthand for the various classes
+ * and functions needed to make a module loadable by the OS.
+ * It defines the class factory and external AnopeInit and AnopeFini functions.
*/
-enum EventReturn
-{
- EVENT_STOP,
- EVENT_CONTINUE,
- EVENT_ALLOW
-};
+#ifdef _WIN32
+# define MODULE_INIT(x) \
+ extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
+ extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
+ { \
+ return new x(modname, creator); \
+ } \
+ BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
+ { \
+ return TRUE; \
+ } \
+ extern "C" DllExport void AnopeFini(x *); \
+ extern "C" void AnopeFini(x *m) \
+ { \
+ delete m; \
+ }
+#else
+# define MODULE_INIT(x) \
+ extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
+ { \
+ return new x(modname, creator); \
+ } \
+ extern "C" DllExport void AnopeFini(x *m) \
+ { \
+ delete m; \
+ }
+#endif
/**
* This #define allows us to call a method in all
@@ -35,8 +58,8 @@ enum EventReturn
#define FOREACH_MOD(y, x) \
if (true) \
{ \
- std::vector<Module*>::iterator safei; \
- for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
+ std::vector<Module *>::iterator safei; \
+ for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
{ \
safei = _i; \
++safei; \
@@ -62,9 +85,9 @@ else \
#define FOREACH_RESULT(y, x) \
if (true) \
{ \
- std::vector<Module*>::iterator safei; \
+ std::vector<Module *>::iterator safei; \
MOD_RESULT = EVENT_CONTINUE; \
- for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
+ for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
{ \
safei = _i; \
++safei; \
@@ -86,24 +109,15 @@ if (true) \
else \
static_cast<void>(0)
-#ifndef _WIN32
-# include <dlfcn.h>
- /* Define these for systems without them */
-# ifndef RTLD_NOW
-# define RTLD_NOW 0
-# endif
-# ifndef RTLD_LAZY
-# define RTLD_LAZY RTLD_NOW
-# endif
-# ifndef RTLD_GLOBAL
-# define RTLD_GLOBAL 0
-# endif
-# ifndef RTLD_LOCAL
-# define RTLD_LOCAL 0
-# endif
-#endif
+/** Possible return types from events.
+ */
+enum EventReturn
+{
+ EVENT_STOP,
+ EVENT_CONTINUE,
+ EVENT_ALLOW
+};
-class Message;
enum ModuleReturn
{
@@ -127,10 +141,10 @@ enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL,
typedef std::multimap<Anope::string, Message *> message_map;
extern CoreExport message_map MessageMap;
-class Module;
+
extern CoreExport std::list<Module *> Modules;
-class Version
+class ModuleVersion
{
private:
int Major;
@@ -143,11 +157,11 @@ class Version
* @param vMinor The minor version numbber
* @param vBuild The build version numbber
*/
- Version(int vMajor, int vMinor, int vBuild);
+ ModuleVersion(int vMajor, int vMinor, int vBuild);
/** Destructor
*/
- virtual ~Version();
+ virtual ~ModuleVersion();
/** Get the major version of Anope this was built against
* @return The major version
@@ -165,9 +179,6 @@ class Version
int GetBuild() const;
};
-class CallBack;
-class XLineManager;
-struct CommandSource;
/** Every module in Anope is actually a class.
*/
@@ -247,7 +258,7 @@ class CoreExport Module : public Extensible
* compiled against
* @return The version
*/
- Version GetVersion() const;
+ ModuleVersion GetVersion() const;
/** Called when the ircd notifies that a user has been kicked from a channel.
* @param c The channel the user has been kicked from.
@@ -1110,50 +1121,9 @@ class CallBack : public Timer
private:
Module *m;
public:
- CallBack(Module *mod, long time_from_now, time_t now = Anope::CurTime, bool repeating = false) : Timer(time_from_now, now, repeating), m(mod)
- {
- m->CallBacks.push_back(this);
- }
-
- virtual ~CallBack()
- {
- std::list<CallBack *>::iterator it = std::find(m->CallBacks.begin(), m->CallBacks.end(), this);
- if (it != m->CallBacks.end())
- m->CallBacks.erase(it);
- }
-};
-
-template<typename T>
-class service_reference : public dynamic_reference<T>
-{
- Anope::string type;
- Anope::string name;
-
- public:
- service_reference(const Anope::string &t, const Anope::string &n) : dynamic_reference<T>(NULL), type(t), name(n)
- {
- }
+ CallBack(Module *mod, long time_from_now, time_t now = Anope::CurTime, bool repeating = false);
- inline void operator=(const Anope::string &n)
- {
- this->name = n;
- }
-
- operator bool()
- {
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- if (!this->ref)
- {
- this->ref = static_cast<T *>(Service::FindService(this->type, this->name));
- if (this->ref)
- this->ref->AddReference(this);
- }
- return this->ref;
- }
+ virtual ~CallBack();
};
class CoreExport Message
diff --git a/include/oper.h b/include/oper.h
index 1a82a8530..ced1d38dc 100644
--- a/include/oper.h
+++ b/include/oper.h
@@ -9,7 +9,8 @@
#ifndef OPER_H
#define OPER_H
-class XLineManager;
+#include "serialize.h"
+#include "service.h"
class CoreExport XLine : public Serializable
{
@@ -29,7 +30,6 @@ class CoreExport XLine : public Serializable
Anope::string GetNick() const;
Anope::string GetUser() const;
Anope::string GetHost() const;
- sockaddrs GetIP() const;
Anope::string serialize_name() const;
serialized_data serialize();
diff --git a/include/opertype.h b/include/opertype.h
index 93f3f0629..3f0b8d157 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -8,9 +8,8 @@
#ifndef OPERTYPE_H
#define OPERTYPE_H
-#include "hashcomp.h"
-
-class OperType;
+#include "services.h"
+#include "account.h"
struct CoreExport Oper
{
diff --git a/include/protocol.h b/include/protocol.h
new file mode 100644
index 000000000..f1bb9dbbe
--- /dev/null
+++ b/include/protocol.h
@@ -0,0 +1,155 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#include "services.h"
+#include "anope.h"
+
+/* Protocol tweaks */
+
+struct IRCDVar
+{
+ const char *name; /* Name of the IRCd command */
+ const char *pseudoclient_mode; /* Mode used by BotServ Bots */
+ int svsnick; /* Supports SVSNICK */
+ int vhost; /* Supports vhost */
+ int snline; /* Supports SNline */
+ int sqline; /* Supports SQline */
+ int szline; /* Supports SZline */
+ int join2msg; /* Join 2 Message */
+ int chansqline; /* Supports Channel Sqlines */
+ int quitonkill; /* IRCD sends QUIT when kill */
+ int vident; /* Supports vidents */
+ int svshold; /* Supports svshold */
+ int tsonmode; /* Timestamp on mode changes */
+ int omode; /* On the fly o:lines */
+ int umode; /* change user modes */
+ int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
+ int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
+ int sglineenforce;
+ int ts6; /* ircd is TS6 */
+ const char *globaltldprefix; /* TLD prefix used for Global */
+ unsigned maxmodes; /* Max modes to send per line */
+ int certfp; /* IRCd sends a SSL users certificate fingerprint */
+};
+
+
+class CoreExport IRCDProto
+{
+ private:
+ virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &) = 0;
+ virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &) = 0;
+ virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &) = 0;
+ virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &) = 0;
+ virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
+ virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
+ virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
+ virtual void SendQuitInternal(const User *u, const Anope::string &buf);
+ virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
+ virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
+ virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
+ virtual void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf);
+ public:
+ virtual ~IRCDProto() { }
+
+ virtual void SendSVSNOOP(const Server *, bool) { }
+ virtual void SendTopic(BotInfo *, Channel *) = 0;
+ virtual void SendVhostDel(User *) { }
+ virtual void SendAkill(User *, const XLine *) = 0;
+ virtual void SendAkillDel(const XLine *) = 0;
+ virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
+ virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
+ virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
+ virtual void SendClientIntroduction(const User *u) = 0;
+ virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
+ virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg);
+ virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg);
+
+ virtual void SendQuit(const User *u, const char *fmt, ...);
+ virtual void SendPing(const Anope::string &servname, const Anope::string &who);
+ virtual void SendPong(const Anope::string &servname, const Anope::string &who);
+ virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
+ virtual void SendSQLineDel(const XLine *x) { }
+ virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
+ virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
+ virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
+ virtual void SendSQLine(User *, const XLine *x) { }
+ virtual void SendSquit(Server *, const Anope::string &message);
+ virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
+ virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
+ virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
+ virtual void SendConnect() = 0;
+ virtual void SendSVSHold(const Anope::string &) { }
+ virtual void SendSVSHoldDel(const Anope::string &) { }
+ virtual void SendSGLineDel(const XLine *) { }
+ virtual void SendSZLineDel(const XLine *) { }
+ virtual void SendSZLine(User *u, const XLine *) { }
+ virtual void SendSGLine(User *, const XLine *) { }
+ virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendSVSJoin(const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendSWhois(const Anope::string &, const Anope::string &, const Anope::string &) { }
+ virtual void SendBOB() { }
+ virtual void SendEOB() { }
+ virtual void SendServer(const Server *) = 0;
+ virtual bool IsNickValid(const Anope::string &) { return true; }
+ virtual bool IsChannelValid(const Anope::string &);
+ virtual void SendNumeric(const Anope::string &source, int numeric, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendLogin(User *u) = 0;
+ virtual void SendLogout(User *u) = 0;
+
+ /** Send a channel creation message to the uplink.
+ * On most TS6 IRCds this is a SJOIN with no nick
+ */
+ virtual void SendChannel(Channel *c) { }
+};
+
+class CoreExport IRCdMessage
+{
+ public:
+ virtual bool On436(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnAway(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnJoin(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnKick(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnKill(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnMode(const Anope::string &, const std::vector<Anope::string> &) = 0;
+ virtual bool OnUID(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnNick(const Anope::string &, const std::vector<Anope::string> &) = 0;
+ virtual bool OnPart(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnPing(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnPrivmsg(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnQuit(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnServer(const Anope::string &, const std::vector<Anope::string> &) = 0;
+ virtual bool OnSQuit(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnTopic(const Anope::string &, const std::vector<Anope::string> &) = 0;
+ virtual bool OnWhois(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnCapab(const Anope::string &, const std::vector<Anope::string> &);
+ virtual bool OnSJoin(const Anope::string &, const std::vector<Anope::string> &) = 0;
+ virtual bool OnError(const Anope::string &, const std::vector<Anope::string> &);
+};
+
+extern IRCDVar *ircd;
+extern IRCDProto *ircdproto;
+extern IRCdMessage *ircdmessage;
+
+extern void pmodule_ircd_proto(IRCDProto *);
+extern void pmodule_ircd_var(IRCDVar *ircdvar);
+extern void pmodule_ircd_message(IRCdMessage *message);
+
+#endif // PROTOCOL_H
diff --git a/include/regchannel.h b/include/regchannel.h
index 0cd890402..614b98f19 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -9,6 +9,13 @@
#ifndef REGCHANNEL_H
#define REGCHANNEL_H
+#include "botserv.h"
+#include "memo.h"
+#include "modes.h"
+#include "extensible.h"
+#include "logger.h"
+#include "modules.h"
+
typedef Anope::insensitive_map<ChannelInfo *> registered_channel_map;
extern CoreExport registered_channel_map RegisteredChannelList;
@@ -429,25 +436,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
void ClearLevels();
};
-/** A timer used to keep the BotServ bot/ChanServ in the channel
- * after kicking the last user in a channel
- */
-class CoreExport ChanServTimer : public Timer
-{
- private:
- dynamic_reference<Channel> c;
-
- public:
- /** Default constructor
- * @param chan The channel
- */
- ChanServTimer(Channel *chan);
-
- /** Called when the delay is up
- * @param The current time
- */
- void Tick(time_t);
-};
+extern void check_modes(Channel *c);
+extern ChannelInfo *cs_findchan(const Anope::string &chan);
+extern bool IsFounder(User *user, ChannelInfo *ci);
+extern void update_cs_lastseen(User *user, ChannelInfo *ci);
+extern int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret);
#endif // REGCHANNEL_H
diff --git a/include/serialize.h b/include/serialize.h
index 752f26bfa..891af726f 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -1,6 +1,22 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ */
+
#ifndef SERIALIZE_H
#define SERIALIZE_H
+#include <sstream>
+
+#include "anope.h"
+
namespace Serialize
{
enum DataType
@@ -8,58 +24,34 @@ namespace Serialize
DT_TEXT,
DT_INT
};
+}
+
+class stringstream : public std::stringstream
+{
+ private:
+ Serialize::DataType type;
+ bool key;
+ unsigned _max;
- class stringstream : public std::stringstream
+ public:
+ stringstream();
+ stringstream(const stringstream &ss);
+ Anope::string astr() const;
+ template<typename T> std::istream &operator>>(T &val)
{
- private:
- DataType type;
- bool key;
- unsigned _max;
-
- public:
- stringstream() : std::stringstream(), type(DT_TEXT), key(false), _max(0) { }
- stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(DT_TEXT), key(false), _max(0) { }
- Anope::string astr() const { return this->str(); }
- template<typename T> std::istream &operator>>(T &val)
- {
- std::istringstream is(this->str());
- is >> val;
- return *this;
- }
- std::istream &operator>>(Anope::string &val)
- {
- val = this->str();
- return *this;
- }
- stringstream &setType(DataType t)
- {
- this->type = t;
- return *this;
- }
- DataType getType() const
- {
- return this->type;
- }
- stringstream &setKey()
- {
- this->key = true;
- return *this;
- }
- bool getKey() const
- {
- return this->key;
- }
- stringstream &setMax(unsigned m)
- {
- this->_max = m;
- return *this;
- }
- unsigned getMax() const
- {
- return this->_max;
- }
- };
-}
+ std::istringstream is(this->str());
+ is >> val;
+ return *this;
+ }
+ std::istream &operator>>(Anope::string &val);
+ stringstream &setType(Serialize::DataType t);
+ Serialize::DataType getType() const;
+ stringstream &setKey();
+ bool getKey() const;
+ stringstream &setMax(unsigned m);
+ unsigned getMax() const;
+};
+
extern void RegisterTypes();
@@ -71,40 +63,20 @@ class CoreExport Serializable
std::list<Serializable *>::iterator s_iter;
protected:
- Serializable()
- {
- if (serizliable_items == NULL)
- serizliable_items = new std::list<Serializable *>();
- serizliable_items->push_front(this);
- this->s_iter = serizliable_items->begin();
- }
+ Serializable();
+ Serializable(const Serializable &);
- Serializable(const Serializable &)
- {
- serizliable_items->push_front(this);
- this->s_iter = serizliable_items->begin();
- }
+ virtual ~Serializable();
- virtual ~Serializable()
- {
- serizliable_items->erase(this->s_iter);
- }
-
- Serializable &operator=(const Serializable &)
- {
- return *this;
- }
+ Serializable &operator=(const Serializable &);
public:
- typedef std::map<Anope::string, Serialize::stringstream> serialized_data;
+ typedef std::map<Anope::string, stringstream> serialized_data;
virtual Anope::string serialize_name() const = 0;
virtual serialized_data serialize() = 0;
- static const std::list<Serializable *> &GetItems()
- {
- return *serizliable_items;
- }
+ static const std::list<Serializable *> &GetItems();
};
class CoreExport SerializeType
@@ -118,42 +90,16 @@ class CoreExport SerializeType
unserialize_func unserialize;
public:
- SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f)
- {
- type_order.push_back(this->name);
- types[this->name] = this;
- }
+ SerializeType(const Anope::string &n, unserialize_func f);
+ ~SerializeType();
- ~SerializeType()
- {
- std::vector<Anope::string>::iterator it = std::find(type_order.begin(), type_order.end(), this->name);
- if (it != type_order.end())
- type_order.erase(it);
- types.erase(this->name);
- }
+ const Anope::string &GetName();
- const Anope::string &GetName()
- {
- return this->name;
- }
+ void Create(Serializable::serialized_data &data);
- void Create(Serializable::serialized_data &data)
- {
- this->unserialize(data);
- }
+ static SerializeType *Find(const Anope::string &name);
- static SerializeType *Find(const Anope::string &name)
- {
- Anope::map<SerializeType *>::iterator it = types.find(name);
- if (it != types.end())
- return it->second;
- return NULL;
- }
-
- static const std::vector<Anope::string> &GetTypeOrder()
- {
- return type_order;
- }
+ static const std::vector<Anope::string> &GetTypeOrder();
};
#endif // SERIALIZE_H
diff --git a/include/servers.h b/include/servers.h
index acdbfaa06..c2e56dbde 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -1,6 +1,9 @@
#ifndef SERVERS_H
#define SERVERS_H
+#include "services.h"
+#include "anope.h"
+
/* Anope */
extern CoreExport Server *Me;
diff --git a/include/service.h b/include/service.h
new file mode 100644
index 000000000..f9e36ff40
--- /dev/null
+++ b/include/service.h
@@ -0,0 +1,110 @@
+/*
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#ifndef SERVICE_H
+#define SERVICE_H
+
+#include "services.h"
+#include "anope.h"
+#include "modules.h"
+
+class CoreExport Service : public Base
+{
+ static Anope::map<Anope::map<Service *> > services;
+ public:
+ static Service *FindService(const Anope::string &t, const Anope::string &n)
+ {
+ Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
+ if (it != services.end())
+ {
+ Anope::map<Service *>::iterator it2 = it->second.find(n);
+ if (it2 != it->second.end())
+ return it2->second;
+ }
+
+ return NULL;
+ }
+
+ static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
+ {
+ std::vector<Anope::string> keys;
+ Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
+ if (it != services.end())
+ for (Anope::map<Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
+ keys.push_back(it2->first);
+ return keys;
+ }
+
+ Module *owner;
+ Anope::string type;
+ Anope::string name;
+
+ Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
+ {
+ this->Register();
+ }
+
+ virtual ~Service()
+ {
+ this->Unregister();
+ }
+
+ void Register()
+ {
+ Anope::map<Service *> &smap = services[this->type];
+ if (smap.find(this->name) != smap.end())
+ throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
+ smap[this->name] = this;
+ }
+
+ void Unregister()
+ {
+ Anope::map<Service *> &smap = services[this->type];
+ smap.erase(this->name);
+ if (smap.empty())
+ services.erase(this->type);
+ }
+};
+
+template<typename T>
+class service_reference : public dynamic_reference<T>
+{
+ Anope::string type;
+ Anope::string name;
+
+ public:
+ service_reference(const Anope::string &t, const Anope::string &n) : dynamic_reference<T>(NULL), type(t), name(n)
+ {
+ }
+
+ inline void operator=(const Anope::string &n)
+ {
+ this->name = n;
+ }
+
+ operator bool()
+ {
+ if (this->invalid)
+ {
+ this->invalid = false;
+ this->ref = NULL;
+ }
+ if (!this->ref)
+ {
+ this->ref = static_cast<T *>(Service::FindService(this->type, this->name));
+ if (this->ref)
+ this->ref->AddReference(this);
+ }
+ return this->ref;
+ }
+};
+
+#endif // SERVICE_H
+
diff --git a/include/services.h b/include/services.h
index 37b8df1ad..abe262cad 100644
--- a/include/services.h
+++ b/include/services.h
@@ -14,103 +14,24 @@
#ifndef SERVICES_H
#define SERVICES_H
-/*************************************************************************/
-
#include "sysconf.h"
#define BUFSIZE 1024
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
#include <stdexcept>
-#include <string.h>
+#include <string.h>
#if HAVE_STRINGS_H
# include <strings.h>
#endif
-#include <signal.h>
-#include <time.h>
-#include <errno.h>
-#include <limits.h>
-
-#include <sys/stat.h> /* for umask() on some systems */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <typeinfo>
-#include <ctype.h>
-
-#if GETTEXT_FOUND
-# include <libintl.h>
-#endif
-#define _(x) x
-
-#ifndef _WIN32
-# include <unistd.h>
-# include <grp.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-# include <sys/socket.h>
-# include <sys/time.h>
-# include <sys/wait.h>
-# include <dirent.h>
-# include <pthread.h>
-# define DllExport
-# define CoreExport
-# define MARK_DEPRECATED __attribute((deprecated))
-#else
-# include "anope_windows.h"
-#endif
-
-/* Telling compilers about printf()-like functions: */
-#ifdef __GNUC__
-# define FORMAT(type, fmt, start) __attribute__((format(type, fmt, start)))
-#else
-# define FORMAT(type, fmt, start)
-#endif
-
-/** This definition is used as shorthand for the various classes
- * and functions needed to make a module loadable by the OS.
- * It defines the class factory and external AnopeInit and AnopeFini functions.
- */
-#ifdef _WIN32
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
- extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
- { \
- return new x(modname, creator); \
- } \
- BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
- { \
- return TRUE; \
- } \
- extern "C" DllExport void AnopeFini(x *); \
- extern "C" void AnopeFini(x *m) \
- { \
- delete m; \
- }
-#else
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
- { \
- return new x(modname, creator); \
- } \
- extern "C" DllExport void AnopeFini(x *m) \
- { \
- delete m; \
- }
-#endif
-
-/* Miscellaneous definitions. */
-#include "hashcomp.h"
-
/* Pull in the various bits of STL */
#include <iostream>
#include <fstream>
#include <sstream>
-#include <string>
#include <map>
#include <exception>
#include <list>
@@ -118,616 +39,19 @@
#include <deque>
#include <bitset>
#include <set>
+#include <algorithm>
-#include "anope.h"
-
-/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
- * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
- * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
- * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
- * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
- */
-class CoreException : public std::exception
-{
- protected:
- /** Holds the error message to be displayed
- */
- Anope::string err;
- /** Source of the exception
- */
- Anope::string source;
- public:
- /** Default constructor, just uses the error mesage 'Core threw an exception'.
- */
- CoreException() : err("Core threw an exception"), source("The core") { }
- /** This constructor can be used to specify an error message before throwing.
- */
- CoreException(const Anope::string &message) : err(message), source("The core") { }
- /** This constructor can be used to specify an error message before throwing,
- * and to specify the source of the exception.
- */
- CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
- /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
- * Actually no, it does nothing. Never mind.
- * @throws Nothing!
- */
- virtual ~CoreException() throw() { }
- /** Returns the reason for the exception.
- * The module should probably put something informative here as the user will see this upon failure.
- */
- virtual const Anope::string &GetReason() const
- {
- return err;
- }
-
- virtual const Anope::string &GetSource() const
- {
- return source;
- }
-};
-
-class FatalException : public CoreException
-{
- public:
- FatalException(const Anope::string &reason = "") : CoreException(reason) { }
+#include "defs.h"
- virtual ~FatalException() throw() { }
-};
-
-class ModuleException : public CoreException
-{
- public:
- /** Default constructor, just uses the error mesage 'Module threw an exception'.
- */
- ModuleException() : CoreException("Module threw an exception", "A Module") { }
-
- /** This constructor can be used to specify an error message before throwing.
- */
- ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
- /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
- * Actually no, it does nothing. Never mind.
- * @throws Nothing!
- */
- virtual ~ModuleException() throw() { }
-};
+#define _(x) x
-/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast
- * for debug builds and static_cast on releass builds to speed up the program
- * because dynamic_cast relies on RTTI.
- */
-template<typename T, typename O> inline T debug_cast(O ptr)
-{
-#ifdef DEBUG_BUILD
- T ret = dynamic_cast<T>(ptr);
- if (ptr != NULL && ret == NULL)
- throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
- return ret;
+#ifndef _WIN32
+# define DllExport
+# define CoreExport
+# define MARK_DEPRECATED __attribute((deprecated))
#else
- return static_cast<T>(ptr);
+# include "anope_windows.h"
#endif
-}
-
-/*************************************************************************/
-
-/** Class with the ability to keep flags on items, they should extend from this
- * where T is an enum.
- */
-template<typename T, size_t Size = 32> class Flags
-{
- protected:
- std::bitset<Size> Flag_Values;
- const Anope::string *Flag_Strings;
-
- public:
- Flags() : Flag_Strings(NULL) { }
- Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
-
- /** Add a flag to this item
- * @param Value The flag
- */
- void SetFlag(T Value)
- {
- Flag_Values[Value] = true;
- }
-
- /** Remove a flag from this item
- * @param Value The flag
- */
- void UnsetFlag(T Value)
- {
- Flag_Values[Value] = false;
- }
-
- /** Check if this item has a flag
- * @param Value The flag
- * @return true or false
- */
- bool HasFlag(T Value) const
- {
- return Flag_Values.test(Value);
- }
-
- /** Check how many flags are set
- * @return The number of flags set
- */
- size_t FlagCount() const
- {
- return Flag_Values.count();
- }
-
- /** Unset all of the flags
- */
- void ClearFlags()
- {
- Flag_Values.reset();
- }
-
- Anope::string ToString()
- {
- std::vector<Anope::string> v = ToVector();
- Anope::string flag_buf;
- for (unsigned i = 0; i < v.size(); ++i)
- flag_buf += v[i] + " ";
- flag_buf.trim();
- return flag_buf;
- }
-
- void FromString(const Anope::string &str)
- {
- spacesepstream sep(str);
- Anope::string buf;
- std::vector<Anope::string> v;
-
- while (sep.GetToken(buf))
- v.push_back(buf);
-
- FromVector(v);
- }
-
- std::vector<Anope::string> ToVector()
- {
- std::vector<Anope::string> ret;
- for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
- if (this->HasFlag(static_cast<T>(i)))
- ret.push_back(this->Flag_Strings[i]);
- return ret;
- }
-
- void FromVector(const std::vector<Anope::string> &strings)
- {
- this->ClearFlags();
-
- for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
- for (unsigned j = 0; j < strings.size(); ++j)
- if (this->Flag_Strings[i] == strings[j])
- this->SetFlag(static_cast<T>(i));
- }
-};
-
-class Module;
-
-class CoreExport Service : public Base
-{
- static Anope::map<Anope::map<Service *> > services;
- public:
- static Service *FindService(const Anope::string &t, const Anope::string &n)
- {
- Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
- if (it != services.end())
- {
- Anope::map<Service *>::iterator it2 = it->second.find(n);
- if (it2 != it->second.end())
- return it2->second;
- }
-
- return NULL;
- }
-
- static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
- {
- std::vector<Anope::string> keys;
- Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
- if (it != services.end())
- for (Anope::map<Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
- keys.push_back(it2->first);
- return keys;
- }
-
- Module *owner;
- Anope::string type;
- Anope::string name;
-
- Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
- {
- this->Register();
- }
-
- virtual ~Service()
- {
- this->Unregister();
- }
-
- void Register()
- {
- Anope::map<Service *> &smap = services[this->type];
- if (smap.find(this->name) != smap.end())
- throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
- smap[this->name] = this;
- }
-
- void Unregister()
- {
- Anope::map<Service *> &smap = services[this->type];
- smap.erase(this->name);
- if (smap.empty())
- services.erase(this->type);
- }
-};
-
-#include "sockets.h"
-#include "socketengine.h"
-#include "extensible.h"
-#include "timers.h"
-#include "dns.h"
-
-/*************************************************************************/
-
-class Signal : public Pipe
-{
- static std::vector<Signal *> SignalHandlers;
- static void SignalHandler(int signal);
-
- struct sigaction action, old;
- public:
- int signal;
-
- Signal(int s);
- ~Signal();
-
- virtual void OnNotify() = 0;
-};
-
-class ConvertException : public CoreException
-{
- public:
- ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
-
- virtual ~ConvertException() throw() { }
-};
-
-template<typename T> inline Anope::string stringify(const T &x)
-{
- std::ostringstream stream;
-
- if (!(stream << x))
- throw ConvertException("Stringify fail");
-
- return stream.str();
-}
-
-template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
-{
- leftover.clear();
- std::istringstream i(s.str());
- char c;
- bool res = i >> x;
- if (!res)
- throw ConvertException("Convert fail");
- if (failIfLeftoverChars)
- {
- if (i.get(c))
- throw ConvertException("Convert fail");
- }
- else
- {
- std::string left;
- getline(i, left);
- leftover = left;
- }
-}
-
-template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
-{
- Anope::string Unused;
- convert(s, x, Unused, failIfLeftoverChars);
-}
-
-template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
-{
- T x;
- convert(s, x, leftover, failIfLeftoverChars);
- return x;
-}
-
-template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
-{
- T x;
- convert(s, x, failIfLeftoverChars);
- return x;
-}
-
-/*************************************************************************/
-
-class User;
-class NickCore;
-class NickAlias;
-class BotInfo;
-class ChannelInfo;
-class Channel;
-class Server;
-class Entry;
-
-#include "threadengine.h"
-#include "opertype.h"
-#include "modes.h"
-#include "serialize.h"
-
-/*************************************************************************/
-
-/* Protocol tweaks */
-
-struct IRCDVar
-{
- const char *name; /* Name of the IRCd command */
- const char *pseudoclient_mode; /* Mode used by BotServ Bots */
- int svsnick; /* Supports SVSNICK */
- int vhost; /* Supports vhost */
- int snline; /* Supports SNline */
- int sqline; /* Supports SQline */
- int szline; /* Supports SZline */
- int join2msg; /* Join 2 Message */
- int chansqline; /* Supports Channel Sqlines */
- int quitonkill; /* IRCD sends QUIT when kill */
- int vident; /* Supports vidents */
- int svshold; /* Supports svshold */
- int tsonmode; /* Timestamp on mode changes */
- int omode; /* On the fly o:lines */
- int umode; /* change user modes */
- int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
- int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
- int sglineenforce;
- int ts6; /* ircd is TS6 */
- const char *globaltldprefix; /* TLD prefix used for Global */
- unsigned maxmodes; /* Max modes to send per line */
- int certfp; /* IRCd sends a SSL users certificate fingerprint */
-};
-
-/*************************************************************************/
-
-/** Memo Flags
- */
-enum MemoFlag
-{
- /* Memo is unread */
- MF_UNREAD,
- /* Sender requests a receipt */
- MF_RECEIPT
-};
-
-const Anope::string MemoFlagStrings[] = {
- "MF_UNREAD", "MF_RECEIPT", ""
-};
-
-/* Memo info structures. Since both nicknames and channels can have memos,
- * we encapsulate memo data in a MemoList to make it easier to handle. */
-class CoreExport Memo : public Flags<MemoFlag>, public Serializable
-{
- public:
- Memo();
-
- Anope::string serialize_name() const;
- serialized_data serialize();
- static void unserialize(serialized_data &);
-
- Anope::string owner;
- time_t time; /* When it was sent */
- Anope::string sender;
- Anope::string text;
-};
-
-struct CoreExport MemoInfo
-{
- int16_t memomax;
- std::vector<Memo *> memos;
- std::vector<Anope::string> ignores;
-
- unsigned GetIndex(Memo *m) const;
- void Del(unsigned index);
- void Del(Memo *m);
- bool HasIgnore(User *u);
-};
-
-struct Session
-{
- Anope::string host; /* Host of the session */
- unsigned count; /* Number of clients with this host */
- unsigned hits; /* Number of subsequent kills for a host */
-};
-
-struct Exception;
-
-/*************************************************************************/
-
-class CoreExport HostInfo
-{
- private:
- Anope::string Ident;
- Anope::string Host;
- Anope::string Creator;
- time_t Time;
-
- public:
- /** Set a vhost for the user
- * @param ident The ident
- * @param host The host
- * @param creator Who created the vhost
- * @param time When the vhost was craated
- */
- void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
-
- /** Remove a users vhost
- **/
- void RemoveVhost();
-
- /** Check if the user has a vhost
- * @return true or false
- */
- bool HasVhost() const;
-
- /** Retrieve the vhost ident
- * @return the ident
- */
- const Anope::string &GetIdent() const;
-
- /** Retrieve the vhost host
- * @return the host
- */
- const Anope::string &GetHost() const;
-
- /** Retrieve the vhost creator
- * @return the creator
- */
- const Anope::string &GetCreator() const;
-
- /** Retrieve when the vhost was crated
- * @return the time it was created
- */
- time_t GetTime() const;
-};
-
-/* BotServ SET flags */
-enum BotServFlag
-{
- BS_BEGIN,
- /* BotServ won't kick ops */
- BS_DONTKICKOPS,
- /* BotServ won't kick voices */
- BS_DONTKICKVOICES,
- /* BotServ bot accepts fantasy commands */
- BS_FANTASY,
- /* BotServ should show greets */
- BS_GREET,
- /* BotServ bots are not allowed to be in this channel */
- BS_NOBOT,
- /* BotServ kicks for bolds */
- BS_KICK_BOLDS,
- /* BotServ kicks for colors */
- BS_KICK_COLORS,
- /* BOtServ kicks for reverses */
- BS_KICK_REVERSES,
- /* BotServ kicks for underlines */
- BS_KICK_UNDERLINES,
- /* BotServ kicks for badwords */
- BS_KICK_BADWORDS,
- /* BotServ kicks for caps */
- BS_KICK_CAPS,
- /* BotServ kicks for flood */
- BS_KICK_FLOOD,
- /* BotServ kicks for repeating */
- BS_KICK_REPEAT,
- /* BotServ kicks for italics */
- BS_KICK_ITALICS,
- /* BotServ kicks for amsgs */
- BS_KICK_AMSGS,
- BS_END
-};
-
-const Anope::string BotServFlagStrings[] = {
- "BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
- "KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
- "KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
- "MSG_NOTICEOPS", ""
-};
-
-/* Indices for TTB (Times To Ban) */
-enum
-{
- TTB_BOLDS,
- TTB_COLORS,
- TTB_REVERSES,
- TTB_UNDERLINES,
- TTB_BADWORDS,
- TTB_CAPS,
- TTB_FLOOD,
- TTB_REPEAT,
- TTB_ITALICS,
- TTB_AMSGS,
- TTB_SIZE
-};
-
-#include "access.h"
-#include "regchannel.h"
-
-/*************************************************************************/
-
-/* This structure stocks ban data since it must not be removed when
- * user is kicked.
- */
-
-#include "users.h"
-#include "account.h"
-#include "commands.h"
-#include "bots.h"
-#include "channels.h"
-
-/** Channelban type flags
- */
-enum EntryType
-{
- ENTRYTYPE_NONE,
- ENTRYTYPE_CIDR,
- ENTRYTYPE_NICK_WILD,
- ENTRYTYPE_NICK,
- ENTRYTYPE_USER_WILD,
- ENTRYTYPE_USER,
- ENTRYTYPE_HOST_WILD,
- ENTRYTYPE_HOST
-};
-
-class CoreExport Entry : public Flags<EntryType>
-{
- ChannelModeName modename;
-
- public:
- unsigned char cidr_len;
- Anope::string mask;
- Anope::string nick, user, host;
-
- /** Constructor
- * @param _host A full nick!ident@host/cidr mask
- * @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode
- */
- Entry(ChannelModeName mode, const Anope::string &_host);
-
- /** Get the banned mask for this entry
- * @return The mask
- */
- const Anope::string GetMask();
-
- /** Check if this entry matches a user
- * @param u The user
- * @param full True to match against a users real host and IP
- * @return true on match
- */
- bool Matches(User *u, bool full = false) const;
-};
-
-/*************************************************************************/
-
-/* Mail data */
-
-struct MailInfo
-{
- FILE *pipe;
- User *sender;
- NickCore *recipient;
-};
-
-/*************************************************************************/
-
-/* Defcon */
-
-/*************************************************************************/
/**
* RFC: defination of a valid nick
@@ -738,215 +62,4 @@ struct MailInfo
**/
#define isvalidnick(c) (isalnum(c) || ((c) >= '\x5B' && (c) <= '\x60') || ((c) >= '\x7B' && (c) <= '\x7D') || (c) == '-')
-/*************************************************************************/
-
-/*
- * Forward declaration reqired, because the base IRCDProto class uses some crap from in here.
- */
-class IRCDProto;
-class IRCdMessage;
-struct Uplink;
-class ServerConfig;
-class ConfigurationFile;
-class XLine;
-
-#include "extern.h"
-#include "language.h"
-#include "mail.h"
-#include "servers.h"
-#include "logger.h"
-#include "config.h"
-
-class CoreExport IRCDProto
-{
- private:
- virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &) = 0;
- virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &) = 0;
- virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &) = 0;
- virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &) = 0;
- virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
- virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
- virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
- virtual void SendQuitInternal(const User *u, const Anope::string &buf);
- virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
- virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
- virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
- virtual void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf);
- public:
- virtual ~IRCDProto() { }
-
- virtual void SendSVSNOOP(const Server *, bool) { }
- virtual void SendTopic(BotInfo *, Channel *) = 0;
- virtual void SendVhostDel(User *) { }
- virtual void SendAkill(User *, const XLine *) = 0;
- virtual void SendAkillDel(const XLine *) = 0;
- virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
- virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
- virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
- virtual void SendClientIntroduction(const User *u) = 0;
- virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
- virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg);
- virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg);
-
- virtual void SendQuit(const User *u, const char *fmt, ...);
- virtual void SendPing(const Anope::string &servname, const Anope::string &who);
- virtual void SendPong(const Anope::string &servname, const Anope::string &who);
- virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
- virtual void SendSQLineDel(const XLine *x) { }
- virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
- virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
- virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
- virtual void SendSQLine(User *, const XLine *x) { }
- virtual void SendSquit(Server *, const Anope::string &message);
- virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
- virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
- virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
- virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
- virtual void SendConnect() = 0;
- virtual void SendSVSHold(const Anope::string &) { }
- virtual void SendSVSHoldDel(const Anope::string &) { }
- virtual void SendSGLineDel(const XLine *) { }
- virtual void SendSZLineDel(const XLine *) { }
- virtual void SendSZLine(User *u, const XLine *) { }
- virtual void SendSGLine(User *, const XLine *) { }
- virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
- virtual void SendSVSJoin(const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &) { }
- virtual void SendSWhois(const Anope::string &, const Anope::string &, const Anope::string &) { }
- virtual void SendBOB() { }
- virtual void SendEOB() { }
- virtual void SendServer(const Server *) = 0;
- virtual bool IsNickValid(const Anope::string &) { return true; }
- virtual bool IsChannelValid(const Anope::string &);
- virtual void SendNumeric(const Anope::string &source, int numeric, const Anope::string &dest, const char *fmt, ...);
- virtual void SendLogin(User *u) = 0;
- virtual void SendLogout(User *u) = 0;
-
- /** Send a channel creation message to the uplink.
- * On most TS6 IRCds this is a SJOIN with no nick
- */
- virtual void SendChannel(Channel *c) { }
-};
-
-class CoreExport IRCdMessage
-{
- public:
- virtual bool On436(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnAway(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnJoin(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnKick(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnKill(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnMode(const Anope::string &, const std::vector<Anope::string> &) = 0;
- virtual bool OnUID(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnNick(const Anope::string &, const std::vector<Anope::string> &) = 0;
- virtual bool OnPart(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnPing(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnPrivmsg(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnQuit(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnServer(const Anope::string &, const std::vector<Anope::string> &) = 0;
- virtual bool OnSQuit(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnTopic(const Anope::string &, const std::vector<Anope::string> &) = 0;
- virtual bool OnWhois(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnCapab(const Anope::string &, const std::vector<Anope::string> &);
- virtual bool OnSJoin(const Anope::string &, const std::vector<Anope::string> &) = 0;
- virtual bool OnError(const Anope::string &, const std::vector<Anope::string> &);
-};
-
-/*************************************************************************/
-
-struct Uplink
-{
- Anope::string host;
- unsigned port;
- Anope::string password;
- bool ipv6;
-
- Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
- bool operator==(const Uplink &other) const
- {
- if (this->host != other.host)
- return false;
- if (this->port != other.port)
- return false;
- if (this->password != other.password)
- return false;
- if (this->ipv6 != other.ipv6)
- return false;
- return true;
- }
- inline bool operator!=(const Uplink &other) const { return !(*this == other); }
-};
-
-/** A class to process numbered lists (passed to most DEL/LIST/VIEW commands).
- * The function HandleNumber is called for every number in the list. Note that
- * if descending is true it gets called in descending order. This is so deleting
- * the index passed to the function from an array will not cause the other indexes
- * passed to the function to be incorrect. This keeps us from having to have an
- * 'in use' flag on everything.
- */
-class CoreExport NumberList
-{
- private:
- bool is_valid;
-
- std::set<unsigned> numbers;
-
- bool desc;
- public:
- /** Processes a numbered list
- * @param list The list
- * @param descending True to make HandleNumber get called with numbers in descending order
- */
- NumberList(const Anope::string &list, bool descending);
-
- /** Destructor, does nothing
- */
- virtual ~NumberList();
-
- /** Should be called after the constructors are done running. This calls the callbacks.
- */
- void Process();
-
- /** Called with a number from the list
- * @param Number The number
- */
- virtual void HandleNumber(unsigned Number);
-
- /** Called when there is an error with the numbered list
- * Return false to immediatly stop processing the list and return
- * This is all done before we start calling HandleNumber, so no numbers will have been processed yet
- * @param list The list
- * @return false to stop processing
- */
- virtual bool InvalidRange(const Anope::string &list);
-};
-
-class CoreExport ListFormatter
-{
- public:
- typedef std::map<Anope::string, Anope::string> ListEntry;
- private:
- std::vector<Anope::string> columns;
- std::vector<ListEntry> entries;
- public:
- ListFormatter &addColumn(const Anope::string &name);
- void addEntry(const ListEntry &entry);
- bool isEmpty() const;
- void Process(std::vector<Anope::string> &);
-};
-
-class CoreExport InfoFormatter
-{
- User *user;
- std::vector<std::pair<Anope::string, Anope::string> > replies;
- unsigned longest;
- public:
- InfoFormatter(User *u);
- void Process(std::vector<Anope::string> &);
- Anope::string &operator[](const Anope::string &key);
-};
-
-#endif /* SERVICES_H */
+#endif // SERVICES_H
diff --git a/include/signals.h b/include/signals.h
new file mode 100644
index 000000000..70fdead42
--- /dev/null
+++ b/include/signals.h
@@ -0,0 +1,49 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#ifndef SIGNAL_H
+#define SIGNAL_H
+
+#include <signal.h>
+
+#include "sockets.h"
+
+/** Represents a signal handler
+ */
+class Signal : public Pipe
+{
+ static std::vector<Signal *> SignalHandlers;
+ static void SignalHandler(int signal);
+
+ struct sigaction action, old;
+ public:
+ int signal;
+
+ /** Constructor
+ * @param s The signal to listen for
+ */
+ Signal(int s);
+ ~Signal();
+
+ /**
+ * Called when the signal is received.
+ * Note this is not *immediatly* called when the signal is received,
+ * but it is saved and called at a later time when we are not doing something
+ * important. This is always called on the main thread, even on systems that
+ * spawn threads for signals, like Windows.
+ */
+ virtual void OnNotify() = 0;
+};
+
+#endif
+
diff --git a/include/socketengine.h b/include/socketengine.h
index 947f27327..0cffec6b3 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -12,6 +12,8 @@
#ifndef SOCKETENGINE_H
#define SOCKETENGINE_H
+#include "services.h"
+
class CoreExport SocketEngine
{
public:
diff --git a/include/sockets.h b/include/sockets.h
index 126bd3f8a..eb990fd4f 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -12,6 +12,8 @@
#ifndef SOCKETS_H
#define SOCKETS_H
+#include <netinet/in.h>
+
#include "anope.h"
#define NET_BUFSIZE 65535
@@ -26,7 +28,7 @@ union CoreExport sockaddrs
/** Construct the object, sets everything to 0
*/
- sockaddrs();
+ sockaddrs(const Anope::string &address = "");
/** Memset the object to 0
*/
@@ -112,10 +114,6 @@ enum SocketFlag
static const Anope::string SocketFlagStrings[] = { "SF_DEAD", "SF_WRITABLE", "SF_CONNECTING", "SF_CONNECTED", "SF_ACCEPTING", "SF_ACCEPTED", "" };
-class Socket;
-class ClientSocket;
-class ListenSocket;
-class ConnectionSocket;
class CoreExport SocketIO
{
@@ -475,4 +473,8 @@ class CoreExport Pipe : public Socket
virtual void OnNotify();
};
+extern uint32_t TotalRead;
+extern uint32_t TotalWritten;
+extern SocketIO normalSocketIO;
+
#endif // SOCKET_H
diff --git a/include/threadengine.h b/include/threadengine.h
index b840092d4..5d1752a8f 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -1,7 +1,8 @@
#ifndef THREADENGINE_H
#define THREADENGINE_H
-class Thread;
+#include "sockets.h"
+#include "extensible.h"
class CoreExport Thread : public Pipe, public Extensible
{
diff --git a/include/timers.h b/include/timers.h
index c51d778f2..d5fc66fb0 100644
--- a/include/timers.h
+++ b/include/timers.h
@@ -11,13 +11,9 @@
#ifndef TIMERS_H
#define TIMERS_H
-#include "services.h"
-#include <time.h>
-#include <algorithm>
-#include <stdio.h>
-#include <stdlib.h>
+#include "anope.h"
-class CoreExport Timer : public Extensible
+class CoreExport Timer
{
private:
/** The time this was created
@@ -88,7 +84,7 @@ class CoreExport Timer : public Extensible
* This will ensure timers are not missed, as well as removing timers that have
* expired and allowing the addition of new ones.
*/
-class CoreExport TimerManager : public Extensible
+class CoreExport TimerManager
{
/** A list of timers
*/
diff --git a/include/uplink.h b/include/uplink.h
new file mode 100644
index 000000000..7f200d426
--- /dev/null
+++ b/include/uplink.h
@@ -0,0 +1,44 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#ifndef UPLINK_H
+#define UPLINK_H
+
+#include "sockets.h"
+
+class UplinkSocket : public ConnectionSocket, public BufferedSocket
+{
+ public:
+ UplinkSocket();
+ ~UplinkSocket();
+ bool Read(const Anope::string &);
+ void OnConnect();
+ void OnError(const Anope::string &);
+
+ class CoreExport Message
+ {
+ Anope::string source;
+ std::stringstream buffer;
+ public:
+ Message();
+ Message(const Anope::string &);
+ ~Message();
+ template<typename T> Message &operator<<(const T &val)
+ {
+ this->buffer << val;
+ return *this;
+ }
+ };
+};
+extern UplinkSocket *UplinkSock;
+
+#endif // UPLINK_H
+
diff --git a/include/users.h b/include/users.h
index 703e1ceb7..a6510235f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -8,6 +8,10 @@
#ifndef USERS_H
#define USERS_H
+#include "anope.h"
+#include "modes.h"
+#include "extensible.h"
+
extern CoreExport Anope::insensitive_map<User *> UserListByNick;
extern CoreExport Anope::map<User *> UserListByUID;
@@ -30,8 +34,9 @@ struct ChannelContainer
typedef std::list<ChannelContainer *> UChannelList;
+
/* Online user and channel data. */
-class CoreExport User : public Extensible
+class CoreExport User : public Base, public Extensible
{
protected:
Anope::string vident;
@@ -50,7 +55,7 @@ class CoreExport User : public Extensible
Anope::string chost; /* User's cloaked hostname */
Anope::string realname; /* Realname */
Anope::string fingerprint; /* SSL Fingerprint */
- sockaddrs ip; /* User's IP */
+ Anope::string ip; /* User's IP */
Server *server; /* Server user is connected to */
time_t timestamp; /* Timestamp of the nick */
time_t my_signon; /* When did _we_ see the user? */
@@ -296,4 +301,19 @@ class CoreExport User : public Extensible
void Kill(const Anope::string &source, const Anope::string &reason);
};
+extern int32_t opcnt;
+extern uint32_t maxusercnt, usercnt;
+extern time_t maxusertime;
+
+extern User *finduser(const Anope::string &nick);
+
+extern User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
+
+extern void do_umode(const Anope::string &user, const Anope::string &modes);
+extern void do_kill(User *user, const Anope::string &reason);
+
+extern bool matches_list(Channel *c, User *user, ChannelModeName mode);
+
+extern Anope::string create_mask(User *u);
+
#endif // USERS_H
diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp
index b8362cdda..44b2bf5e6 100644
--- a/modules/commands/hs_del.cpp
+++ b/modules/commands/hs_del.cpp
@@ -31,7 +31,7 @@ class CommandHSDel : public Command
{
Log(LOG_ADMIN, u, this) << "for user " << na->nick;
FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
- na->hostinfo.RemoveVhost();
+ na->RemoveVhost();
source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str());
}
else
@@ -69,7 +69,7 @@ class CommandHSDelAll : public Command
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
{
na = *it;
- na->hostinfo.RemoveVhost();
+ na->RemoveVhost();
}
Log(LOG_ADMIN, u, this) << "for all nicks in group " << nc->display;
source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str());
diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp
index 53efd3094..78c863a51 100644
--- a/modules/commands/hs_group.cpp
+++ b/modules/commands/hs_group.cpp
@@ -17,13 +17,13 @@ class CommandHSGroup : public Command
{
void Sync(NickAlias *na)
{
- if (!na || !na->hostinfo.HasVhost())
+ if (!na || !na->HasVhost())
return;
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
{
NickAlias *nick = *it;
- nick->hostinfo.SetVhost(na->hostinfo.GetIdent(), na->hostinfo.GetHost(), na->hostinfo.GetCreator());
+ nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
}
@@ -38,13 +38,13 @@ class CommandHSGroup : public Command
{
User *u = source.u;
NickAlias *na = findnick(u->nick);
- if (na && u->Account() == na->nc && na->hostinfo.HasVhost())
+ if (na && u->Account() == na->nc && na->HasVhost())
{
this->Sync(na);
- if (!na->hostinfo.GetIdent().empty())
- source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str());
+ if (!na->GetVhostIdent().empty())
+ source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
else
- source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), u->Account()->display.c_str(), na->hostinfo.GetHost().c_str());
+ source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), u->Account()->display.c_str(), na->GetVhostHost().c_str());
}
else
source.Reply(HOST_NOT_ASSIGNED);
diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp
index 54295f52f..acba0528f 100644
--- a/modules/commands/hs_list.cpp
+++ b/modules/commands/hs_list.cpp
@@ -63,24 +63,24 @@ class CommandHSList : public Command
{
NickAlias *na = it->second;
- if (!na->hostinfo.HasVhost())
+ if (!na->HasVhost())
continue;
if (!key.empty() && key[0] != '#')
{
- if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key)) && display_counter < Config->NSListMax)
+ if ((Anope::Match(na->nick, key) || Anope::Match(na->GetVhostHost(), key)) && display_counter < Config->NSListMax)
{
++display_counter;
ListFormatter::ListEntry entry;
entry["Number"] = stringify(display_counter);
entry["Nick"] = na->nick;
- if (!na->hostinfo.GetIdent().empty())
- entry["Vhost"] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost();
+ if (!na->GetVhostIdent().empty())
+ entry["Vhost"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
else
- entry["Vhost"] = na->hostinfo.GetHost();
- entry["Creator"] = na->hostinfo.GetCreator();
- entry["Created"] = do_strftime(na->hostinfo.GetTime());
+ entry["Vhost"] = na->GetVhostHost();
+ entry["Creator"] = na->GetVhostCreator();
+ entry["Created"] = do_strftime(na->GetVhostCreated());
list.addEntry(entry);
}
}
@@ -96,12 +96,12 @@ class CommandHSList : public Command
ListFormatter::ListEntry entry;
entry["Number"] = stringify(display_counter);
entry["Nick"] = na->nick;
- if (!na->hostinfo.GetIdent().empty())
- entry["Vhost"] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost();
+ if (!na->GetVhostIdent().empty())
+ entry["Vhost"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
else
- entry["Vhost"] = na->hostinfo.GetHost();
- entry["Creator"] = na->hostinfo.GetCreator();
- entry["Created"] = do_strftime(na->hostinfo.GetTime());
+ entry["Vhost"] = na->GetVhostHost();
+ entry["Creator"] = na->GetVhostCreator();
+ entry["Created"] = do_strftime(na->GetVhostCreated());
list.addEntry(entry);
}
}
diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp
index 46a83a4e5..45a8befd3 100644
--- a/modules/commands/hs_off.cpp
+++ b/modules/commands/hs_off.cpp
@@ -27,7 +27,7 @@ class CommandHSOff : public Command
User *u = source.u;
NickAlias *na = findnick(u->nick);
- if (!na || !na->hostinfo.HasVhost())
+ if (!na || !na->HasVhost())
source.Reply(HOST_NOT_ASSIGNED);
else
{
diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp
index 788808e7c..2c7d12f41 100644
--- a/modules/commands/hs_on.cpp
+++ b/modules/commands/hs_on.cpp
@@ -26,20 +26,20 @@ class CommandHSOn : public Command
{
User *u = source.u;
NickAlias *na = findnick(u->nick);
- if (na && u->Account() == na->nc && na->hostinfo.HasVhost())
+ if (na && u->Account() == na->nc && na->HasVhost())
{
- if (!na->hostinfo.GetIdent().empty())
- source.Reply(_("Your vhost of \002%s\002@\002%s\002 is now activated."), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str());
+ if (!na->GetVhostIdent().empty())
+ source.Reply(_("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
else
- source.Reply(_("Your vhost of \002%s\002 is now activated."), na->hostinfo.GetHost().c_str());
- Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->hostinfo.GetIdent().empty() ? na->hostinfo.GetIdent() + "@" : "") << na->hostinfo.GetHost();
- ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost());
+ source.Reply(_("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str());
+ Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost();
+ ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
if (ircd->vhost)
- u->vhost = na->hostinfo.GetHost();
+ u->vhost = na->GetVhostHost();
if (ircd->vident)
{
- if (!na->hostinfo.GetIdent().empty())
- u->SetVIdent(na->hostinfo.GetIdent());
+ if (!na->GetVhostIdent().empty())
+ u->SetVIdent(na->GetVhostIdent());
}
u->UpdateHost();
}
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp
index 634dec06c..d5f63d175 100644
--- a/modules/commands/hs_request.cpp
+++ b/modules/commands/hs_request.cpp
@@ -192,7 +192,7 @@ class CommandHSActivate : public Command
HostRequest *req = na ? na->GetExt<HostRequest *>("hs_request") : NULL;
if (req)
{
- na->hostinfo.SetVhost(req->ident, req->host, u->nick, req->time);
+ na->SetVhost(req->ident, req->host, u->nick, req->time);
FOREACH_MOD(I_OnSetVhost, OnSetVhost(na));
if (HSRequestMemoUser && memoserv)
diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp
index e305c3b33..d648952f7 100644
--- a/modules/commands/hs_set.cpp
+++ b/modules/commands/hs_set.cpp
@@ -82,7 +82,7 @@ class CommandHSSet : public Command
Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host;
- na->hostinfo.SetVhost(user, host, u->nick);
+ na->SetVhost(user, host, u->nick);
FOREACH_MOD(I_OnSetVhost, OnSetVhost(na));
if (!user.empty())
source.Reply(_("VHost for \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str());
@@ -106,13 +106,13 @@ class CommandHSSetAll : public Command
{
void Sync(NickAlias *na)
{
- if (!na || !na->hostinfo.HasVhost())
+ if (!na || !na->HasVhost())
return;
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
{
NickAlias *nick = *it;
- nick->hostinfo.SetVhost(na->hostinfo.GetIdent(), na->hostinfo.GetHost(), na->hostinfo.GetCreator());
+ nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
}
@@ -183,7 +183,7 @@ class CommandHSSetAll : public Command
Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host;
- na->hostinfo.SetVhost(user, host, u->nick);
+ na->SetVhost(user, host, u->nick);
this->Sync(na);
FOREACH_MOD(I_OnSetVhost, OnSetVhost(na));
if (!user.empty())
diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp
index 2acbcb91f..a58cb5248 100644
--- a/modules/commands/ms_ignore.cpp
+++ b/modules/commands/ms_ignore.cpp
@@ -11,6 +11,7 @@
/*************************************************************************/
+
#include "module.h"
#include "memoserv.h"
diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp
index 065762f8b..514757037 100644
--- a/modules/commands/ns_info.cpp
+++ b/modules/commands/ns_info.cpp
@@ -101,12 +101,12 @@ class CommandNSInfo : public Command
if (show_hidden)
{
- if (na->hostinfo.HasVhost())
+ if (na->HasVhost())
{
- if (ircd->vident && !na->hostinfo.GetIdent().empty())
- info[_("VHost")] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost();
+ if (ircd->vident && !na->GetVhostIdent().empty())
+ info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost();
else
- info[_("VHost")] = na->hostinfo.GetHost();
+ info[_("VHost")] = na->GetVhostHost();
}
if (!na->nc->greet.empty())
diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp
index 7d20c5539..b5b184740 100644
--- a/modules/commands/os_forbid.cpp
+++ b/modules/commands/os_forbid.cpp
@@ -277,7 +277,7 @@ class OSForbid : public Module
if (!c->HasFlag(CH_INHABIT))
{
/* Join ChanServ and set a timer for this channel to part ChanServ later */
- new ChanServTimer(c);
+ c->Hold();
/* Set +si to prevent rejoin */
c->SetMode(NULL, CMODE_NOEXTERNAL);
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index 2e7573674..26d11c047 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -157,7 +157,7 @@ class CommandOSUserList : public Command
if (!pattern.empty())
{
- Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + (u2->ip() ? u2->ip.addr() : u2->host);
+ Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + (!u2->ip.empty() ? u2->ip : u2->host);
if (!Anope::Match(mask, pattern) && !Anope::Match(mask2, pattern) && !Anope::Match(mask3, pattern))
continue;
if (!Modes.empty())
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index 12267b651..d89fbe1a6 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -38,7 +38,7 @@ class MySessionService : public SessionService
for (std::vector<Exception *>::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it)
{
Exception *e = *it;
- if (Anope::Match(u->host, e->mask) || (u->ip() && Anope::Match(u->ip.addr(), e->mask)))
+ if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip, e->mask))
return e;
}
return NULL;
diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h
index 67927410d..0d2cee9ad 100644
--- a/modules/commands/os_session.h
+++ b/modules/commands/os_session.h
@@ -1,6 +1,13 @@
#ifndef OS_SESSION_H
#define OS_SESSION_H
+struct Session
+{
+ Anope::string host; /* Host of the session */
+ unsigned count; /* Number of clients with this host */
+ unsigned hits; /* Number of subsequent kills for a host */
+};
+
struct Exception : Serializable
{
Anope::string mask; /* Hosts to which this exception applies */
@@ -15,7 +22,6 @@ struct Exception : Serializable
static void unserialize(serialized_data &data);
};
-
class SessionService : public Service
{
public:
diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp
index e7a6fa390..d699e1a5f 100644
--- a/modules/database/db_old.cpp
+++ b/modules/database/db_old.cpp
@@ -591,7 +591,7 @@ static void LoadVHosts()
continue;
}
- na->hostinfo.SetVhost(ident, host, creator, vtime);
+ na->SetVhost(ident, host, creator, vtime);
Log() << "Loaded vhost for " << na->nick;
}
diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp
index 7c7721f7c..7f88ae9c1 100644
--- a/modules/database/db_plain.cpp
+++ b/modules/database/db_plain.cpp
@@ -117,7 +117,7 @@ EventReturn OnDatabaseReadMetadata(NickAlias *na, const Anope::string &key, cons
else if (key.equals_ci("FLAGS"))
na->FromVector(params);
else if (key.equals_ci("VHOST"))
- na->hostinfo.SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0);
+ na->SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0);
return EVENT_CONTINUE;
}
@@ -722,8 +722,8 @@ class DBPlain : public Module
db_buffer << "MD LAST_QUIT :" << na->last_quit << endl;
if (na->FlagCount())
db_buffer << "MD FLAGS " << na->ToString() << endl;
- if (na->hostinfo.HasVhost())
- db_buffer << "MD VHOST " << na->hostinfo.GetCreator() << " " << na->hostinfo.GetTime() << " " << na->hostinfo.GetHost() << " :" << na->hostinfo.GetIdent() << endl;
+ if (na->HasVhost())
+ db_buffer << "MD VHOST " << na->GetVhostCreator() << " " << na->GetVhostCreated() << " " << na->GetVhostHost() << " :" << na->GetVhostIdent() << endl;
//FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
}
diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp
index 285871cc6..0d863ad8d 100644
--- a/modules/extra/m_dnsbl.cpp
+++ b/modules/extra/m_dnsbl.cpp
@@ -43,7 +43,7 @@ class DNSBLResolver : public DNSRequest
{
sockaddrs sresult;
sresult.pton(AF_INET, ans_record.rdata);
- int result = (sresult.sa4.sin_addr.s_addr & 0xFF000000) >> 24;
+ int result = sresult.sa4.sin_addr.s_addr >> 24;
if (!this->blacklist.replies.count(result))
return;
@@ -57,13 +57,13 @@ class DNSBLResolver : public DNSRequest
reason = reason.replace_all_cs("%u", user->GetIdent());
reason = reason.replace_all_cs("%g", user->realname);
reason = reason.replace_all_cs("%h", user->host);
- reason = reason.replace_all_cs("%i", user->ip.addr());
+ reason = reason.replace_all_cs("%i", user->ip);
reason = reason.replace_all_cs("%r", record_reason);
reason = reason.replace_all_cs("%N", Config->NetworkName);
BotInfo *operserv = findbot(Config->OperServ);
- Log(operserv) << "DNSBL: " << user->GetMask() << " (" << user->ip.addr() << ") appears in " << this->blacklist.name;
- XLine *x = new XLine("*@" + user->ip.addr(), Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID());
+ Log(operserv) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name;
+ XLine *x = new XLine("*@" + user->ip, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID());
if (this->add_to_akill && akills)
{
akills->AddXLine(x);
@@ -133,15 +133,15 @@ class ModuleDNSBL : public Module
if (!this->check_on_netburst && !user->server->IsSynced())
return;
+
/* At this time we only support IPv4 */
- if (user->ip.sa.sa_family != AF_INET)
+ sockaddrs user_ip(user->ip);
+ if (user_ip.sa.sa_family != AF_INET)
return;
- unsigned long ip = user->ip.sa4.sin_addr.s_addr;
- unsigned long reverse_ip = ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip & 0xFF000000) >> 24);
+ const unsigned long &ip = user_ip.sa4.sin_addr.s_addr;
+ unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24);
- sockaddrs user_ip;
- user_ip.sa4.sin_family = AF_INET;
user_ip.sa4.sin_addr.s_addr = reverse_ip;
for (unsigned i = 0; i < this->blacklists.size(); ++i)
diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp
index 6b3153e32..37fd7c432 100644
--- a/modules/extra/m_proxyscan.cpp
+++ b/modules/extra/m_proxyscan.cpp
@@ -343,11 +343,12 @@ class ModuleProxyScan : public Module
void OnUserConnect(dynamic_reference<User> &user, bool &exempt)
{
- if (exempt || !user || !user->ip() || !Me->IsSynced() || !user->server->IsSynced())
+ if (exempt || !user || !Me->IsSynced() || !user->server->IsSynced())
return;
+ sockaddrs user_ip(user->ip);
/* At this time we only support IPv4 */
- if (user->ip.sa.sa_family != AF_INET)
+ if (user_ip.sa.sa_family != AF_INET)
return;
if (!this->con_notice.empty() && !this->con_source.empty())
@@ -374,7 +375,7 @@ class ModuleProxyScan : public Module
con = new SOCKS5ProxyConnect(p, p.ports[k]);
else
continue;
- con->Connect(user->ip.addr(), p.ports[k]);
+ con->Connect(user->ip, p.ports[k]);
}
catch (const SocketException &ex)
{
diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp
index 2d89c078d..829d3e532 100644
--- a/modules/extra/m_ssl.cpp
+++ b/modules/extra/m_ssl.cpp
@@ -102,7 +102,6 @@ class SSLModule : public Module
SSL_library_init();
SSL_load_error_strings();
- SSLeay_add_ssl_algorithms();
client_ctx = SSL_CTX_new(SSLv23_client_method());
server_ctx = SSL_CTX_new(SSLv23_server_method());
diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp
index 215be9d77..40a032092 100644
--- a/modules/extra/m_xmlrpc.cpp
+++ b/modules/extra/m_xmlrpc.cpp
@@ -1,3 +1,4 @@
+
#include "module.h"
#include "ssl.h"
#include "xmlrpc.h"
diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp
index 7498a3059..8762872ad 100644
--- a/modules/extra/m_xmlrpc_main.cpp
+++ b/modules/extra/m_xmlrpc_main.cpp
@@ -215,8 +215,8 @@ class MyXMLRPCEvent : public XMLRPCEvent
request->reply("vhost", iface->Sanitize(u->vhost));
if (!u->chost.empty())
request->reply("chost", iface->Sanitize(u->chost));
- if (u->ip())
- request->reply("ip", u->ip.addr());
+ if (!u->ip.empty())
+ request->reply("ip", u->ip);
request->reply("timestamp", stringify(u->timestamp));
request->reply("signon", stringify(u->my_signon));
if (u->Account())
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 3a7d655f3..b83afa686 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -11,10 +11,7 @@
/*************************************************************************/
-#include "services.h"
-#include "modules.h"
-#include "oper.h"
-#include "nickserv.h"
+#include "module.h"
IRCDVar myIrcd[] = {
{"Bahamut 1.8.x", /* ircd name */
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 003f1bb68..d984e597e 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -11,10 +11,7 @@
/*************************************************************************/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
IRCDVar myIrcd[] = {
{"InspIRCd 1.1", /* ircd name */
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 346e2b0e3..8fd29c7e8 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -11,10 +11,7 @@
/*************************************************************************/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
/* inspircd-ts6.h uses these */
static bool has_globopsmod = false;
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 30f8e2da3..8af8a999b 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -11,10 +11,7 @@
/*************************************************************************/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
/* inspircd-ts6.h uses these */
static bool has_chghostmod = false;
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index c920babf3..16e6d3753 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -9,10 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
static Anope::string TS6UPLINK;
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 016a364ca..16ac806be 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -9,10 +9,7 @@
* Based on the original code of Services by Andy Church.
*/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
static Anope::string TS6UPLINK;
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 101e803f4..4f45893c8 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -11,10 +11,7 @@
/*************************************************************************/
-#include "services.h"
-#include "modules.h"
-#include "nickserv.h"
-#include "oper.h"
+#include "module.h"
IRCDVar myIrcd[] = {
{"UnrealIRCd 3.2.x", /* ircd name */
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index 717b117f3..ecf0ecb47 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -33,37 +33,30 @@ class HostServCore : public Module
void OnNickIdentify(User *u)
{
- HostInfo *ho = NULL;
NickAlias *na = findnick(u->nick);
- if (na && na->hostinfo.HasVhost())
- ho = &na->hostinfo;
- else
- {
+ if (!na || !na->HasVhost())
na = findnick(u->Account()->display);
- if (na && na->hostinfo.HasVhost())
- ho = &na->hostinfo;
- }
- if (ho == NULL)
+ if (!na)
return;
- if (u->vhost.empty() || !u->vhost.equals_cs(na->hostinfo.GetHost()) || (!na->hostinfo.GetIdent().empty() && !u->GetVIdent().equals_cs(na->hostinfo.GetIdent())))
+ if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent())))
{
- ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost());
+ ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
if (ircd->vhost)
{
- u->vhost = na->hostinfo.GetHost();
+ u->vhost = na->GetVhostHost();
u->UpdateHost();
}
- if (ircd->vident && !na->hostinfo.GetIdent().empty())
- u->SetVIdent(na->hostinfo.GetIdent());
+ if (ircd->vident && !na->GetVhostIdent().empty())
+ u->SetVIdent(na->GetVhostIdent());
BotInfo *bi = findbot(Config->HostServ);
if (bi)
{
- if (!na->hostinfo.GetIdent().empty())
- u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str());
+ if (!na->GetVhostIdent().empty())
+ u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
else
- u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->hostinfo.GetHost().c_str());
+ u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str());
}
}
}
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index c486c2e0b..163fcc6af 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -16,6 +16,60 @@
static BotInfo *NickServ;
+class NickServCollide;
+class NickServRelease;
+
+typedef std::map<Anope::string, NickServCollide *> nickservcollides_map;
+typedef std::map<Anope::string, NickServRelease *> nickservreleases_map;
+
+static nickservcollides_map NickServCollides;
+static nickservreleases_map NickServReleases;
+
+/** Timer for colliding nicks to force people off of nicknames
+ */
+class CoreExport NickServCollide : public Timer
+{
+ dynamic_reference<User> u;
+ Anope::string nick;
+
+ public:
+ /** Default constructor
+ * @param nick The nick we're colliding
+ * @param delay How long to delay before kicking the user off the nick
+ */
+ NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick)
+ {
+ /* Erase the current collide and use the new one */
+ nickservcollides_map::iterator nit = NickServCollides.find(user->nick);
+ if (nit != NickServCollides.end())
+ delete nit->second;
+
+ NickServCollides.insert(std::make_pair(nick, this));
+ }
+
+ /** Default destructor
+ */
+ virtual ~NickServCollide()
+ {
+ NickServCollides.erase(this->nick);
+ }
+
+ /** Called when the delay is up
+ * @param t The current time
+ */
+ void Tick(time_t t)
+ {
+ if (!u)
+ return;
+ /* If they identified or don't exist anymore, don't kill them. */
+ NickAlias *na = findnick(u->nick);
+ if (!na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
+ return;
+
+ u->Collide(na);
+ }
+};
+
class MyNickServService : public NickServService
{
public:
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index 7dfaf40bb..813d9f098 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -40,7 +40,7 @@ class SGLineManager : public XLineManager
throw SocketException("SZLine is not supported");
else if (x->GetUser() != "*")
throw SocketException("Can not ZLine a username");
- x->GetIP();
+ sockaddrs(x->GetHost());
ircdproto->SendSZLine(u, x);
}
catch (const SocketException &)
@@ -57,7 +57,7 @@ class SGLineManager : public XLineManager
throw SocketException("SZLine is not supported");
else if (x->GetUser() != "*")
throw SocketException("Can not ZLine a username");
- x->GetIP();
+ sockaddrs(x->GetHost());
ircdproto->SendSZLineDel(x);
}
catch (const SocketException &)
diff --git a/src/access.cpp b/src/access.cpp
index 32c648857..4ed19c7fe 100644
--- a/src/access.cpp
+++ b/src/access.cpp
@@ -9,8 +9,11 @@
* Based on the original code of Services by Andy Church.
*/
-#include "services.h"
-#include "modules.h"
+#include "service.h"
+#include "access.h"
+#include "regchannel.h"
+#include "users.h"
+#include "account.h"
Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r)
{
diff --git a/src/actions.cpp b/src/actions.cpp
index 01c8bf918..5536596e6 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -10,6 +10,10 @@
*/
#include "services.h"
+#include "users.h"
+#include "config.h"
+#include "regchannel.h"
+#include "channels.h"
/*************************************************************************/
diff --git a/src/base.cpp b/src/base.cpp
index f8b393774..492ef4628 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -1,10 +1,10 @@
#include "services.h"
#include "modules.h"
#include "oper.h"
-
-std::vector<Anope::string> SerializeType::type_order;
-Anope::map<SerializeType *> SerializeType::types;
-std::list<Serializable *> *Serializable::serizliable_items;
+#include "account.h"
+#include "regchannel.h"
+#include "access.h"
+#include "bots.h"
Anope::map<Anope::map<Service *> > Service::services;
diff --git a/src/base64.cpp b/src/base64.cpp
index b8f4b9de6..df4189547 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -10,6 +10,7 @@
*/
#include "services.h"
+#include "anope.h"
static const Anope::string Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
diff --git a/src/bots.cpp b/src/bots.cpp
index a6cc1c06f..30df962d8 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -6,9 +6,16 @@
*/
#include "services.h"
-#include "modules.h"
-#include "commands.h"
+#include "anope.h"
+#include "bots.h"
+#include "servers.h"
+#include "protocol.h"
#include "oper.h"
+#include "regchannel.h"
+#include "channels.h"
+#include "config.h"
+#include "language.h"
+#include "extern.h"
Anope::insensitive_map<BotInfo *> BotListByNick;
Anope::map<BotInfo *> BotListByUID;
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 4007bb355..962f2b80e 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -12,7 +12,14 @@
/*************************************************************************/
#include "services.h"
-#include "modules.h"
+#include "anope.h"
+#include "protocol.h"
+#include "bots.h"
+#include "regchannel.h"
+#include "language.h"
+#include "extern.h"
+#include "access.h"
+#include "channels.h"
BotInfo *findbot(const Anope::string &nick)
{
diff --git a/src/channels.cpp b/src/channels.cpp
index ef74edcec..a04abff52 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -10,7 +10,19 @@
*/
#include "services.h"
+#include "channels.h"
+#include "regchannel.h"
+#include "logger.h"
#include "modules.h"
+#include "users.h"
+#include "bots.h"
+#include "servers.h"
+#include "protocol.h"
+#include "users.h"
+#include "config.h"
+#include "access.h"
+#include "extern.h"
+#include "sockets.h"
channel_map ChannelList;
@@ -91,7 +103,7 @@ void Channel::Sync()
{
if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi == this->users.front()->user)))
{
- new ChanServTimer(this);
+ this->Hold();
}
if (this->ci)
{
@@ -863,6 +875,56 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
}
}
+/** A timer used to keep the BotServ bot/ChanServ in the channel
+ * after kicking the last user in a channel
+ */
+class CoreExport ChanServTimer : public Timer
+{
+ private:
+ dynamic_reference<Channel> c;
+
+ public:
+ /** Default constructor
+ * @param chan The channel
+ */
+ ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan)
+ {
+ BotInfo *bi = findbot(Config->ChanServ);
+ if (!bi || !c)
+ return;
+ c->SetFlag(CH_INHABIT);
+ if (!c->ci || !c->ci->bi)
+ bi->Join(c);
+ else if (!c->FindUser(c->ci->bi))
+ c->ci->bi->Join(c);
+ }
+
+ /** Called when the delay is up
+ * @param The current time
+ */
+ void Tick(time_t)
+ {
+ if (!c)
+ return;
+
+ c->UnsetFlag(CH_INHABIT);
+
+ if (!c->ci || !c->ci->bi)
+ {
+ BotInfo *bi = findbot(Config->ChanServ);
+ if (bi)
+ bi->Part(c);
+ }
+ else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers)
+ c->ci->bi->Part(c);
+ }
+};
+
+void Channel::Hold()
+{
+ new ChanServTimer(this);
+}
+
/*************************************************************************/
Channel *findchan(const Anope::string &chan)
@@ -1198,9 +1260,7 @@ Entry::Entry(ChannelModeName mode, const Anope::string &_host) : Flags<EntryType
{
try
{
- sockaddrs addr;
- bool ipv6 = _realhost.substr(0, sl).find(':') != Anope::string::npos;
- addr.pton(ipv6 ? AF_INET6 : AF_INET, _realhost.substr(0, sl));
+ sockaddrs addr(_realhost.substr(0, sl));
/* If we got here, _realhost is a valid IP */
Anope::string cidr_range = _realhost.substr(sl + 1);
@@ -1248,11 +1308,15 @@ bool Entry::Matches(User *u, bool full) const
{
try
{
- cidr cidr_mask(this->host, this->cidr_len);
- if (!u->ip() || !cidr_mask.match(u->ip))
- ret = false;
+ if (full)
+ {
+ cidr cidr_mask(this->host, this->cidr_len);
+ sockaddrs addr(u->ip);
+ if (!cidr_mask.match(addr))
+ ret = false;
+ }
/* If we're not matching fully and their displayed host isnt their IP */
- else if (!full && u->ip.addr() != u->GetDisplayedHost())
+ else if (u->ip != u->GetDisplayedHost())
ret = false;
}
catch (const SocketException &)
@@ -1267,7 +1331,7 @@ bool Entry::Matches(User *u, bool full) const
ret = false;
if (this->HasFlag(ENTRYTYPE_HOST) && !this->host.equals_ci(u->GetDisplayedHost()) && (!full ||
(!this->host.equals_ci(u->host) && !this->host.equals_ci(u->chost) && !this->host.equals_ci(u->vhost) &&
- (!u->ip() || !this->host.equals_ci(u->ip.addr())))))
+ !this->host.equals_ci(u->ip))))
ret = false;
if (this->HasFlag(ENTRYTYPE_NICK_WILD) && !Anope::Match(u->nick, this->nick))
ret = false;
@@ -1276,7 +1340,7 @@ bool Entry::Matches(User *u, bool full) const
ret = false;
if (this->HasFlag(ENTRYTYPE_HOST_WILD) && !Anope::Match(u->GetDisplayedHost(), this->host) && (!full ||
(!Anope::Match(u->host, this->host) && !Anope::Match(u->chost, this->host) &&
- !Anope::Match(u->vhost, this->host) && (!u->ip() || !Anope::Match(u->ip.addr(), this->host)))))
+ !Anope::Match(u->vhost, this->host) && !Anope::Match(u->ip, this->host))))
ret = false;
ChannelMode *cm = ModeManager::FindChannelModeByName(this->modename);
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index 398617fb5..f18c919cc 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -12,7 +12,11 @@
/*************************************************************************/
#include "services.h"
-#include "modules.h"
+#include "anope.h"
+#include "regchannel.h"
+#include "users.h"
+#include "channels.h"
+#include "access.h"
registered_channel_map RegisteredChannelList;
@@ -184,32 +188,3 @@ int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret)
}
}
-ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan)
-{
- BotInfo *bi = findbot(Config->ChanServ);
- if (!bi || !c)
- return;
- c->SetFlag(CH_INHABIT);
- if (!c->ci || !c->ci->bi)
- bi->Join(c);
- else if (!c->FindUser(c->ci->bi))
- c->ci->bi->Join(c);
-}
-
-void ChanServTimer::Tick(time_t)
-{
- if (!c)
- return;
-
- c->UnsetFlag(CH_INHABIT);
-
- if (!c->ci || !c->ci->bi)
- {
- BotInfo *bi = findbot(Config->ChanServ);
- if (bi)
- bi->Part(c);
- }
- else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers)
- c->ci->bi->Part(c);
-}
-
diff --git a/src/command.cpp b/src/command.cpp
index 75271867b..309611a92 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -6,8 +6,12 @@
*/
#include "services.h"
-#include "modules.h"
#include "commands.h"
+#include "extern.h"
+#include "users.h"
+#include "language.h"
+#include "config.h"
+#include "bots.h"
void CommandSource::Reply(const char *message, ...)
{
diff --git a/src/config.cpp b/src/config.cpp
index d35399896..784142556 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -12,6 +12,11 @@
#include "services.h"
#include "config.h"
#include "module.h"
+#include "extern.h"
+#include "bots.h"
+#include "access.h"
+#include "opertype.h"
+#include "channels.h"
/*************************************************************************/
@@ -510,7 +515,7 @@ bool InitUplinks(ServerConfig *config, const Anope::string &)
{
if (!config->Uplinks.empty())
{
- std::vector<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end();
+ std::vector<ServerConfig::Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end();
for (; curr_uplink != end_uplink; ++curr_uplink)
delete *curr_uplink;
}
@@ -535,7 +540,7 @@ static bool DoUplink(ServerConfig *config, const Anope::string &, const Anope::s
if (!ValidateNotEmpty(config, "uplink", "password", vi_password))
throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
// If we get here, all the values are valid, we'll add it to the Uplinks list
- config->Uplinks.push_back(new Uplink(host, port, password, ipv6));
+ config->Uplinks.push_back(new ServerConfig::Uplink(host, port, password, ipv6));
return true;
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 9d6d49c2b..0bbdb0e49 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -24,6 +24,7 @@
*/
#include "services.h"
+#include "config.h"
ConfigReader::ConfigReader() : error(CONF_NO_ERROR)
{
diff --git a/src/dns.cpp b/src/dns.cpp
index fc1ab37df..d9010b8f9 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -1,4 +1,23 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
+#include "anope.h"
+#include "dns.h"
+#include "sockets.h"
+#include "socketengine.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
DNSManager *DNSEngine = NULL;
@@ -320,11 +339,10 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size
if (q.type == DNS_QUERY_PTR)
{
+ sockaddrs ip(q.name);
+
if (q.name.find(':') != Anope::string::npos)
{
- sockaddrs ip;
- ip.pton(AF_INET6, q.name);
-
static const char *const hex = "0123456789abcdef";
char reverse_ip[128];
unsigned reverse_ip_count = 0;
@@ -342,9 +360,6 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size
}
else
{
- sockaddrs ip;
- ip.pton(AF_INET, q.name);
-
unsigned long forward = ip.sa4.sin_addr.s_addr;
in_addr reverse;
reverse.s_addr = forward << 24 | (forward & 0xFF00) << 8 | (forward & 0xFF0000) >> 8 | forward >> 24;
@@ -399,8 +414,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size
if (pos + 6 > output_size)
throw SocketException("Unable to pack packet");
- sockaddrs addr;
- addr.pton(AF_INET, rr.rdata);
+ sockaddrs addr(rr.rdata);
s = htons(4);
memcpy(&output[pos], &s, 2);
@@ -415,8 +429,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size
if (pos + 18 > output_size)
throw SocketException("Unable to pack packet");
- sockaddrs addr;
- addr.pton(AF_INET6, rr.rdata);
+ sockaddrs addr(rr.rdata);
s = htons(16);
memcpy(&output[pos], &s, 2);
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 94b899536..84773b369 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -9,6 +9,8 @@
*/
#include "services.h"
+#include "hashcomp.h"
+#include "anope.h"
/*
*
diff --git a/src/hostserv.cpp b/src/hostserv.cpp
deleted file mode 100644
index dde6d44ce..000000000
--- a/src/hostserv.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* HostServ functions
- *
- * (C) 2003-2012 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#include "services.h"
-#include "modules.h"
-
-
-/** Set a vhost for the user
- * @param ident The ident
- * @param host The host
- * @param creator Who created the vhost
- * @param time When the vhost was craated
- */
-void HostInfo::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created)
-{
- Ident = ident;
- Host = host;
- Creator = creator;
- Time = created;
-}
-
-/** Remove a users vhost
- **/
-void HostInfo::RemoveVhost()
-{
- Ident.clear();
- Host.clear();
- Creator.clear();
- Time = 0;
-}
-
-/** Check if the user has a vhost
- * @return true or false
- */
-bool HostInfo::HasVhost() const
-{
- return !Host.empty();
-}
-
-/** Retrieve the vhost ident
- * @return the ident
- */
-const Anope::string &HostInfo::GetIdent() const
-{
- return Ident;
-}
-
-/** Retrieve the vhost host
- * @return the host
- */
-const Anope::string &HostInfo::GetHost() const
-{
- return Host;
-}
-
-/** Retrieve the vhost creator
- * @return the creator
- */
-const Anope::string &HostInfo::GetCreator() const
-{
- return Creator;
-}
-
-/** Retrieve when the vhost was crated
- * @return the time it was created
- */
-time_t HostInfo::GetTime() const
-{
- return Time;
-}
-
diff --git a/src/init.cpp b/src/init.cpp
index 2a87ade9c..a161f9c6f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -10,10 +10,21 @@
*/
#include "services.h"
-#include "modules.h"
+#include "config.h"
+#include "extern.h"
+#include "users.h"
+#include "protocol.h"
+#include "bots.h"
#include "oper.h"
+#include "signals.h"
+#include "socketengine.h"
+#include "servers.h"
-Uplink *uplink_server;
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
+ServerConfig::Uplink *uplink_server;
void introduce_user(const Anope::string &user)
{
diff --git a/src/language.cpp b/src/language.cpp
index 222008b8c..1a374c0bc 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -1,6 +1,23 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
#include "modules.h"
#include "commands.h"
+#include "config.h"
+#include "extern.h"
+
+#if GETTEXT_FOUND
+# include <libintl.h>
+#endif
std::vector<Anope::string> languages;
std::vector<Anope::string> domains;
diff --git a/src/logger.cpp b/src/logger.cpp
index 978c9cd44..508fa7b0c 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -12,6 +12,17 @@
#include "services.h"
#include "modules.h"
#include "commands.h"
+#include "channels.h"
+#include "users.h"
+#include "logger.h"
+#include "extern.h"
+#include "config.h"
+#include "bots.h"
+#include "servers.h"
+#include "uplink.h"
+#include "protocol.h"
+
+#include <sys/time.h>
static Anope::string GetTimeStamp()
{
diff --git a/src/mail.cpp b/src/mail.cpp
index dcf9dea5e..cc1541640 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1,4 +1,18 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+
#include "services.h"
+#include "mail.h"
+#include "config.h"
MailThread::MailThread(const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message) : Thread(), MailTo(mailto), Addr(addr), Subject(subject), Message(message), DontQuoteAddresses(Config->DontQuoteAddresses), Success(false)
{
diff --git a/src/main.cpp b/src/main.cpp
index 87cf8532c..55f185057 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,12 +25,18 @@
#include "services.h"
#include "timers.h"
-#include "modules.h"
-
-#ifdef _WIN32
-# include <process.h>
-# define execve _execve
-#endif
+#include "extern.h"
+#include "uplink.h"
+#include "config.h"
+#include "protocol.h"
+#include "servers.h"
+#include "bots.h"
+#include "dns.h"
+#include "signals.h"
+#include "socketengine.h"
+
+#include <unistd.h>
+#include <limits.h>
/******** Global variables! ********/
@@ -229,7 +235,7 @@ static void Connect()
if (static_cast<unsigned>(++CurrentUplink) >= Config->Uplinks.size())
CurrentUplink = 0;
- Uplink *u = Config->Uplinks[CurrentUplink];
+ ServerConfig::Uplink *u = Config->Uplinks[CurrentUplink];
new UplinkSocket();
if (!Config->LocalHost.empty())
@@ -340,9 +346,9 @@ int main(int ac, char **av, char **envp)
/* If we're root, issue a warning now */
if (!getuid() && !getgid())
{
- std::cout << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl;
- std::cout << " require root privileges to run, and it is discouraged that you run Anope" << std::endl;
- std::cout << " as the root superuser." << std::endl;
+ std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl;
+ std::cerr << " require root privileges to run, and it is discouraged that you run Anope" << std::endl;
+ std::cerr << " as the root superuser." << std::endl;
sleep(3);
}
#endif
diff --git a/src/memoserv.cpp b/src/memoserv.cpp
index bb168b939..1407e8521 100644
--- a/src/memoserv.cpp
+++ b/src/memoserv.cpp
@@ -9,9 +9,14 @@
* Based on the original code of Services by Andy Church.
*/
+
#include "services.h"
#include "modules.h"
+#include "service.h"
#include "memoserv.h"
+#include "memo.h"
+#include "users.h"
+#include "account.h"
Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { }
diff --git a/src/messages.cpp b/src/messages.cpp
index a3032e79a..fa93e528c 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -11,6 +11,12 @@
#include "services.h"
#include "modules.h"
+#include "users.h"
+#include "protocol.h"
+#include "config.h"
+#include "extern.h"
+#include "uplink.h"
+#include "opertype.h"
bool OnStats(const Anope::string &source, const std::vector<Anope::string> &params)
{
diff --git a/src/misc.cpp b/src/misc.cpp
index 524095d88..bb8658a56 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -13,6 +13,15 @@
#include "services.h"
#include "version.h"
#include "modules.h"
+#include "extern.h"
+#include "lists.h"
+#include "config.h"
+#include "bots.h"
+#include "language.h"
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
ExtensibleItem::ExtensibleItem()
{
@@ -758,9 +767,9 @@ const Anope::string Anope::LastError()
#endif
}
-Version Module::GetVersion() const
+ModuleVersion Module::GetVersion() const
{
- return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
+ return ModuleVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
}
Anope::string Anope::Version()
diff --git a/src/modes.cpp b/src/modes.cpp
index d64d60fd8..0b61440a5 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -8,8 +8,12 @@
#include "services.h"
#include "modules.h"
+#include "extern.h"
+#include "config.h"
+#include "sockets.h"
+#include "protocol.h"
+#include "channels.h"
-ModeManager::ModePipe *ModeManager::mpipe = NULL;
/* List of pairs of user/channels and their stacker info */
std::list<std::pair<Base *, StackerInfo *> > ModeManager::StackerObjects;
@@ -346,12 +350,14 @@ void StackerInfo::AddMode(Mode *mode, bool Set, const Anope::string &Param)
list->push_back(std::make_pair(mode, Param));
}
-/** Called when there are modes to be set
- */
-void ModeManager::ModePipe::OnNotify()
+class ModePipe : public Pipe
{
- ModeManager::ProcessModes();
-}
+ public:
+ void OnNotify()
+ {
+ ModeManager::ProcessModes();
+ }
+};
/** Get the stacker info for an item, if one doesnt exist it is created
* @param Item The user/channel etc
@@ -467,9 +473,8 @@ void ModeManager::StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool
else if (Type == ST_USER)
s->bi = NULL;
- if (mpipe == NULL)
- mpipe = new ModePipe();
- mpipe->Notify();
+ static ModePipe mpipe;
+ mpipe.Notify();
}
/** Add a user mode to Anope
diff --git a/src/module.cpp b/src/module.cpp
index 6fb6fff9a..d3406ec22 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -6,7 +6,11 @@
* Please read COPYING and README for further details.
*/
+
+#include "services.h"
#include "modules.h"
+#include "extern.h"
+#include "dns.h"
#ifdef GETTEXT_FOUND
# include <libintl.h>
@@ -80,25 +84,25 @@ void Module::SetAuthor(const Anope::string &nauthor)
this->author = nauthor;
}
-Version::Version(int vMajor, int vMinor, int vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild)
+ModuleVersion::ModuleVersion(int vMajor, int vMinor, int vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild)
{
}
-Version::~Version()
+ModuleVersion::~ModuleVersion()
{
}
-int Version::GetMajor() const
+int ModuleVersion::GetMajor() const
{
return this->Major;
}
-int Version::GetMinor() const
+int ModuleVersion::GetMinor() const
{
return this->Minor;
}
-int Version::GetBuild() const
+int ModuleVersion::GetBuild() const
{
return this->Build;
}
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index f56a3171a..39a4fcc45 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -6,8 +6,17 @@
* Please read COPYING and README for further details.
*/
+#include "services.h"
#include "modules.h"
-#include <algorithm> // std::find
+#include "extern.h"
+#include "users.h"
+
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
std::vector<Module *> ModuleManager::EventHandlers[I_END];
@@ -174,7 +183,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
m->filename = pbuf;
m->handle = handle;
- Version v = m->GetVersion();
+ ModuleVersion v = m->GetVersion();
if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor()))
{
Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor();
diff --git a/src/modules.cpp b/src/modules.cpp
index c978fdf16..e34c3597d 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -9,11 +9,24 @@
* Based on the original code of Services by Andy Church.
*/
+
+#include "services.h"
#include "modules.h"
message_map MessageMap;
std::list<Module *> Modules;
+CallBack::CallBack(Module *mod, long time_from_now, time_t now, bool repeating) : Timer(time_from_now, now, repeating), m(mod)
+{
+}
+
+CallBack::~CallBack()
+{
+ std::list<CallBack *>::iterator it = std::find(m->CallBacks.begin(), m->CallBacks.end(), this);
+ if (it != m->CallBacks.end())
+ m->CallBacks.erase(it);
+}
+
/** Message constructor, adds the message to Anope
* @param n The message name
* @param f A callback function
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index 43a35d448..586add90e 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -1,5 +1,28 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+
#include "services.h"
+#include "account.h"
#include "modules.h"
+#include "opertype.h"
+#include "protocol.h"
+#include "users.h"
+#include "servers.h"
+#include "config.h"
+
+class NickServHeld;
+
+typedef std::map<Anope::string, NickServHeld *> nickservheld_map;
+static nickservheld_map NickServHelds;
/** Default constructor
* @param nick The nick
@@ -83,6 +106,81 @@ void NickAlias::Release()
}
}
+/** Timers for removing HELD status from nicks.
+ */
+class NickServHeld : public Timer
+{
+ dynamic_reference<NickAlias> na;
+ Anope::string nick;
+ public:
+ NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick)
+ {
+ nickservheld_map::iterator nit = NickServHelds.find(na->nick);
+ if (nit != NickServHelds.end())
+ delete nit->second;
+
+ NickServHelds[na->nick] = this;
+ }
+
+ ~NickServHeld()
+ {
+ NickServHelds.erase(this->nick);
+ }
+
+ void Tick(time_t)
+ {
+ if (na)
+ na->UnsetFlag(NS_HELD);
+ }
+};
+
+/** Timers for releasing nicks to be available for use
+ */
+class CoreExport NickServRelease : public User, public Timer
+{
+ static std::map<Anope::string, NickServRelease *> NickServReleases;
+ Anope::string nick;
+
+ public:
+ /** Default constructor
+ * @param na The nick
+ * @param delay The delay before the nick is released
+ */
+ NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick)
+ {
+ this->realname = "Services Enforcer";
+ this->server = Me;
+
+ /* Erase the current release timer and use the new one */
+ std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick);
+ if (nit != NickServReleases.end())
+ {
+ ircdproto->SendQuit(nit->second, "");
+ delete nit->second;
+ }
+
+ NickServReleases.insert(std::make_pair(this->nick, this));
+
+ ircdproto->SendClientIntroduction(this);
+ }
+
+ /** Default destructor
+ */
+ virtual ~NickServRelease()
+ {
+ NickServReleases.erase(this->nick);
+ }
+
+ /** Called when the delay is up
+ * @param t The current time
+ */
+ void Tick(time_t t)
+ {
+ ircdproto->SendQuit(this, "");
+ }
+};
+std::map<Anope::string, NickServRelease *> NickServRelease::NickServReleases;
+
/** Called when a user gets off this nick
* See the comment in users.cpp for User::Collide()
* @param u The user
@@ -103,6 +201,47 @@ void NickAlias::OnCancel(User *)
}
}
+void NickAlias::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created)
+{
+ this->vhost_ident = ident;
+ this->vhost_host = host;
+ this->vhost_creator = creator;
+ this->vhost_created = created;
+}
+
+void NickAlias::RemoveVhost()
+{
+ this->vhost_ident.clear();
+ this->vhost_host.clear();
+ this->vhost_creator.clear();
+ this->vhost_created = 0;
+}
+
+bool NickAlias::HasVhost() const
+{
+ return !this->vhost_host.empty();
+}
+
+const Anope::string &NickAlias::GetVhostIdent() const
+{
+ return this->vhost_ident;
+}
+
+const Anope::string &NickAlias::GetVhostHost() const
+{
+ return this->vhost_host;
+}
+
+const Anope::string &NickAlias::GetVhostCreator() const
+{
+ return this->vhost_creator;
+}
+
+time_t NickAlias::GetVhostCreated() const
+{
+ return this->vhost_created;
+}
+
Anope::string NickAlias::serialize_name() const
{
return "NickAlias";
@@ -122,12 +261,12 @@ Serializable::serialized_data NickAlias::serialize()
data["nc"] << this->nc->display;
data["flags"] << this->ToString();
- if (this->hostinfo.HasVhost())
+ if (this->HasVhost())
{
- data["vhost_ident"] << this->hostinfo.GetIdent();
- data["vhost_host"] << this->hostinfo.GetHost();
- data["vhost_creator"] << this->hostinfo.GetCreator();
- data["vhost_time"] << this->hostinfo.GetTime();
+ data["vhost_ident"] << this->GetVhostIdent();
+ data["vhost_host"] << this->GetVhostHost();
+ data["vhost_creator"] << this->GetVhostCreator();
+ data["vhost_time"] << this->GetVhostCreated();
}
return data;
@@ -167,6 +306,6 @@ void NickAlias::unserialize(serialized_data &data)
time_t vhost_time;
data["vhost_time"] >> vhost_time;
- na->hostinfo.SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time);
+ na->SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time);
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 370d6b705..62a3d7006 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -1,5 +1,18 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
#include "modules.h"
+#include "account.h"
+#include "config.h"
/** Default constructor
* @param display The display nick
diff --git a/src/nickserv.cpp b/src/nickserv.cpp
index fde535e7c..011ee685e 100644
--- a/src/nickserv.cpp
+++ b/src/nickserv.cpp
@@ -10,95 +10,14 @@
*/
#include "services.h"
+#include "account.h"
#include "modules.h"
+#include "users.h"
+#include "protocol.h"
nickalias_map NickAliasList;
nickcore_map NickCoreList;
-typedef std::map<Anope::string, NickServCollide *> nickservcollides_map;
-typedef std::map<Anope::string, NickServHeld *> nickservheld_map;
-typedef std::map<Anope::string, NickServRelease *> nickservreleases_map;
-
-static nickservcollides_map NickServCollides;
-static nickservheld_map NickServHelds;
-static nickservreleases_map NickServReleases;
-
-NickServCollide::NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick)
-{
- /* Erase the current collide and use the new one */
- nickservcollides_map::iterator nit = NickServCollides.find(user->nick);
- if (nit != NickServCollides.end())
- delete nit->second;
-
- NickServCollides.insert(std::make_pair(nick, this));
-}
-
-NickServCollide::~NickServCollide()
-{
- NickServCollides.erase(this->nick);
-}
-
-void NickServCollide::Tick(time_t ctime)
-{
- if (!u)
- return;
- /* If they identified or don't exist anymore, don't kill them. */
- NickAlias *na = findnick(u->nick);
- if (!na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
- return;
-
- u->Collide(na);
-}
-
-NickServHeld::NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick)
-{
- nickservheld_map::iterator nit = NickServHelds.find(na->nick);
- if (nit != NickServHelds.end())
- delete nit->second;
-
- NickServHelds[na->nick] = this;
-}
-
-NickServHeld::~NickServHeld()
-{
- NickServHelds.erase(this->nick);
-}
-
-void NickServHeld::Tick(time_t)
-{
- if (na)
- na->UnsetFlag(NS_HELD);
-}
-
-NickServRelease::NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick)
-{
- this->realname = "Services Enforcer";
- this->server = Me;
-
- /* Erase the current release timer and use the new one */
- nickservreleases_map::iterator nit = NickServReleases.find(this->nick);
- if (nit != NickServReleases.end())
- delete nit->second;
-
- NickServReleases.insert(std::make_pair(this->nick, this));
-
- ircdproto->SendClientIntroduction(this);
-}
-
-NickServRelease::~NickServRelease()
-{
- NickServReleases.erase(this->nick);
-
- ircdproto->SendQuit(this, "");
-}
-
-void NickServRelease::Tick(time_t)
-{
- /* Do not do anything here,
- * The timer manager will delete this timer which will do the necessary cleanup
- */
-}
-
NickAlias *findnick(const Anope::string &nick)
{
FOREACH_MOD(I_OnFindNick, OnFindNick(nick));
diff --git a/src/operserv.cpp b/src/operserv.cpp
index e32937797..6cdbf2ff3 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -9,9 +9,13 @@
* Based on the original code of Services by Andy Church.
*/
+
#include "services.h"
#include "modules.h"
#include "oper.h"
+#include "users.h"
+#include "extern.h"
+#include "sockets.h"
/* List of XLine managers we check users against in XLineManager::CheckAll */
std::list<XLineManager *> XLineManager::XLineManagers;
@@ -62,13 +66,6 @@ Anope::string XLine::GetHost() const
return this->Mask.substr(host_t + 1);
}
-sockaddrs XLine::GetIP() const
-{
- sockaddrs addr;
- addr.pton(this->GetHost().find(':') != Anope::string::npos ? AF_INET6 : AF_INET, this->GetHost());
- return addr;
-}
-
Anope::string XLine::serialize_name() const
{
return "XLine";
@@ -361,12 +358,13 @@ XLine *XLineManager::Check(User *u)
if (!x->GetUser().empty() && !Anope::Match(u->GetIdent(), x->GetUser()))
continue;
- if (u->ip() && !x->GetHost().empty())
+ if (!x->GetHost().empty())
{
try
{
cidr cidr_ip(x->GetHost());
- if (cidr_ip.match(u->ip))
+ sockaddrs ip(u->ip);
+ if (cidr_ip.match(ip))
{
OnMatch(u, x);
return x;
diff --git a/src/opertype.cpp b/src/opertype.cpp
index 8c2edb60f..b719b4cc7 100644
--- a/src/opertype.cpp
+++ b/src/opertype.cpp
@@ -6,7 +6,9 @@
*/
#include "services.h"
-
+#include "anope.h"
+#include "opertype.h"
+#include "config.h"
Oper *Oper::Find(const Anope::string &name)
{
diff --git a/src/process.cpp b/src/process.cpp
index 02be28465..6bfa3fec7 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -11,6 +11,7 @@
#include "services.h"
#include "modules.h"
+#include "extern.h"
/** Main process routine
* @param buffer A raw line from the uplink to do things with
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 1bdebcc79..051f6f2d1 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -1,5 +1,24 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
#include "modules.h"
+#include "protocol.h"
+#include "users.h"
+#include "servers.h"
+#include "config.h"
+#include "uplink.h"
+#include "bots.h"
+#include "extern.h"
+#include "channels.h"
IRCDProto *ircdproto;
IRCDVar *ircd;
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 1ae7115c9..bf85f5809 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -11,6 +11,15 @@
#include "services.h"
#include "modules.h"
+#include "regchannel.h"
+#include "account.h"
+#include "access.h"
+#include "channels.h"
+#include "config.h"
+#include "bots.h"
+#include "extern.h"
+#include "language.h"
+#include "servers.h"
Anope::string BadWord::serialize_name() const
{
@@ -1024,7 +1033,7 @@ bool ChannelInfo::CheckKick(User *user)
}
/* Join ChanServ and set a timer for this channel to part ChanServ later */
- new ChanServTimer(this->c);
+ this->c->Hold();
}
this->c->SetMode(NULL, CMODE_BAN, mask);
diff --git a/src/serialize.cpp b/src/serialize.cpp
new file mode 100644
index 000000000..beaf5a8cc
--- /dev/null
+++ b/src/serialize.cpp
@@ -0,0 +1,138 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+
+#include "services.h"
+#include "anope.h"
+#include "serialize.h"
+
+std::vector<Anope::string> SerializeType::type_order;
+Anope::map<SerializeType *> SerializeType::types;
+std::list<Serializable *> *Serializable::serizliable_items;
+
+stringstream::stringstream() : std::stringstream(), type(Serialize::DT_TEXT), key(false), _max(0)
+{
+}
+
+stringstream::stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(Serialize::DT_TEXT), key(false), _max(0)
+{
+}
+
+Anope::string stringstream::astr() const
+{
+ return this->str();
+}
+
+std::istream &stringstream::operator>>(Anope::string &val)
+{
+ val = this->str();
+ return *this;
+}
+
+stringstream &stringstream::setType(Serialize::DataType t)
+{
+ this->type = t;
+ return *this;
+}
+
+Serialize::DataType stringstream::getType() const
+{
+ return this->type;
+}
+
+stringstream &stringstream::setKey()
+{
+ this->key = true;
+ return *this;
+}
+
+bool stringstream::getKey() const
+{
+ return this->key;
+}
+
+stringstream &stringstream::setMax(unsigned m)
+{
+ this->_max = m;
+ return *this;
+}
+
+unsigned stringstream::getMax() const
+{
+ return this->_max;
+}
+
+Serializable::Serializable()
+{
+ if (serizliable_items == NULL)
+ serizliable_items = new std::list<Serializable *>();
+ serizliable_items->push_front(this);
+ this->s_iter = serizliable_items->begin();
+}
+
+Serializable::Serializable(const Serializable &)
+{
+ serizliable_items->push_front(this);
+ this->s_iter = serizliable_items->begin();
+}
+
+Serializable::~Serializable()
+{
+ serizliable_items->erase(this->s_iter);
+}
+
+Serializable &Serializable::operator=(const Serializable &)
+{
+ return *this;
+}
+
+const std::list<Serializable *> &Serializable::GetItems()
+{
+ return *serizliable_items;
+}
+
+SerializeType::SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f)
+{
+ type_order.push_back(this->name);
+ types[this->name] = this;
+}
+
+SerializeType::~SerializeType()
+{
+ std::vector<Anope::string>::iterator it = std::find(type_order.begin(), type_order.end(), this->name);
+ if (it != type_order.end())
+ type_order.erase(it);
+ types.erase(this->name);
+}
+
+const Anope::string &SerializeType::GetName()
+{
+ return this->name;
+}
+
+void SerializeType::Create(Serializable::serialized_data &data)
+{
+ this->unserialize(data);
+}
+
+SerializeType *SerializeType::Find(const Anope::string &name)
+{
+ Anope::map<SerializeType *>::iterator it = types.find(name);
+ if (it != types.end())
+ return it->second;
+ return NULL;
+}
+
+const std::vector<Anope::string> &SerializeType::GetTypeOrder()
+{
+ return type_order;
+}
+
diff --git a/src/servers.cpp b/src/servers.cpp
index 6aef23ef8..944285c42 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -12,6 +12,13 @@
#include "services.h"
#include "modules.h"
#include "oper.h"
+#include "servers.h"
+#include "bots.h"
+#include "regchannel.h"
+#include "protocol.h"
+#include "config.h"
+#include "channels.h"
+#include "extern.h"
/* Anope */
Server *Me = NULL;
diff --git a/src/socket_clients.cpp b/src/socket_clients.cpp
index c3f7e6367..847981510 100644
--- a/src/socket_clients.cpp
+++ b/src/socket_clients.cpp
@@ -10,6 +10,11 @@
*/
#include "services.h"
+#include "anope.h"
+#include "logger.h"
+#include "sockets.h"
+
+#include <errno.h>
ConnectionSocket::ConnectionSocket() : Socket()
{
diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp
index c2e964271..b524c6a24 100644
--- a/src/socket_transport.cpp
+++ b/src/socket_transport.cpp
@@ -10,6 +10,8 @@
*/
#include "services.h"
+#include "sockets.h"
+#include "socketengine.h"
BufferedSocket::BufferedSocket()
{
diff --git a/src/socketengines/pipeengine_eventfd.cpp b/src/socketengines/pipeengine_eventfd.cpp
index 06102ff20..d1051cc28 100644
--- a/src/socketengines/pipeengine_eventfd.cpp
+++ b/src/socketengines/pipeengine_eventfd.cpp
@@ -1,4 +1,17 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
+#include "sockets.h"
+
#include <sys/eventfd.h>
Pipe::Pipe() : Socket(eventfd(0, EFD_NONBLOCK))
diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp
index 7901931c8..dc7d6918a 100644
--- a/src/socketengines/pipeengine_pipe.cpp
+++ b/src/socketengines/pipeengine_pipe.cpp
@@ -1,4 +1,20 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
+#include "sockets.h"
+#include "socketengine.h"
+
+#include <unistd.h>
+#include <fcntl.h>
Pipe::Pipe() : Socket(-1), WritePipe(-1)
{
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp
index 927d84100..b6dbdc23f 100644
--- a/src/socketengines/socketengine_epoll.cpp
+++ b/src/socketengines/socketengine_epoll.cpp
@@ -1,6 +1,23 @@
-#include "module.h"
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#include "services.h"
+#include "anope.h"
+#include "sockets.h"
+#include "socketengine.h"
+#include "config.h"
+
#include <sys/epoll.h>
#include <ulimit.h>
+#include <errno.h>
static long max;
static int EngineHandle;
diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp
index 1c9fe1c2f..7af78bad6 100644
--- a/src/socketengines/socketengine_kqueue.cpp
+++ b/src/socketengines/socketengine_kqueue.cpp
@@ -1,4 +1,21 @@
-#include "module.h"
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#include "services.h"
+#include "anope.h"
+#include "socketengine.h"
+#include "sockets.h"
+#include "logger.h"
+#include "config.h"
+
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp
index a174bf828..8fa666cf3 100644
--- a/src/socketengines/socketengine_poll.cpp
+++ b/src/socketengines/socketengine_poll.cpp
@@ -1,4 +1,22 @@
-#include "module.h"
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#include "services.h"
+#include "anope.h"
+#include "socketengine.h"
+#include "sockets.h"
+#include "config.h"
+#include "logger.h"
+
+#include <errno.h>
#ifndef _WIN32
# include <sys/poll.h>
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp
index 89a5c47c3..e3393fdea 100644
--- a/src/socketengines/socketengine_select.cpp
+++ b/src/socketengines/socketengine_select.cpp
@@ -1,4 +1,20 @@
-#include "module.h"
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#include "services.h"
+#include "anope.h"
+#include "socketengine.h"
+#include "sockets.h"
+#include "logger.h"
+#include "config.h"
#ifdef _AIX
# undef FD_ZERO
diff --git a/src/sockets.cpp b/src/sockets.cpp
index 9b985a504..ebaf8f5a3 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -1,17 +1,38 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
+#include "sockets.h"
+#include "socketengine.h"
+#include "logger.h"
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
std::map<int, Socket *> SocketEngine::Sockets;
-int32_t TotalRead = 0;
-int32_t TotalWritten = 0;
+uint32_t TotalRead = 0;
+uint32_t TotalWritten = 0;
SocketIO normalSocketIO;
/** Construct the object, sets everything to 0
*/
-sockaddrs::sockaddrs()
+sockaddrs::sockaddrs(const Anope::string &address)
{
this->clear();
+ if (!address.empty())
+ this->pton(address.find(':') != Anope::string::npos ? AF_INET6 : AF_INET, address);
}
/** Memset the object to 0
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index c186e49a2..d45686586 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -1,4 +1,19 @@
+/*
+ *
+ * (C) 2003-2012 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
#include "services.h"
+#include "threadengine.h"
+#include "anope.h"
+
+#include <pthread.h>
static inline pthread_attr_t *get_engine_attr()
{
diff --git a/src/timers.cpp b/src/timers.cpp
index a0f707bc9..267629aee 100644
--- a/src/timers.cpp
+++ b/src/timers.cpp
@@ -8,7 +8,9 @@
* Based on the original code of Services by Andy Church.
*/
+
#include "services.h"
+#include "timers.h"
std::vector<Timer *> TimerManager::Timers;
diff --git a/src/users.cpp b/src/users.cpp
index f15754b28..c85aadd5b 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -9,8 +9,18 @@
* Based on the original code of Services by Andy Church.
*/
+
#include "services.h"
#include "modules.h"
+#include "users.h"
+#include "account.h"
+#include "protocol.h"
+#include "servers.h"
+#include "channels.h"
+#include "bots.h"
+#include "config.h"
+#include "opertype.h"
+#include "extern.h"
Anope::insensitive_map<User *> UserListByNick;
Anope::map<User *> UserListByUID;
@@ -814,6 +824,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
/* Allocate User structure and fill it in. */
dynamic_reference<User> user = new User(nick, username, host, uid);
+ user->ip = ip;
user->server = serv;
user->realname = realname;
user->timestamp = ts;
@@ -822,23 +833,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
user->SetVIdent(username);
user->SetModesInternal(modes.c_str());
- if (!ip.empty())
- {
- try
- {
- if (ip.find(':') != Anope::string::npos)
- user->ip.pton(AF_INET6, ip);
- else
- user->ip.pton(AF_INET, ip);
- }
- catch (const SocketException &ex)
- {
- Log() << "Received an invalid IP for user " << user->nick << " (" << ip << ")";
- Log() << ex.GetReason();
- }
- }
-
- Log(user, "connect") << (!vhost.empty() ? Anope::string("(") + vhost + ")" : "") << " (" << user->realname << ") " << (user->ip() ? Anope::string("[") + user->ip.addr() + "] " : "") << "connected to the network (" << serv->GetName() << ")";
+ Log(user, "connect") << (!vhost.empty() ? Anope::string("(") + vhost + ")" : "") << " (" << user->realname << ") " << user->ip << "connected to the network (" << serv->GetName() << ")";
bool exempt = false;
if (user->server && user->server->IsULined())
diff --git a/src/win32/pipe/pipe.cpp b/src/win32/pipe/pipe.cpp
index 849517b94..f46094c80 100644
--- a/src/win32/pipe/pipe.cpp
+++ b/src/win32/pipe/pipe.cpp
@@ -9,9 +9,7 @@
int pipe(int fds[2])
{
- sockaddrs localhost;
-
- localhost.pton(AF_INET, "127.0.0.1");
+ sockaddrs localhost("127.0.0.1");
int cfd = socket(AF_INET, SOCK_STREAM, 0), lfd = socket(AF_INET, SOCK_STREAM, 0);
if (cfd == -1 || lfd == -1)
diff --git a/include/resource.h b/src/win32/resource.h
index cccb0b4f5..cccb0b4f5 100644
--- a/include/resource.h
+++ b/src/win32/resource.h