summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt89
-rw-r--r--src/access.cpp476
-rw-r--r--src/accessgroup.cpp125
-rw-r--r--src/account.cpp91
-rw-r--r--src/base.cpp40
-rw-r--r--src/base64.cpp20
-rw-r--r--src/bots.cpp292
-rw-r--r--src/channels.cpp215
-rw-r--r--src/command.cpp190
-rw-r--r--src/config.cpp741
-rw-r--r--src/event.cpp35
-rw-r--r--src/extensible.cpp63
-rw-r--r--src/hashcomp.cpp152
-rw-r--r--src/init.cpp188
-rw-r--r--src/language.cpp57
-rw-r--r--src/logger.cpp484
-rw-r--r--src/mail.cpp58
-rw-r--r--src/main.cpp65
-rw-r--r--src/memos.cpp141
-rw-r--r--src/messages.cpp502
-rw-r--r--src/misc.cpp209
-rw-r--r--src/modes.cpp178
-rw-r--r--src/module.cpp51
-rw-r--r--src/modulemanager.cpp298
-rw-r--r--src/nickalias.cpp217
-rw-r--r--src/nickcore.cpp270
-rw-r--r--src/opertype.cpp114
-rw-r--r--src/pipeengine.cpp25
-rw-r--r--src/process.cpp95
-rw-r--r--src/protocol.cpp387
-rw-r--r--src/regchannel.cpp695
-rw-r--r--src/serialize.cpp355
-rw-r--r--src/servers.cpp207
-rw-r--r--src/service.cpp67
-rw-r--r--src/service_manager.cpp139
-rw-r--r--src/socket_clients.cpp26
-rw-r--r--src/socket_transport.cpp52
-rw-r--r--src/socketengines/socketengine_epoll.cpp8
-rw-r--r--src/socketengines/socketengine_kqueue.cpp6
-rw-r--r--src/socketengines/socketengine_poll.cpp4
-rw-r--r--src/socketengines/socketengine_select.cpp4
-rw-r--r--src/sockets.cpp22
-rw-r--r--src/threadengine.cpp119
-rw-r--r--src/timers.cpp19
-rw-r--r--src/tools/CMakeLists.txt55
-rw-r--r--src/tools/anope_sqlite.cpp132
-rw-r--r--src/tools/anoperc.in10
-rw-r--r--src/tools/anopesmtp.cpp505
-rw-r--r--src/uplink.cpp103
-rw-r--r--src/users.cpp322
-rw-r--r--src/version.sh6
-rw-r--r--src/win32/Config.cs363
-rw-r--r--src/win32/anope_windows.h12
-rw-r--r--src/win32/dir/dir.cpp7
-rw-r--r--src/win32/dir/dir.h7
-rw-r--r--src/win32/dl/dl.cpp5
-rw-r--r--src/win32/dl/dl.h5
-rw-r--r--src/win32/pipe/pipe.cpp8
-rw-r--r--src/win32/pipe/pipe.h5
-rw-r--r--src/win32/pthread/pthread.cpp119
-rw-r--r--src/win32/pthread/pthread.h35
-rw-r--r--src/win32/resource.h10
-rw-r--r--src/win32/sigaction/sigaction.cpp17
-rw-r--r--src/win32/sigaction/sigaction.h28
-rw-r--r--src/win32/socket.cpp7
-rw-r--r--src/win32/socket.h5
-rw-r--r--src/win32/windows.cpp12
-rw-r--r--src/xline.cpp422
68 files changed, 3583 insertions, 6208 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b390d164b..007e3605a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,72 +2,37 @@
file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
if(WIN32)
- append_to_list(SRC_SRCS win32/dir/dir.cpp)
- append_to_list(SRC_SRCS win32/socket.cpp)
- append_to_list(SRC_SRCS win32/windows.cpp)
- append_to_list(SRC_SRCS win32/dl/dl.cpp)
- append_to_list(SRC_SRCS win32/pipe/pipe.cpp)
- append_to_list(SRC_SRCS win32/pthread/pthread.cpp)
- append_to_list(SRC_SRCS win32/sigaction/sigaction.cpp)
-endif(WIN32)
+ list(APPEND SRC_SRCS win32/dir/dir.cpp)
+ list(APPEND SRC_SRCS win32/socket.cpp)
+ list(APPEND SRC_SRCS win32/windows.cpp)
+ list(APPEND SRC_SRCS win32/dl/dl.cpp)
+ list(APPEND SRC_SRCS win32/pipe/pipe.cpp)
+ list(APPEND SRC_SRCS win32/sigaction/sigaction.cpp)
+endif()
if(HAVE_EPOLL)
- append_to_list(SRC_SRCS socketengines/socketengine_epoll.cpp)
-else(HAVE_EPOLL)
- if(HAVE_KQUEUE)
- append_to_list(SRC_SRCS socketengines/socketengine_kqueue.cpp)
- else(HAVE_KQUEUE)
- if(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_poll.cpp)
- else(HAVE_POLL)
- append_to_list(SRC_SRCS socketengines/socketengine_select.cpp)
- endif(HAVE_POLL)
- endif(HAVE_KQUEUE)
-endif(HAVE_EPOLL)
+ list(APPEND SRC_SRCS socketengines/socketengine_epoll.cpp)
+elseif(HAVE_KQUEUE)
+ list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp)
+elseif(HAVE_POLL)
+ list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp)
+else()
+ list(APPEND SRC_SRCS socketengines/socketengine_select.cpp)
+endif()
-sort_list(SRC_SRCS)
+list(SORT SRC_SRCS)
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
set_source_files_properties(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
-# Create an empty list to store extra include directories
-set(EXTRA_INCLUDES)
-# Iterate through all the source files
-foreach(SRC ${SRC_SRCS})
- # Temporary variable for the current source's include directories
- set(TEMP_INCLUDES)
- # Calculate the header file dependencies for the given source file
- calculate_depends(${SRC} TEMP_INCLUDES)
- # If there were some extra include directories, add them to the list
- if(TEMP_INCLUDES)
- append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES})
- endif(TEMP_INCLUDES)
-endforeach(SRC)
-# If there were extra include directories, remove the duplicates and add the directories to the include path
-if(EXTRA_INCLUDES)
- remove_list_duplicates(EXTRA_INCLUDES)
- include_directories(${EXTRA_INCLUDES})
-endif(EXTRA_INCLUDES)
-
# Under Windows, we also include a resource file to the build
if(WIN32)
# Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc LANGUAGE RC)
# Add the resource file to the list of sources
- append_to_list(SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
- # For MinGW, we have to change the compile flags
- if(MINGW)
- set(RC_CFLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
- # If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler
- if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
- set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG")
- endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "${RC_CFLAGS}")
- # For anything else, assumingly Visual Studio at this point, use a different set of compile flags
- else(MINGW)
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
- endif(MINGW)
-endif(WIN32)
+ list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
+endif()
# If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators
if(MSVC)
@@ -75,26 +40,26 @@ if(MSVC)
add_library(win32_memory STATIC win32/win32_memory.cpp)
set(WIN32_MEMORY win32_memory)
set(EXTRA_LDFLAGS "/OPT:NOREF") # https://sourceware.org/bugzilla/show_bug.cgi?id=12633
-else(MSVC)
+else()
set(WIN32_MEMORY)
-endif(MSVC)
+endif()
# Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module
add_executable(${PROGRAM_NAME} ${SRC_SRCS})
set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS} ${EXTRA_LDFLAGS}" ENABLE_EXPORTS ON INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
# On Windows, also link Anope to the wsock32 and Ws2_32 library, as well as set the version
if(WIN32)
- target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${WIN32_MEMORY})
+ target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${Boost_LIBRARIES} ${WIN32_MEMORY})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
-else(WIN32)
- target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES})
-endif(WIN32)
+else()
+ target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${Boost_LIBRARIES})
+endif()
# Building the Anope executable requires the version.h header to be generated
add_dependencies(${PROGRAM_NAME} headers)
# Also require the language files if we have gettext
if(GETTEXT_FOUND)
add_dependencies(${PROGRAM_NAME} language)
-endif(GETTEXT_FOUND)
+endif()
# Get the filename of the Anope executable as it is in on this system
get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
@@ -108,7 +73,7 @@ configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/i
# Go into the following directories and run their CMakeLists.txt as well
if(NOT DISABLE_TOOLS)
add_subdirectory(tools)
-endif(NOT DISABLE_TOOLS)
+endif()
# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
diff --git a/src/access.cpp b/src/access.cpp
deleted file mode 100644
index 1c1a6f8e4..000000000
--- a/src/access.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- *
- * (C) 2003-2017 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 "service.h"
-#include "access.h"
-#include "regchannel.h"
-#include "users.h"
-#include "account.h"
-#include "protocol.h"
-
-static struct
-{
- Anope::string name;
- Anope::string desc;
-} descriptions[] = {
- {"ACCESS_CHANGE", _("Allowed to modify the access list")},
- {"ACCESS_LIST", _("Allowed to view the access list")},
- {"AKICK", _("Allowed to use the AKICK command")},
- {"ASSIGN", _("Allowed to assign/unassign a bot")},
- {"AUTOHALFOP", _("Automatic halfop upon join")},
- {"AUTOOP", _("Automatic channel operator status upon join")},
- {"AUTOOWNER", _("Automatic owner upon join")},
- {"AUTOPROTECT", _("Automatic protect upon join")},
- {"AUTOVOICE", _("Automatic voice on join")},
- {"BADWORDS", _("Allowed to modify channel badwords list")},
- {"BAN", _("Allowed to ban users")},
- {"FANTASIA", _("Allowed to use fantasy commands")},
- {"FOUNDER", _("Allowed to issue commands restricted to channel founders")},
- {"GETKEY", _("Allowed to use GETKEY command")},
- {"GREET", _("Greet message displayed on join")},
- {"HALFOP", _("Allowed to (de)halfop users")},
- {"HALFOPME", _("Allowed to (de)halfop him/herself")},
- {"INFO", _("Allowed to get full INFO output")},
- {"INVITE", _("Allowed to use the INVITE command")},
- {"KICK", _("Allowed to use the KICK command")},
- {"MEMO", _("Allowed to read channel memos")},
- {"MODE", _("Allowed to use the MODE command")},
- {"NOKICK", _("Prevents users being kicked by Services")},
- {"OP", _("Allowed to (de)op users")},
- {"OPME", _("Allowed to (de)op him/herself")},
- {"OWNER", _("Allowed to (de)owner users")},
- {"OWNERME", _("Allowed to (de)owner him/herself")},
- {"PROTECT", _("Allowed to (de)protect users")},
- {"PROTECTME", _("Allowed to (de)protect him/herself")},
- {"SAY", _("Allowed to use SAY and ACT commands")},
- {"SET", _("Allowed to set channel settings")},
- {"SIGNKICK", _("No signed kick when SIGNKICK LEVEL is used")},
- {"TOPIC", _("Allowed to change channel topics")},
- {"UNBAN", _("Allowed to unban users")},
- {"VOICE", _("Allowed to (de)voice users")},
- {"VOICEME", _("Allowed to (de)voice him/herself")}
-};
-
-Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r)
-{
- if (this->desc.empty())
- for (unsigned j = 0; j < sizeof(descriptions) / sizeof(*descriptions); ++j)
- if (descriptions[j].name.equals_ci(name))
- this->desc = descriptions[j].desc;
-}
-
-bool Privilege::operator==(const Privilege &other) const
-{
- return this->name.equals_ci(other.name);
-}
-
-std::vector<Privilege> PrivilegeManager::Privileges;
-
-void PrivilegeManager::AddPrivilege(Privilege p)
-{
- unsigned i;
- for (i = 0; i < Privileges.size(); ++i)
- {
- Privilege &priv = Privileges[i];
-
- if (priv.rank > p.rank)
- break;
- }
-
- Privileges.insert(Privileges.begin() + i, p);
-}
-
-void PrivilegeManager::RemovePrivilege(Privilege &p)
-{
- std::vector<Privilege>::iterator it = std::find(Privileges.begin(), Privileges.end(), p);
- if (it != Privileges.end())
- Privileges.erase(it);
-
- for (registered_channel_map::const_iterator cit = RegisteredChannelList->begin(), cit_end = RegisteredChannelList->end(); cit != cit_end; ++cit)
- {
- cit->second->QueueUpdate();
- cit->second->RemoveLevel(p.name);
- }
-}
-
-Privilege *PrivilegeManager::FindPrivilege(const Anope::string &name)
-{
- for (unsigned i = Privileges.size(); i > 0; --i)
- if (Privileges[i - 1].name.equals_ci(name))
- return &Privileges[i - 1];
- return NULL;
-}
-
-std::vector<Privilege> &PrivilegeManager::GetPrivileges()
-{
- return Privileges;
-}
-
-void PrivilegeManager::ClearPrivileges()
-{
- Privileges.clear();
-}
-
-AccessProvider::AccessProvider(Module *o, const Anope::string &n) : Service(o, "AccessProvider", n)
-{
- Providers.push_back(this);
-}
-
-AccessProvider::~AccessProvider()
-{
- std::list<AccessProvider *>::iterator it = std::find(Providers.begin(), Providers.end(), this);
- if (it != Providers.end())
- Providers.erase(it);
-}
-
-std::list<AccessProvider *> AccessProvider::Providers;
-
-const std::list<AccessProvider *>& AccessProvider::GetProviders()
-{
- return Providers;
-}
-
-ChanAccess::ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p)
-{
-}
-
-ChanAccess::~ChanAccess()
-{
- if (this->ci)
- {
- std::vector<ChanAccess *>::iterator it = std::find(this->ci->access->begin(), this->ci->access->end(), this);
- if (it != this->ci->access->end())
- this->ci->access->erase(it);
-
- if (*nc != NULL)
- nc->RemoveChannelReference(this->ci);
- else
- {
- ChannelInfo *c = ChannelInfo::Find(this->mask);
- if (c)
- c->RemoveChannelReference(this->ci->name);
- }
- }
-}
-
-void ChanAccess::SetMask(const Anope::string &m, ChannelInfo *c)
-{
- if (*nc != NULL)
- nc->RemoveChannelReference(this->ci);
- else if (!this->mask.empty())
- {
- ChannelInfo *targc = ChannelInfo::Find(this->mask);
- if (targc)
- targc->RemoveChannelReference(this->ci->name);
- }
-
- ci = c;
- mask.clear();
- nc = NULL;
-
- const NickAlias *na = NickAlias::Find(m);
- if (na != NULL)
- {
- nc = na->nc;
- nc->AddChannelReference(ci);
- }
- else
- {
- mask = m;
-
- ChannelInfo *targci = ChannelInfo::Find(mask);
- if (targci != NULL)
- targci->AddChannelReference(ci->name);
- }
-}
-
-const Anope::string &ChanAccess::Mask() const
-{
- if (nc)
- return nc->display;
- else
- return mask;
-}
-
-NickCore *ChanAccess::GetAccount() const
-{
- return nc;
-}
-
-void ChanAccess::Serialize(Serialize::Data &data) const
-{
- data["provider"] << this->provider->name;
- data["ci"] << this->ci->name;
- data["mask"] << this->Mask();
- data["creator"] << this->creator;
- data.SetType("last_seen", Serialize::Data::DT_INT); data["last_seen"] << this->last_seen;
- data.SetType("created", Serialize::Data::DT_INT); data["created"] << this->created;
- data["data"] << this->AccessSerialize();
-}
-
-Serializable* ChanAccess::Unserialize(Serializable *obj, Serialize::Data &data)
-{
- Anope::string provider, chan;
-
- data["provider"] >> provider;
- data["ci"] >> chan;
-
- ServiceReference<AccessProvider> aprovider("AccessProvider", provider);
- ChannelInfo *ci = ChannelInfo::Find(chan);
- if (!aprovider || !ci)
- return NULL;
-
- ChanAccess *access;
- if (obj)
- access = anope_dynamic_static_cast<ChanAccess *>(obj);
- else
- access = aprovider->Create();
- access->ci = ci;
- Anope::string m;
- data["mask"] >> m;
- access->SetMask(m, ci);
- data["creator"] >> access->creator;
- data["last_seen"] >> access->last_seen;
- data["created"] >> access->created;
-
- Anope::string adata;
- data["data"] >> adata;
- access->AccessUnserialize(adata);
-
- if (!obj)
- ci->AddAccess(access);
- return access;
-}
-
-bool ChanAccess::Matches(const User *u, const NickCore *acc, ChannelInfo* &next) const
-{
- next = NULL;
-
- if (this->nc)
- return this->nc == acc;
-
- if (u)
- {
- bool is_mask = this->mask.find_first_of("!@?*") != Anope::string::npos;
- if (is_mask && Anope::Match(u->nick, this->mask))
- return true;
- else if (Anope::Match(u->GetDisplayedMask(), this->mask))
- return true;
- }
-
- if (acc)
- {
- for (unsigned i = 0; i < acc->aliases->size(); ++i)
- {
- const NickAlias *na = acc->aliases->at(i);
- if (Anope::Match(na->nick, this->mask))
- return true;
- }
- }
-
- if (IRCD->IsChannelValid(this->mask))
- {
- next = ChannelInfo::Find(this->mask);
- }
-
- return false;
-}
-
-bool ChanAccess::operator>(const ChanAccess &other) const
-{
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return this_p && !other_p;
- }
-
- return false;
-}
-
-bool ChanAccess::operator<(const ChanAccess &other) const
-{
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return !this_p && other_p;
- }
-
- return false;
-}
-
-bool ChanAccess::operator>=(const ChanAccess &other) const
-{
- return !(*this < other);
-}
-
-bool ChanAccess::operator<=(const ChanAccess &other) const
-{
- return !(*this > other);
-}
-
-AccessGroup::AccessGroup()
-{
- this->ci = NULL;
- this->nc = NULL;
- this->super_admin = this->founder = false;
-}
-
-static bool HasPriv(const ChanAccess::Path &path, const Anope::string &name)
-{
- if (path.empty())
- return false;
-
- for (unsigned int i = 0; i < path.size(); ++i)
- {
- ChanAccess *access = path[i];
-
- EventReturn MOD_RESULT;
- FOREACH_RESULT(OnCheckPriv, MOD_RESULT, (access, name));
-
- if (MOD_RESULT != EVENT_ALLOW && !access->HasPriv(name))
- return false;
- }
-
- return true;
-}
-
-bool AccessGroup::HasPriv(const Anope::string &name) const
-{
- if (this->super_admin)
- return true;
- else if (!ci || ci->GetLevel(name) == ACCESS_INVALID)
- return false;
-
- /* Privileges prefixed with auto are understood to be given
- * automatically. Sometimes founders want to not automatically
- * obtain privileges, so we will let them */
- bool auto_mode = !name.find("AUTO");
-
- /* Only grant founder privilege if this isn't an auto mode or if they don't match any entries in this group */
- if ((!auto_mode || paths.empty()) && this->founder)
- return true;
-
- EventReturn MOD_RESULT;
- FOREACH_RESULT(OnGroupCheckPriv, MOD_RESULT, (this, name));
- if (MOD_RESULT != EVENT_CONTINUE)
- return MOD_RESULT == EVENT_ALLOW;
-
- for (unsigned int i = paths.size(); i > 0; --i)
- {
- const ChanAccess::Path &path = paths[i - 1];
-
- if (::HasPriv(path, name))
- return true;
- }
-
- return false;
-}
-
-static ChanAccess *HighestInPath(const Ch