From 9bee202b74abbf63b59963369deebaa3efdd551f Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Apr 2013 22:47:15 -0400 Subject: Fix disabling IPV6_V6ONLY on sockets, issue #511 --- src/listensocket.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 07ae491e0..ae11c3b48 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -33,11 +33,6 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t if (this->fd == -1) return; - ServerInstance->SE->SetReuse(fd); - int rv = ServerInstance->SE->Bind(this->fd, bind_to); - if (rv >= 0) - rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn); - #ifdef IPV6_V6ONLY /* This OS supports IPv6 sockets that can also listen for IPv4 * connections. If our address is "*" or empty, enable both v4 and v6 to @@ -48,12 +43,19 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t if (bind_to.sa.sa_family == AF_INET6) { std::string addr = tag->getString("address"); - const char enable = (addr.empty() || addr == "*") ? 0 : 1; - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &enable, sizeof(enable)); + /* This must be >= sizeof(DWORD) on Windows */ + const int enable = (addr.empty() || addr == "*") ? 0 : 1; + /* This must be before bind() */ + setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&enable), sizeof(enable)); // errors ignored intentionally } #endif + ServerInstance->SE->SetReuse(fd); + int rv = ServerInstance->SE->Bind(this->fd, bind_to); + if (rv >= 0) + rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn); + if (rv < 0) { int errstore = errno; -- cgit v1.2.3 From 52386bed51b481f9779ef3525f7c09a10a7e49cf Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 May 2013 04:00:13 -0500 Subject: Fix gnutls (again) on Windows by using gnutls_transport_set_errno() --- src/modules/extra/m_ssl_gnutls.cpp | 98 ++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index b3c7bca3e..e3f9cd566 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -77,46 +77,6 @@ static int cert_callback (gnutls_session_t session, const gnutls_datum_t * req_c return 0; } -static ssize_t gnutls_pull_wrapper(gnutls_transport_ptr_t user_wrap, void* buffer, size_t size) -{ - StreamSocket* user = reinterpret_cast(user_wrap); - if (user->GetEventMask() & FD_READ_WILL_BLOCK) - { - errno = EAGAIN; - return -1; - } - int rv = ServerInstance->SE->Recv(user, reinterpret_cast(buffer), size, 0); - if (rv < 0) - { - /* On Windows we need to set errno for gnutls */ - if (SocketEngine::IgnoreError()) - errno = EAGAIN; - } - if (rv < (int)size) - ServerInstance->SE->ChangeEventMask(user, FD_READ_WILL_BLOCK); - return rv; -} - -static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t user_wrap, const void* buffer, size_t size) -{ - StreamSocket* user = reinterpret_cast(user_wrap); - if (user->GetEventMask() & FD_WRITE_WILL_BLOCK) - { - errno = EAGAIN; - return -1; - } - int rv = ServerInstance->SE->Send(user, reinterpret_cast(buffer), size, 0); - if (rv < 0) - { - /* On Windows we need to set errno for gnutls */ - if (SocketEngine::IgnoreError()) - errno = EAGAIN; - } - if (rv < (int)size) - ServerInstance->SE->ChangeEventMask(user, FD_WRITE_WILL_BLOCK); - return rv; -} - class RandGen : public HandlerBase2 { public: @@ -132,10 +92,12 @@ class RandGen : public HandlerBase2 class issl_session { public: + StreamSocket* socket; gnutls_session_t sess; issl_status status; reference cert; - issl_session() : sess(NULL) {} + + issl_session() : socket(NULL), sess(NULL) {} }; class CommandStartTLS : public SplitCommand @@ -213,6 +175,56 @@ class ModuleSSLGnuTLS : public Module return str ? str : "UNKNOWN"; } + static ssize_t gnutls_pull_wrapper(gnutls_transport_ptr_t session_wrap, void* buffer, size_t size) + { + issl_session* session = reinterpret_cast(session_wrap); + if (session->socket->GetEventMask() & FD_READ_WILL_BLOCK) + { + gnutls_transport_set_errno(session->sess, EAGAIN); + return -1; + } + + int rv = ServerInstance->SE->Recv(session->socket, reinterpret_cast(buffer), size, 0); + if (rv < 0) + { + /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() + * and then set errno appropriately. + * The gnutls library may also have a different errno variable than us, see + * gnutls_transport_set_errno(3). + */ + gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); + } + + if (rv < (int)size) + ServerInstance->SE->ChangeEventMask(session->socket, FD_READ_WILL_BLOCK); + return rv; + } + + static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t session_wrap, const void* buffer, size_t size) + { + issl_session* session = reinterpret_cast(session_wrap); + if (session->socket->GetEventMask() & FD_WRITE_WILL_BLOCK) + { + gnutls_transport_set_errno(session->sess, EAGAIN); + return -1; + } + + int rv = ServerInstance->SE->Send(session->socket, reinterpret_cast(buffer), size, 0); + if (rv < 0) + { + /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() + * and then set errno appropriately. + * The gnutls library may also have a different errno variable than us, see + * gnutls_transport_set_errno(3). + */ + gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); + } + + if (rv < (int)size) + ServerInstance->SE->ChangeEventMask(session->socket, FD_WRITE_WILL_BLOCK); + return rv; + } + public: ModuleSSLGnuTLS() @@ -540,13 +552,14 @@ class ModuleSSLGnuTLS : public Module issl_session* session = &sessions[user->GetFd()]; gnutls_init(&session->sess, me_server ? GNUTLS_SERVER : GNUTLS_CLIENT); + session->socket = user; #ifdef GNUTLS_NEW_PRIO_API gnutls_priority_set(session->sess, priority); #endif gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred); gnutls_dh_set_prime_bits(session->sess, dh_bits); - gnutls_transport_set_ptr(session->sess, reinterpret_cast(user)); + gnutls_transport_set_ptr(session->sess, reinterpret_cast(session)); gnutls_transport_set_push_function(session->sess, gnutls_push_wrapper); gnutls_transport_set_pull_function(session->sess, gnutls_pull_wrapper); @@ -762,6 +775,7 @@ class ModuleSSLGnuTLS : public Module gnutls_bye(session->sess, GNUTLS_SHUT_WR); gnutls_deinit(session->sess); } + session->socket = NULL; session->sess = NULL; session->cert = NULL; session->status = ISSL_NONE; -- cgit v1.2.3 From dc4c8c85f383567aef9325a08515c9890bd89ab8 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 2 May 2013 23:45:10 +0200 Subject: m_ssl_gnutls Call gnutls_transport_set_errno() on Windows only --- src/modules/extra/m_ssl_gnutls.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index e3f9cd566..41e9d0c3d 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -180,11 +180,17 @@ class ModuleSSLGnuTLS : public Module issl_session* session = reinterpret_cast(session_wrap); if (session->socket->GetEventMask() & FD_READ_WILL_BLOCK) { +#ifdef _WIN32 gnutls_transport_set_errno(session->sess, EAGAIN); +#else + errno = EAGAIN; +#endif return -1; } int rv = ServerInstance->SE->Recv(session->socket, reinterpret_cast(buffer), size, 0); + +#ifdef _WIN32 if (rv < 0) { /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() @@ -194,6 +200,7 @@ class ModuleSSLGnuTLS : public Module */ gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); } +#endif if (rv < (int)size) ServerInstance->SE->ChangeEventMask(session->socket, FD_READ_WILL_BLOCK); @@ -205,11 +212,17 @@ class ModuleSSLGnuTLS : public Module issl_session* session = reinterpret_cast(session_wrap); if (session->socket->GetEventMask() & FD_WRITE_WILL_BLOCK) { +#ifdef _WIN32 gnutls_transport_set_errno(session->sess, EAGAIN); +#else + errno = EAGAIN; +#endif return -1; } int rv = ServerInstance->SE->Send(session->socket, reinterpret_cast(buffer), size, 0); + +#ifdef _WIN32 if (rv < 0) { /* Windows doesn't use errno, but gnutls does, so check SocketEngine::IgnoreError() @@ -219,6 +232,7 @@ class ModuleSSLGnuTLS : public Module */ gnutls_transport_set_errno(session->sess, SocketEngine::IgnoreError() ? EAGAIN : errno); } +#endif if (rv < (int)size) ServerInstance->SE->ChangeEventMask(session->socket, FD_WRITE_WILL_BLOCK); -- cgit v1.2.3 From 6a1892b1c1bdd8e8ecb519933ee9887adb5b8585 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 6 May 2013 17:39:24 +0100 Subject: Fix an extremely low risk crash bug in m_connectban. --- src/modules/m_connectban.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index dc2bc3f18..26120add9 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -97,11 +97,12 @@ class ModuleConnectBan : public Module { // Create zline for set duration. ZLine* zl = new ZLine(ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect.", mask.str()); - if (ServerInstance->XLines->AddLine(zl,NULL)) - ServerInstance->XLines->ApplyLines(); - else + if (!ServerInstance->XLines->AddLine(zl, NULL)) + { delete zl; - + return; + } + ServerInstance->XLines->ApplyLines(); std::string maskstr = mask.str(); std::string timestr = ServerInstance->TimeString(zl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding", -- cgit v1.2.3 From 7fb10c11e442135988d9ea0646f6f2b4a5e421f7 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 15 May 2013 20:02:55 +0200 Subject: Fix thread handle leak in threadengine_win32 --- src/threadengines/threadengine_win32.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp index 637a3e010..529e24a29 100644 --- a/src/threadengines/threadengine_win32.cpp +++ b/src/threadengines/threadengine_win32.cpp @@ -65,6 +65,7 @@ void ThreadData::FreeThread(Thread* thread) { thread->SetExitFlag(); WaitForSingleObject(handle,INFINITE); + CloseHandle(handle); } class ThreadSignalSocket : public BufferedSocket -- cgit v1.2.3 From 0a8b0d317ed4adc43185c1b791bcf752115dc58e Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 16 May 2013 20:33:46 +0200 Subject: Remove unused variables, avoid copies where possible, check empty() instead of size() == 0 Most of these were detected by cppcheck --- include/command_parse.h | 10 ---------- include/modules.h | 2 +- src/channels.cpp | 1 - src/command_parse.cpp | 2 -- src/modules/m_alias.cpp | 2 +- src/modules/m_filter.cpp | 2 +- src/modules/m_kicknorejoin.cpp | 2 +- src/modules/m_operprefix.cpp | 2 +- src/modules/m_spanningtree/netburst.cpp | 1 - src/modules/m_sqloper.cpp | 2 +- src/modules/u_listmode.h | 4 ++-- 11 files changed, 8 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/include/command_parse.h b/include/command_parse.h index f6ff588e1..f9e3a740c 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -23,10 +23,6 @@ #ifndef COMMAND_PARSE_H #define COMMAND_PARSE_H -/** A list of dll/so files containing the command handlers for the core - */ -typedef std::map SharedObjectList; - /** This class handles command management and parsing. * It allows you to add and remove commands from the map, * call command handlers by name, and chop up comma seperated @@ -35,10 +31,6 @@ typedef std::map SharedObjectList; class CoreExport CommandParser { private: - /** Parameter buffer - */ - std::vector para; - /** Process a parameter string into a list of items * @param command_p The output list of items * @param parameters The input string @@ -52,8 +44,6 @@ class CoreExport CommandParser */ bool ProcessCommand(LocalUser *user, std::string &cmd); - - public: /** Command list, a hash_map of command names to Command* */ diff --git a/include/modules.h b/include/modules.h index 8aedaabdd..00f2cbb62 100644 --- a/include/modules.h +++ b/include/modules.h @@ -116,7 +116,7 @@ struct ModResult { * and numerical comparisons in preprocessor macros if they wish to support * multiple versions of InspIRCd in one file. */ -#define INSPIRCD_VERSION_API 5 +#define INSPIRCD_VERSION_API 6 /** * This #define allows us to call a method in all diff --git a/src/channels.cpp b/src/channels.cpp index 3502abe12..4f63654a5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -673,7 +673,6 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList char tb[MAXBUF]; snprintf(tb,MAXBUF,":%s %s", serversource ? ServerInstance->Config->ServerName.c_str() : user->GetFullHost().c_str(), text.c_str()); - std::string out = tb; this->RawWriteAllExcept(user, serversource, status, except_list, std::string(tb)); } diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 0bf8e0e0a..b05b34c9b 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -389,7 +389,6 @@ bool CommandParser::AddCommand(Command *f) CommandParser::CommandParser() { - para.resize(128); } int CommandParser::TranslateUIDs(const std::vector to, const std::vector &source, std::string &dest, bool prefix_final, Command* custom_translator) @@ -451,7 +450,6 @@ int CommandParser::TranslateUIDs(const std::vector to, const std: int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest) { User* user = NULL; - std::string item; int translations = 0; dest.clear(); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 97b1612af..25f071bab 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -251,7 +251,7 @@ class ModuleAlias : public Module } - int DoAlias(User *user, Channel *c, Alias *a, const std::string compare, const std::string safe) + int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe) { User *u = NULL; diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 5e1b4d38d..4090f5600 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -60,7 +60,7 @@ class FilterResult bool flag_notice; bool flag_strip_color; - FilterResult(const std::string free, const std::string &rea, FilterAction act, long gt, const std::string &fla) : + FilterResult(const std::string& free, const std::string& rea, FilterAction act, long gt, const std::string& fla) : freeform(free), reason(rea), action(act), gline_time(gt) { this->FillFlags(fla); diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index c754aa0f0..a914f3869 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -124,7 +124,7 @@ public: } } - if (!dl->size()) + if (dl->empty()) kr.ext.unset(chan); } } diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index b6e6b893b..25937cd6e 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -51,7 +51,7 @@ class OperPrefixMode : public ModeHandler return MODEACTION_ALLOW; else { - if (source && channel) + if (channel) source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only servers are permitted to change channel mode '%c'", source->nick.c_str(), channel->name.c_str(), 'y'); return MODEACTION_DENY; } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 5248ea897..d508c092d 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -240,7 +240,6 @@ void TreeSocket::SendChannelModes() void TreeSocket::SendUsers() { char data[MAXBUF]; - std::string dataline; for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { if (u->second->registered == REG_ALL) diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 03b626963..ae581cc4b 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -119,7 +119,7 @@ class OpMeQuery : public SQLQuery hostname.append("@").append(user->host); - if (OneOfMatches(hostname.c_str(), user->GetIPString(), pattern.c_str())) + if (OneOfMatches(hostname.c_str(), user->GetIPString(), pattern)) { /* Opertype and host match, looks like this is it. */ diff --git a/src/modules/u_listmode.h b/src/modules/u_listmode.h index b370c86e8..0f5903e53 100644 --- a/src/modules/u_listmode.h +++ b/src/modules/u_listmode.h @@ -201,7 +201,7 @@ class ListModeBase : public ModeHandler if (limit.mask.size() && limit.limit > 0) chanlimits.push_back(limit); } - if (chanlimits.size() == 0) + if (chanlimits.empty()) { ListLimit limit; limit.mask = "*"; @@ -316,7 +316,7 @@ class ListModeBase : public ModeHandler if (parameter == it->mask) { el->erase(it); - if (el->size() == 0) + if (el->empty()) { extItem.unset(channel); } -- cgit v1.2.3 From bb962f92ace6eb23c66c5fccee01f825c22363c3 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 16 May 2013 20:51:12 +0200 Subject: Workaround for std::list::size() having linear complexity on some implementations --- include/usermanager.h | 6 +++++- src/usermanager.cpp | 3 ++- src/users.cpp | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/include/usermanager.h b/include/usermanager.h index 3d7fe88fb..743db508a 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -63,7 +63,11 @@ class CoreExport UserManager /** Number of unregistered users online right now. * (Unregistered means before USER/NICK/dns) */ - int unregistered_count; + unsigned int unregistered_count; + + /** Number of elements in local_users + */ + unsigned int local_count; /** Map of global ip addresses for clone counting * XXX - this should be private, but m_clones depends on it currently. diff --git a/src/usermanager.cpp b/src/usermanager.cpp index e3ddfc9f2..670add777 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -74,6 +74,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs ServerInstance->Users->AddGlobalClone(New); New->localuseriter = this->local_users.insert(local_users.end(), New); + local_count++; if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds())) { @@ -332,7 +333,7 @@ unsigned int UserManager::UnregisteredUserCount() unsigned int UserManager::LocalUserCount() { /* Doesnt count unregistered clients */ - return (this->local_users.size() - this->UnregisteredUserCount()); + return (this->local_count - this->UnregisteredUserCount()); } void UserManager::ServerNoticeAll(const char* text, ...) diff --git a/src/users.cpp b/src/users.cpp index f48e3642f..2305ba8ce 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -545,7 +545,10 @@ CullResult LocalUser::cull() // overwritten in UserManager::AddUser() with the real iterator so this check // is only a precaution currently. if (localuseriter != ServerInstance->Users->local_users.end()) + { + ServerInstance->Users->local_count--; ServerInstance->Users->local_users.erase(localuseriter); + } else ServerInstance->Logs->Log("USERS", DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick); -- cgit v1.2.3 From 3f782d5cad84165d695203977c75d2a3877f4644 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 16 May 2013 19:57:53 -0400 Subject: Fix m_randquote with 0 quotes --- src/modules.cpp | 2 +- src/modules/m_randquote.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/modules.cpp b/src/modules.cpp index a7b3364ae..d25e145e3 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -765,7 +765,7 @@ bool FileReader::Exists() std::string FileReader::GetLine(int x) { - if ((x<0) || ((unsigned)x>fc.size())) + if ((x<0) || ((unsigned)x>=fc.size())) return ""; return fc[x]; } diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index dab3c93cd..668eea0e5 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -41,12 +41,13 @@ class CommandRandquote : public Command CmdResult Handle (const std::vector& parameters, User *user) { - std::string str; - int fsize; - - fsize = quotes->FileSize(); - str = quotes->GetLine(ServerInstance->GenRandomInt(fsize)); - user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str()); + int fsize = quotes->FileSize(); + if (fsize) + { + std::string str = quotes->GetLine(ServerInstance->GenRandomInt(fsize)); + if (!str.empty()) + user->WriteServ("NOTICE %s :%s%s%s",user->nick.c_str(),prefix.c_str(),str.c_str(),suffix.c_str()); + } return CMD_SUCCESS; } -- cgit v1.2.3 From 67822c67e91e70917ddbdec0bd8453c7170ee06d Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 18 May 2013 16:03:17 +0200 Subject: Initialize local_count --- include/usermanager.h | 2 ++ src/inspircd.cpp | 2 -- src/usermanager.cpp | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/include/usermanager.h b/include/usermanager.h index 743db508a..ac8ae1cb3 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -32,6 +32,8 @@ class CoreExport UserManager */ clonemap local_clones; public: + UserManager(); + ~UserManager() { for (user_hash::iterator i = clientlist->begin();i != clientlist->end();i++) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 344e2a473..4def50c87 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -375,8 +375,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : // Create base manager classes early, so nothing breaks this->Users = new UserManager; - this->Users->unregistered_count = 0; - this->Users->clientlist = new user_hash(); this->Users->uuidlist = new user_hash(); this->chanlist = new chan_hash(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 670add777..076277a33 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -24,6 +24,11 @@ #include "xline.h" #include "bancache.h" +UserManager::UserManager() + : unregistered_count(0), local_count(0) +{ +} + /* add a client connection to the sockets list */ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) { -- cgit v1.2.3 From b92f3e2032357e5e2aed9814ef169c6560787da7 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 18 May 2013 16:04:10 +0200 Subject: m_geoip Set cc in OnSetConnectClass to the newly created string if it was NULL --- src/modules/extra/m_geoip.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp index c93479b3c..a36c39bc8 100644 --- a/src/modules/extra/m_geoip.cpp +++ b/src/modules/extra/m_geoip.cpp @@ -35,7 +35,7 @@ class ModuleGeoIP : public Module LocalStringExt ext; GeoIP* gi; - void SetExt(LocalUser* user) + std::string* SetExt(LocalUser* user) { const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString()); if (!c) @@ -43,6 +43,7 @@ class ModuleGeoIP : public Module std::string* cc = new std::string(c); ext.set(user, cc); + return cc; } public: @@ -85,7 +86,7 @@ class ModuleGeoIP : public Module { std::string* cc = ext.get(user); if (!cc) - SetExt(user); + cc = SetExt(user); std::string geoip = myclass->config->getString("geoip"); if (geoip.empty()) -- cgit v1.2.3 From 740539d620997cc47fe930db13f41d1c4a650299 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 18 May 2013 16:05:08 +0200 Subject: m_httpd_acl Reread config on rehash --- src/modules/m_httpd_acl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index 2694402bd..c25cabc0a 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -49,7 +49,7 @@ class ModuleHTTPAccessList : public Module public: - void ReadConfig() + void OnRehash(User* user) { acl_list.clear(); ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl"); @@ -95,8 +95,8 @@ class ModuleHTTPAccessList : public Module void init() { - ReadConfig(); - Implementation eventlist[] = { I_OnEvent }; + OnRehash(NULL); + Implementation eventlist[] = { I_OnEvent, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } -- cgit v1.2.3 From ecf7690813b936a1751281f4b4a5199aa1db02c8 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 18 May 2013 21:02:09 +0200 Subject: m_channames Fix iteration in ValidateChans() Spotted by @Adam- --- src/modules/m_channames.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index e78171c4a..b5f5853e7 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -89,9 +89,17 @@ class ModuleChannelNames : public Module ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient); } const UserMembList* users = c->GetUsers(); - for(UserMembCIter j = users->begin(); j != users->end(); ++j) + for(UserMembCIter j = users->begin(); j != users->end(); ) + { if (IS_LOCAL(j->first)) - c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid"); + { + // KickUser invalidates the iterator + UserMembCIter it = j++; + c->KickUser(ServerInstance->FakeClient, it->first, "Channel name no longer valid"); + } + else + ++j; + } } badchan = false; } -- cgit v1.2.3 From 8d172c077e41e08e3864615538c6b06f07f24d84 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 22 May 2013 22:29:15 +0200 Subject: m_mysql Fix crash on rehash when the database tags have been changed in the config --- src/modules/extra/m_mysql.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 682f041ad..16c4485f3 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -435,13 +435,14 @@ void ModuleSQL::OnRehash(User* user) i->second->lock.Lock(); i->second->lock.Unlock(); // now remove all active queries to this DB - for(unsigned int j = qq.size() - 1; j >= 0; j--) + for (size_t j = qq.size(); j > 0; j--) { - if (qq[j].c == i->second) + size_t k = j - 1; + if (qq[k].c == i->second) { - qq[j].q->OnError(err); - delete qq[j].q; - qq.erase(qq.begin() + j); + qq[k].q->OnError(err); + delete qq[k].q; + qq.erase(qq.begin() + k); } } // finally, nuke the connection -- cgit v1.2.3 From 7e990d1af81414b6b5147f561155d5919e1dd7ea Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 23 May 2013 20:12:09 +0200 Subject: Update authors --- src/commands/cmd_info.cpp | 15 ++++++++------- src/inspircd.cpp | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/commands/cmd_info.cpp b/src/commands/cmd_info.cpp index 63debd3fe..6e5f2a909 100644 --- a/src/commands/cmd_info.cpp +++ b/src/commands/cmd_info.cpp @@ -64,26 +64,27 @@ static const char* const lines[] = { " Matt Smith, dz, ", " Daniel De Graaf, danieldg, ", " jackmcbarn, ", + " Attila Molnar, Attila, ", " ", "\2Regular Contributors\2:", - " Majic MacGyver Namegduf Ankit", - " Phoenix Taros", + " Adam SaberUK", " ", "\2Other Contributors\2:", + " ChrisTX Shawn Shutter", + " ", + "\2Former Contributors\2:", " dmb Zaba skenmy GreenReaper", " Dan Jason satmd owine", " Adremelech John2 jilles HiroP", " eggy Bricker AnMaster djGrrr", " nenolod Quension praetorian pippijn", - " Adam", - " ", - "\2Former Contributors\2:", " CC jamie typobox43 Burlex (win32)", " Stskeeps ThaPrince BuildSmart Thunderhacker", - " Skip LeaChim", + " Skip LeaChim Majic MacGyver", + " Namegduf Ankit Phoenix Taros", " ", "\2Thanks To\2:", - " searchirc.com irc-junkie.org Brik", + " searchirc.com irc-junkie.org Brik fraggeln", " ", " Best experienced with: \2An IRC client\2", NULL diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 4def50c87..1403cdef5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -509,7 +509,8 @@ InspIRCd::InspIRCd(int argc, char** argv) : std::cout << con_green << "(C) InspIRCd Development Team." << con_reset << std::endl << std::endl; std::cout << "Developers:" << std::endl; std::cout << con_green << "\tBrain, FrostyCoolSlug, w00t, Om, Special, peavey" << std::endl; - std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << con_reset << std::endl << std::endl; + std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << std::endl; + std::cout << "\tAttila" << con_reset << std::endl << std::endl; std::cout << "Others:\t\t\t" << con_green << "See /INFO Output" << con_reset << std::endl; this->Modes = new ModeParser; -- cgit v1.2.3 From 4801080b51674b2c766e27d04e6459ef65dc6a47 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 23 May 2013 20:19:16 +0200 Subject: m_nicklock Fix wrong hook in SetPriority() --- src/modules/m_nicklock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index abeb25869..4f5e5941c 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -187,7 +187,7 @@ class ModuleNickLock : public Module void Prioritize() { Module *nflood = ServerInstance->Modules->Find("m_nickflood.so"); - ServerInstance->Modules->SetPriority(this, I_OnUserPreJoin, PRIORITY_BEFORE, &nflood); + ServerInstance->Modules->SetPriority(this, I_OnUserPreNick, PRIORITY_BEFORE, &nflood); } }; -- cgit v1.2.3 From c70a6b5699ef905c05bc669fb6cc9c16f33c6787 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 16 May 2013 19:49:56 +0200 Subject: m_userip Allow querying own IP for non-opers, require the users/auspex priv for opers to query the IP of others Issue #513 suggested by @CuleX --- src/modules/m_userip.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index a28c12444..bfac36b1a 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -30,19 +30,37 @@ class CommandUserip : public Command public: CommandUserip(Module* Creator) : Command(Creator,"USERIP", 1) { - flags_needed = 'o'; syntax = "{,}"; + syntax = "{,}"; } CmdResult Handle (const std::vector ¶meters, User *user) { std::string retbuf = "340 " + user->nick + " :"; int nicks = 0; + bool checked_privs = false; + bool has_privs; for (int i = 0; i < (int)parameters.size(); i++) { User *u = ServerInstance->FindNick(parameters[i]); if ((u) && (u->registered == REG_ALL)) { + // Anyone may query their own IP + if (u != user) + { + if (!checked_privs) + { + // Do not trigger the insufficient priviliges message more than once + checked_privs = true; + has_privs = user->HasPrivPermission("users/auspex"); + if (!has_privs) + user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str()); + } + + if (!has_privs) + continue; + } + retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "="; if (IS_AWAY(u)) retbuf += "-"; @@ -56,7 +74,6 @@ class CommandUserip : public Command if (nicks != 0) user->WriteServ(retbuf); - /* Dont send to the network */ return CMD_SUCCESS; } }; -- cgit v1.2.3 From 0e09600a431d0e0f2cde6457e088d84caf6d6f5d Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 1 Jun 2013 20:53:32 +0200 Subject: m_mysql Fix escaping strings longer than MAXBUF/2 Quotes from the documentation: "You must allocate the to buffer to be at least length*2+1 bytes long. (In the worst case, each character may need to be encoded as using two bytes, and you need room for the terminating null byte.)" "The return value is the length of the encoded string, not including the terminating null character." http://dev.mysql.com/doc/refman/5.6/en/mysql-real-escape-string.html --- src/modules/extra/m_mysql.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 16c4485f3..b2bb44408 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -333,10 +333,15 @@ class SQLConnection : public SQLProvider if (param < p.size()) { std::string parm = p[param++]; - char buffer[MAXBUF]; - mysql_escape_string(buffer, parm.c_str(), parm.length()); + // In the worst case, each character may need to be encoded as using two bytes, + // and one byte is the terminating null + std::vector buffer(parm.length() * 2 + 1); + + // The return value of mysql_escape_string() is the length of the encoded string, + // not including the terminating null + unsigned long escapedsize = mysql_escape_string(&buffer[0], parm.c_str(), parm.length()); // mysql_real_escape_string(connection, queryend, paramscopy[paramnum].c_str(), paramscopy[paramnum].length()); - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } @@ -362,9 +367,10 @@ class SQLConnection : public SQLProvider if (it != p.end()) { std::string parm = it->second; - char buffer[MAXBUF]; - mysql_escape_string(buffer, parm.c_str(), parm.length()); - res.append(buffer); + // NOTE: See above + std::vector buffer(parm.length() * 2 + 1); + unsigned long escapedsize = mysql_escape_string(&buffer[0], parm.c_str(), parm.length()); + res.append(&buffer[0], escapedsize); } } } -- cgit v1.2.3 From c8ef121681b73748bb78a2fdefca5d5973491f25 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sat, 1 Jun 2013 20:53:45 +0200 Subject: cmd_who Hide +i users when listing users on a server and hidewhois is off Fixes #547 reported by @RawrDragon --- src/commands/cmd_who.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index c8cb67694..f8926b9f7 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -264,7 +264,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * for (const char* check = matchtext; *check; check++) { - if (*check == '*' || *check == '?') + if (*check == '*' || *check == '?' || *check == '.') { usingwildcards = true; break; -- cgit v1.2.3 From 9b08c60495603920baf3ab14607c702e1411bce6 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 4 Jun 2013 21:38:03 +0200 Subject: m_pgsql Same fix as 0e09600a431d0e0f2cde6457e088d84caf6d6f5d --- src/modules/extra/m_pgsql.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 7751f9b82..ac247548a 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -412,16 +412,16 @@ restart: if (param < p.size()) { std::string parm = p[param++]; - char buffer[MAXBUF]; + std::vector buffer(parm.length() * 2 + 1); #ifdef PGSQL_HAS_ESCAPECONN int error; - PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error); + size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log("m_pgsql", DEBUG, "BUG: Apparently PQescapeStringConn() failed"); #else - PQescapeString (buffer, parm.c_str(), parm.length()); + size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); #endif - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } @@ -447,16 +447,16 @@ restart: if (it != p.end()) { std::string parm = it->second; - char buffer[MAXBUF]; + std::vector buffer(parm.length() * 2 + 1); #ifdef PGSQL_HAS_ESCAPECONN int error; - PQescapeStringConn(sql, buffer, parm.c_str(), parm.length(), &error); + size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error); if (error) ServerInstance->Logs->Log("m_pgsql", DEBUG, "BUG: Apparently PQescapeStringConn() failed"); #else - PQescapeString (buffer, parm.c_str(), parm.length()); + size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length()); #endif - res.append(buffer); + res.append(&buffer[0], escapedsize); } } } -- cgit v1.2.3 From f07eda62da11eaab091e817e41d3a2bc8f4bd8d0 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 4 Jun 2013 22:16:15 +0200 Subject: m_spanningtree Fix FIDENT routing A new FIDENT was broadcast for each incoming FIDENT causing harmless but unnecessary server to server traffic --- src/modules/m_spanningtree/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index fdb9ef200..7e6ad12f8 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -652,8 +652,7 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos) void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident) { - // only occurs for local clients - if (user->registered != REG_ALL) + if ((user->registered != REG_ALL) || (!IS_LOCAL(user))) return; parameterlist params; -- cgit v1.2.3 From d87bfc277858543ff14cd43f4222c66362464094 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 5 Jun 2013 23:11:50 +0200 Subject: Remove unnecessary string copies and dead code --- src/commands/cmd_loadmodule.cpp | 2 +- src/modes/umode_o.cpp | 2 +- src/modules/extra/m_mysql.cpp | 1 - src/modules/m_cban.cpp | 2 +- src/modules/m_dccallow.cpp | 2 +- src/modules/m_passforward.cpp | 2 +- src/modules/m_rline.cpp | 5 ++--- src/modules/m_sasl.cpp | 4 ++-- src/modules/m_shun.cpp | 4 ++-- src/modules/m_spanningtree/main.cpp | 3 +-- src/modules/m_spanningtree/utils.cpp | 18 ++---------------- src/modules/m_spanningtree/utils.h | 15 ++------------- src/modules/m_svshold.cpp | 2 +- 13 files changed, 17 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/commands/cmd_loadmodule.cpp b/src/commands/cmd_loadmodule.cpp index 9d60613a2..379e597e4 100644 --- a/src/commands/cmd_loadmodule.cpp +++ b/src/commands/cmd_loadmodule.cpp @@ -44,7 +44,7 @@ class CommandLoadmodule : public Command */ CmdResult CommandLoadmodule::Handle (const std::vector& parameters, User *user) { - if (ServerInstance->Modules->Load(parameters[0].c_str())) + if (ServerInstance->Modules->Load(parameters[0])) { ServerInstance->SNO->WriteGlobalSno('a', "NEW MODULE: %s loaded %s",user->nick.c_str(), parameters[0].c_str()); user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str()); diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp index 5fb62571d..a5f590ba0 100644 --- a/src/modes/umode_o.cpp +++ b/src/modes/umode_o.cpp @@ -32,7 +32,7 @@ ModeUserOperator::ModeUserOperator() : ModeHandler(NULL, "oper", 'o', PARAM_NONE ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding) { /* Only opers can execute this class at all */ - if (!ServerInstance->ULine(source->nick.c_str()) && !ServerInstance->ULine(source->server) && !IS_OPER(source)) + if (!ServerInstance->ULine(source->server) && !IS_OPER(source)) return MODEACTION_DENY; /* Not even opers can GIVE the +o mode, only take it away */ diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index b2bb44408..22cf5f3f4 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -180,7 +180,6 @@ class MySQLresult : public SQLResult rows++; } mysql_free_result(res); - res = NULL; } } diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index c779f02df..fb78e41b2 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -32,7 +32,7 @@ class CBan : public XLine public: irc::string matchtext; - CBan(time_t s_time, long d, std::string src, std::string re, std::string ch) + CBan(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& ch) : XLine(s_time, d, src, re, "CBAN") { this->matchtext = ch.c_str(); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 712dd91b8..de7b6b7bf 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -166,7 +166,7 @@ class CommandDccallow : public Command length = ServerInstance->Duration(parameters[1]); } - if (!ServerInstance->IsValidMask(mask.c_str())) + if (!ServerInstance->IsValidMask(mask)) { return CMD_FAILURE; } diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index 84389fb22..c04b306b1 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -91,7 +91,7 @@ class ModulePassForward : public Module if (!nickrequired.empty()) { /* Check if nick exists and its server is ulined */ - User* u = ServerInstance->FindNick(nickrequired.c_str()); + User* u = ServerInstance->FindNick(nickrequired); if (!u || !ServerInstance->ULine(u->server)) return; } diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 160092a63..d1ab5d9ba 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -41,11 +41,10 @@ class RLine : public XLine * @param regex Pattern to match with * @ */ - RLine(time_t s_time, long d, std::string src, std::string re, std::string regexs, dynamic_reference& rxfactory) + RLine(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference& rxfactory) : XLine(s_time, d, src, re, "R") + , matchtext(regexs) { - matchtext = regexs; - /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time */ diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index f8d8c5322..b67111987 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -52,7 +52,7 @@ class SaslAuthenticator bool state_announced; public: - SaslAuthenticator(User *user_, std::string method, Module *ctor) + SaslAuthenticator(User* user_, const std::string& method) : user(user_), state(SASL_INIT), state_announced(false) { parameterlist params; @@ -195,7 +195,7 @@ class CommandAuthenticate : public Command SaslAuthenticator *sasl = authExt.get(user); if (!sasl) - authExt.set(user, new SaslAuthenticator(user, parameters[0], creator)); + authExt.set(user, new SaslAuthenticator(user, parameters[0])); else if (sasl->SendClientMessage(parameters) == false) // IAL abort extension --nenolod { sasl->AnnounceState(); diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 21959e400..8bf4d30e7 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -30,10 +30,10 @@ class Shun : public XLine public: std::string matchtext; - Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask) + Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask) : XLine(s_time, d, src, re, "SHUN") + , matchtext(shunmask) { - this->matchtext = shunmask; } ~Shun() diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 7e6ad12f8..7c93e7d45 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -271,8 +271,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) return; } - QueryType start_type = DNS_QUERY_A; - start_type = DNS_QUERY_AAAA; + QueryType start_type = DNS_QUERY_AAAA; if (strchr(x->IPAddr.c_str(),':')) { in6_addr n; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index cc1c400db..1879d7111 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -202,7 +202,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerLis return; } -bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string omit) +bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, const std::string& omit) { TreeServer* omitroute = this->BestRouteTo(omit); std::string FullLine = ":" + prefix + " " + command; @@ -251,21 +251,7 @@ bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::st return true; } -bool SpanningTreeUtilities::DoOneToMany(const char* prefix, const char* command, const parameterlist ¶ms) -{ - std::string spfx = prefix; - std::string scmd = command; - return this->DoOneToMany(spfx, scmd, params); -} - -bool SpanningTreeUtilities::DoOneToAllButSender(const char* prefix, const char* command, const parameterlist ¶ms, std::string omit) -{ - std::string spfx = prefix; - std::string scmd = command; - return this->DoOneToAllButSender(spfx, scmd, params, omit); -} - -bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string target) +bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, const std::string& target) { TreeServer* Route = this->BestRouteTo(target); if (Route) diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 7d5ffa216..92a03428f 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -88,9 +88,6 @@ class SpanningTreeUtilities : public classbase /** Hash of currently known server ids */ server_hash sidlist; - /** Hash of servers currently bursting but not initialized as connected - */ - std::map burstingserverlist; /** List of all outgoing sockets and their timeouts */ std::map > timeoutlist; @@ -129,24 +126,16 @@ class SpanningTreeUtilities : public classbase /** Send a message from this server to one other local or remote */ - bool DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string target); - - /** Send a message from this server to all but one other, local or remote - */ - bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string omit); + bool DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, const std::string& target); /** Send a message from this server to all but one other, local or remote */ - bool DoOneToAllButSender(const char* prefix, const char* command, const parameterlist ¶ms, std::string omit); + bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, const std::string& omit); /** Send a message from this server to all others */ bool DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms); - /** Send a message from this server to all others - */ - bool DoOneToMany(const char* prefix, const char* command, const parameterlist ¶ms); - /** Read the spanningtree module's tags from the config file */ void ReadConfiguration(); diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index d2269839d..d8176043e 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -32,7 +32,7 @@ class SVSHold : public XLine public: irc::string nickname; - SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick) + SVSHold(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& nick) : XLine(s_time, d, src, re, "SVSHOLD") { this->nickname = nick.c_str(); -- cgit v1.2.3 From e0ff94b310e9b73ac0131e9df14fb7ca2bf3a878 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 5 Jun 2013 23:28:45 +0200 Subject: Release 2.0.13 --- src/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/version.sh b/src/version.sh index d759d06a7..446246633 100755 --- a/src/version.sh +++ b/src/version.sh @@ -1,2 +1,2 @@ #!/bin/sh -echo "InspIRCd-2.0.12" +echo "InspIRCd-2.0.13" -- cgit v1.2.3