From 73e93305c10f349742fad3b2197c6c5dd3aea34e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 24 Apr 2010 19:38:17 -0400 Subject: Added nickserv/auspex permission and fixed core modules so they build --- src/modules/hs_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index ebc46dfe8..0113817b7 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -339,7 +339,7 @@ class HSListBase : public Command return MOD_CONT; } public: - HSListBase(const std::string &cmd, int min, int max) : Command(cmd, min, max, "hostserv/set") + HSListBase(const ci::string &cmd, int min, int max) : Command(cmd, min, max, "hostserv/set") { } -- cgit From 503958aa77382a85a041e195d04b7a2ec51589e3 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Apr 2010 18:56:31 -0400 Subject: Prevent negaitve mode changes, kicks, bans, and autokicks from affecting users with unreal usermode +q or similar --- src/modules/cs_tban.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 10f295b3d..12fe8cd65 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -203,7 +203,7 @@ int canBanUser(Channel * c, User * u, User * u2) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (is_excepted(ci, u2)) notice_lang(Config.s_ChanServ, u, CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - else if (is_protected(u2)) + else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else ok = 1; -- cgit From a93be9ff1c417d73015fd53a9ee778ea2a642328 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 6 May 2010 14:42:21 -0400 Subject: Added two events called in ns_info and cs_info that allows modules to easially add info output. Made os_info use this --- src/modules/os_info.c | 53 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) (limited to 'src/modules') diff --git a/src/modules/os_info.c b/src/modules/os_info.c index 87d8ea298..b486e32f6 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -409,8 +409,8 @@ class OSInfo : public Module this->InsertLanguage(LANG_RU, LANG_NUM_STRINGS, langtable_ru); this->InsertLanguage(LANG_IT, LANG_NUM_STRINGS, langtable_it); - Implementation i[] = { I_OnNickServHelp, I_OnChanServHelp, I_OnPostCommand, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata }; - ModuleManager::Attach(i, this, 5); + Implementation i[] = { I_OnNickServHelp, I_OnChanServHelp, I_OnNickInfo, I_OnChanInfo, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata }; + ModuleManager::Attach(i, this, 6); } ~OSInfo() @@ -439,42 +439,23 @@ class OSInfo : public Module } } - void OnPostCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) + void OnNickInfo(User *u, NickAlias *na, bool) { - if (command == "INFO") + if (is_oper(u)) { - if (service == Config.s_NickServ) - { - const char *nick = params[0].c_str(); - NickAlias *na = NULL; - - if (is_oper(u)) /* Only show our goodies to opers */ - { - if ((na = findnick(nick))) /* ok we've found the user */ - { - /* If we have any info on this user */ - char *c; - if (na->nc->GetExtArray("os_info", c)) - u->SendMessage(Config.s_NickServ, " OperInfo: %s", c); - } - } - } - else if (service == Config.s_ChanServ) - { - const char *chan = params[0].c_str(); - ChannelInfo *ci = NULL; - - if (is_oper(u)) /* Only show our goodies to opers */ - { - if ((ci = cs_findchan(chan))) - { - /* If we have any info on this channel */ - char *c; - if (ci->GetExtArray("os_info", c)) - u->SendMessage(Config.s_ChanServ, " OperInfo: %s", c); - } - } - } + char *c; + if (na->nc->GetExtArray("os_info", c)) + u->SendMessage(Config.s_NickServ, " OperInfo: %s", c); + } + } + + void OnChanInfo(User *u, ChannelInfo *ci, bool) + { + if (is_oper(u)) + { + char *c; + if (ci->GetExtArray("os_info", c)) + u->SendMessage(Config.s_ChanServ, " OperInfo: %s", c); } } -- cgit From 9439cac6b126254bc488c2375b9e7ff5fd4fce74 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 May 2010 14:11:21 -0400 Subject: Added m_ssl.cpp which allows Anope to use SSL when connecting to its uplink --- src/modules/CMakeLists.txt | 1 + src/modules/ssl/m_ssl.cpp | 150 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 src/modules/ssl/m_ssl.cpp (limited to 'src/modules') diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index ad66663c3..6cb5b5612 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -58,6 +58,7 @@ endforeach(SRC) file(GLOB MODULES_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*") remove_item_from_list(MODULES_FILES "CMakeFiles") remove_item_from_list(MODULES_FILES "mysql") +remove_item_from_list(MODULES_FILES "ssl") # Iterate through this directory searching for subdirectories, and creating modules for those subdirectories foreach(FILE ${MODULES_FILES}) diff --git a/src/modules/ssl/m_ssl.cpp b/src/modules/ssl/m_ssl.cpp new file mode 100644 index 000000000..8036de6ce --- /dev/null +++ b/src/modules/ssl/m_ssl.cpp @@ -0,0 +1,150 @@ +/* RequiredLibraries: ssl,crypt */ + +#include "module.h" + +#include +#include +#include +#include +#include + +#define CERTFILE "anope.cert" +#define KEYFILE "anope.key" + +static SSL_CTX *ctx; + +class SSLSocket : public Socket +{ + private: + SSL *sslsock; + + int RecvInternal(char *buf, size_t sz) const + { + return SSL_read(sslsock, buf, sz); + } + + int SendInternal(const std::string &buf) const + { + return SSL_write(sslsock, buf.c_str(), buf.size()); + } + public: + SSLSocket(const std::string &nTargetHost, int nPort, const std::string &nBindHost = "", bool nIPv6 = false) : Socket(nTargetHost, nPort, nBindHost, nIPv6) + { + sslsock = SSL_new(ctx); + + if (!sslsock) + throw CoreException("Unable to initialize SSL socket"); + + SSL_set_connect_state(sslsock); + SSL_set_fd(sslsock, Sock); + SSL_connect(sslsock); + + UplinkSock = this; + } + + ~SSLSocket() + { + SSL_shutdown(sslsock); + SSL_free(sslsock); + + UplinkSock = NULL; + } + + bool Read(const std::string &buf) + { + process(buf); + return true; + } +}; + +class SSLModule : public Module +{ + public: + SSLModule(const std::string &modname, const std::string &creator) : Module(modname, creator) + { + this->SetAuthor("Anope"); + this->SetVersion("$Id$"); + this->SetType(SUPPORTED); + + SSL_load_error_strings(); + SSLeay_add_ssl_algorithms(); + + ctx = SSL_CTX_new(SSLv23_client_method()); + + if (!ctx) + { + throw ModuleException("Error initializing SSL CTX"); + } + + if (IsFile(CERTFILE)) + { + if (!SSL_CTX_use_certificate_file(ctx, CERTFILE, SSL_FILETYPE_PEM)) + { + SSL_CTX_free(ctx); + throw ModuleException("Error loading certificate"); + } + } + else + { + Alog() << "m_ssl: No certificate file found"; + } + + if (IsFile(KEYFILE)) + { + if (!SSL_CTX_use_PrivateKey_file(ctx, KEYFILE, SSL_FILETYPE_PEM)) + { + SSL_CTX_free(ctx); + throw ModuleException("Error loading private key"); + } + } + else + { + if (IsFile(CERTFILE)) + { + SSL_CTX_free(ctx); + throw ModuleException("Error loading private key - file not found"); + } + else + { + Alog() << "m_ssl: No private key found"; + } + } + + SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2); + SSL_CTX_set_options(ctx, SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_ALL); +// SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, always_accept_verify_cb); + + ModuleManager::Attach(I_OnPreServerConnect, this); + } + + ~SSLModule() + { + SSL_CTX_free(ctx); + } + + EventReturn OnPreServerConnect() + { + int servernum = 1; + for (std::list::iterator curr_uplink = Config.Uplinks.begin(); curr_uplink != Config.Uplinks.end(); ++curr_uplink, ++servernum) + { + uplink_server = *curr_uplink; + + try + { + new SSLSocket(uplink_server->host, uplink_server->port, Config.LocalHost ? Config.LocalHost : "", uplink_server->ipv6); + } + catch (SocketException& ex) + { + Alog() << "Unable to connect to server" << servernum << " (" << uplink_server->host << ":" << uplink_server->port << "), " << ex.GetReason(); + continue; + } + + Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")"; + return EVENT_ALLOW; + } + + return EVENT_STOP; + } +}; + +MODULE_INIT(SSLModule) -- cgit From b775c84402c309ccf4bced359ee714fbedb4dd6e Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 May 2010 15:51:54 -0400 Subject: Fixed the Makefiles to build m_ssl correctly and marked m_ssl as permanent --- src/modules/Makefile | 4 ++-- src/modules/ssl/m_ssl.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/Makefile b/src/modules/Makefile index 3ab2a7803..64b9373c7 100644 --- a/src/modules/Makefile +++ b/src/modules/Makefile @@ -29,12 +29,12 @@ distclean: spotless .c.so: $(MAKEBIN) $(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} \ - $(if $(shell grep RequiredLibraries $< | grep mysqlpp), $(MYSQL_ARGS)) \ + $(if $(shell grep RequiredLibraries $< | grep mysqlpp), $(MYSQL_ARGS)) $(if $(shell grep RequiredLibraries $< | grep ssl), -lssl) $(if $(shell grep RequiredLibraries $< | grep crypt), -lcrypt) \ -I../${INCLUDEDIR} -o $@ $< .cpp.so: $(MAKEBIN) $(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} \ - $(if $(shell grep RequiredLibraries $< | grep mysqlpp), $(MYSQL_ARGS)) \ + $(if $(shell grep RequiredLibraries $< | grep mysqlpp), $(MYSQL_ARGS)) $(if $(shell grep RequiredLibraries $< | grep ssl), -lssl) $(if $(shell grep RequiredLibraries $< | grep crypt), -lcrypt) \ -I../${INCLUDEDIR} -o $@ $< subs: diff --git a/src/modules/ssl/m_ssl.cpp b/src/modules/ssl/m_ssl.cpp index 8036de6ce..075352551 100644 --- a/src/modules/ssl/m_ssl.cpp +++ b/src/modules/ssl/m_ssl.cpp @@ -65,6 +65,7 @@ class SSLModule : public Module this->SetAuthor("Anope"); this->SetVersion("$Id$"); this->SetType(SUPPORTED); + this->SetPermanent(true); SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); @@ -112,7 +113,6 @@ class SSLModule : public Module SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2); SSL_CTX_set_options(ctx, SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_ALL); -// SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, always_accept_verify_cb); ModuleManager::Attach(I_OnPreServerConnect, this); } -- cgit From af805e5b45f75dec7f4ce16ffc322c8880f9859c Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 May 2010 21:04:18 -0400 Subject: Allow enabling ssl on a per-uplink basis --- src/modules/ssl/m_ssl.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/modules') diff --git a/src/modules/ssl/m_ssl.cpp b/src/modules/ssl/m_ssl.cpp index 075352551..be3e5da1f 100644 --- a/src/modules/ssl/m_ssl.cpp +++ b/src/modules/ssl/m_ssl.cpp @@ -122,28 +122,26 @@ class SSLModule : public Module SSL_CTX_free(ctx); } - EventReturn OnPreServerConnect() + EventReturn OnPreServerConnect(Uplink *u, int Number) { - int servernum = 1; - for (std::list::iterator curr_uplink = Config.Uplinks.begin(); curr_uplink != Config.Uplinks.end(); ++curr_uplink, ++servernum) - { - uplink_server = *curr_uplink; + ConfigReader config; + if (config.ReadFlag("uplink", "ssl", "no", Number - 1)) + { try { - new SSLSocket(uplink_server->host, uplink_server->port, Config.LocalHost ? Config.LocalHost : "", uplink_server->ipv6); + new SSLSocket(u->host, u->port, Config.LocalHost ? Config.LocalHost : "", u->ipv6); + Alog() << "Connected to Server " << Number << " (" << u->host << ":" << u->port << ")"; } catch (SocketException& ex) { - Alog() << "Unable to connect to server" << servernum << " (" << uplink_server->host << ":" << uplink_server->port << "), " << ex.GetReason(); - continue; + Alog() << "Unable to connect with SSL to server" << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason(); } - Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")"; return EVENT_ALLOW; } - return EVENT_STOP; + return EVENT_CONTINUE; } }; -- cgit From 631d11d6a81e8c5f63a19fc279606a61ab1a0563 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 10 May 2010 17:55:23 -0400 Subject: Store a plaintext version of mode names in the mode structures, removes alot of unneeded code from db_plain/db_mysql. --- src/modules/mysql/db_mysql.h | 46 +------------ src/modules/mysql/db_mysql_execute.cpp | 10 ++- src/modules/mysql/db_mysql_read.cpp | 43 ++++++++---- src/modules/mysql/db_mysql_write.cpp | 118 ++++++++++++++++++--------------- 4 files changed, 98 insertions(+), 119 deletions(-) (limited to 'src/modules') diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h index b62f52524..12956262a 100644 --- a/src/modules/mysql/db_mysql.h +++ b/src/modules/mysql/db_mysql.h @@ -39,48 +39,6 @@ NickCoreFlagInfo NickCoreFlags[] = { {"", static_cast(-1)} }; -struct ChannelModeInfo -{ - std::string Name; - ChannelModeName Mode; -}; - -ChannelModeInfo ChannelModes[] = { - {"CMODE_BLOCKCOLOR", CMODE_BLOCKCOLOR}, - {"CMODE_FLOOD", CMODE_FLOOD}, - {"CMODE_INVITE", CMODE_INVITE}, - {"CMODE_KEY", CMODE_KEY}, - {"CMODE_LIMIT", CMODE_LIMIT}, - {"CMODE_MODERATED", CMODE_MODERATED}, - {"CMODE_NOEXTERNAL", CMODE_NOEXTERNAL}, - {"CMODE_PRIVATE", CMODE_PRIVATE}, - {"CMODE_REGISTERED", CMODE_REGISTERED}, - {"CMODE_SECRET", CMODE_SECRET}, - {"CMODE_TOPIC", CMODE_TOPIC}, - {"CMODE_AUDITORIUM", CMODE_AUDITORIUM}, - {"CMODE_SSL", CMODE_SSL}, - {"CMODE_ADMINONLY", CMODE_ADMINONLY}, - {"CMODE_NOCTCP", CMODE_NOCTCP}, - {"CMODE_FILTER", CMODE_FILTER}, - {"CMODE_NOKNOCK", CMODE_NOKNOCK}, - {"CMODE_REDIRECT", CMODE_REDIRECT}, - {"CMODE_REGMODERATED", CMODE_REGMODERATED}, - {"CMODE_NONICK", CMODE_NONICK}, - {"CMODE_OPERONLY", CMODE_OPERONLY}, - {"CMODE_NONICK", CMODE_NONICK}, - {"CMODE_REGISTEREDONLY", CMODE_REGISTEREDONLY}, - {"CMODE_STRIPCOLOR", CMODE_STRIPCOLOR}, - {"CMODE_NONOTICE", CMODE_NONOTICE}, - {"CMODE_NOINVITE", CMODE_NOINVITE}, - {"CMODE_ALLINVITE", CMODE_ALLINVITE}, - {"CMODE_BLOCKCAPS", CMODE_BLOCKCAPS}, - {"CMODE_PERM", CMODE_PERM}, - {"CMODE_NICKFLOOD", CMODE_NICKFLOOD}, - {"CMODE_JOINFLOOD", CMODE_JOINFLOOD}, - {"CMODE_NOREJOIN", CMODE_NOREJOIN}, - {"", static_cast(-1)} -}; - struct BotFlagInfo { std::string Name; @@ -169,7 +127,7 @@ MemoFlagInfo MemoFlags[] = { inline std::string SQLAssign(const mysqlpp::String& s) { return s.c_str(); } class DBMySQL; -static DBMySQL *Me; +static DBMySQL *me; bool ExecuteQuery(mysqlpp::Query& query) { @@ -226,7 +184,7 @@ class DBMySQL : public Module DBMySQL(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Me = this; + me = this; this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 0c7c4de65..3933d54d1 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -37,7 +37,7 @@ class FakeUser : public User this->realname = sstrdup("Fake SQL User"); this->hostip = sstrdup("255.255.255.255"); this->vhost = NULL; - this->server = serv_uplink; // XXX Need a good way to set this to ourself + this->server = Me; if (this->prev) this->prev->next = this->next; @@ -50,8 +50,6 @@ class FakeUser : public User ~FakeUser() { - this->server = serv_uplink; // XXX Need a good way to set this to ourself - User **list = &userlist[HASH(this->nick.c_str())]; this->next = *list; if (*list) @@ -73,16 +71,16 @@ class FakeUser : public User class SQLTimer : public Timer { public: - SQLTimer() : Timer(Me->Delay, time(NULL), true) + SQLTimer() : Timer(me->Delay, time(NULL), true) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "TRUNCATE TABLE `anope_commands`"; ExecuteQuery(query); } void Tick(time_t) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); mysqlpp::StoreQueryResult qres; query << "SELECT * FROM `anope_commands`"; diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 5c498b008..728e4b882 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -27,7 +27,7 @@ static std::vector MakeVector(std::string buf) static void LoadDatabase() { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); mysqlpp::StoreQueryResult qres; query << "SELECT * FROM `anope_ns_core`"; @@ -270,12 +270,17 @@ static void LoadDatabase() spacesepstream sep(SQLAssign(qres[i]["mlock_on"])); while (sep.GetToken(buf)) { - for (int j = 0; ChannelModes[j].Mode != -1; ++j) + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) { - if (buf == ChannelModes[j].Name) + if ((*it)->Class == MC_CHANNEL) { - ci->SetMLock(ChannelModes[j].Mode, true); - break; + ChannelMode *cm = dynamic_cast(*it); + + if (buf == cm->NameAsString) + { + ci->SetMLock(cm->Name, true); + break; + } } } } @@ -286,12 +291,17 @@ static void LoadDatabase() spacesepstream sep(SQLAssign(qres[i]["mlock_off"])); while (sep.GetToken(buf)) { - for (int j = 0; ChannelModes[j].Mode != -1; ++j) + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) { - if (buf == ChannelModes[j].Name) + if ((*it)->Class == MC_CHANNEL) { - ci->SetMLock(ChannelModes[j].Mode, false); - break; + ChannelMode *cm = dynamic_cast(*it); + + if (buf == cm->NameAsString) + { + ci->SetMLock(cm->Name, false); + break; + } } } } @@ -302,13 +312,18 @@ static void LoadDatabase() spacesepstream sep(SQLAssign(qres[i]["mlock_params"])); while (sep.GetToken(buf)) { - for (int j = 0; ChannelModes[j].Mode != -1; ++j) + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) { - if (buf == ChannelModes[j].Name) + if ((*it)->Class == MC_CHANNEL) { - sep.GetToken(buf); - ci->SetMLock(ChannelModes[j].Mode, true, buf); - break; + ChannelMode *cm = dynamic_cast(*it); + + if (buf == cm->NameAsString) + { + sep.GetToken(buf); + ci->SetMLock(cm->Name, true, buf); + break; + } } } } diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index b7b94a3a3..5f3218381 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -2,8 +2,6 @@ #include "db_mysql.h" -static Module *me; - static std::string BuildFlagsList(ChannelInfo *ci) { std::string ret; @@ -80,11 +78,16 @@ static std::string MakeMLock(ChannelInfo *ci, bool status) { std::string ret; - for (int i = 0; ChannelModes[i].Mode != -1; ++i) + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) { - if (ci->HasMLock(ChannelModes[i].Mode, status)) + if ((*it)->Class == MC_CHANNEL) { - ret += " " + ChannelModes[i].Name; + ChannelMode *cm = dynamic_cast(*it); + + if (ci->HasMLock(cm->Name, status)) + { + ret += " " + cm->NameAsString; + } } } @@ -108,12 +111,17 @@ static std::string GetMLockParams(ChannelInfo *ci) { std::string ret; - for (int i = 0; ChannelModes[i].Mode != -1; ++i) + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) { - std::string param; - if (ci->GetParam(ChannelModes[i].Mode, param)) + if ((*it)->Class == MC_CHANNEL) { - ret += " " + ChannelModes[i].Name + " " + param; + ChannelMode *cm = dynamic_cast(*it); + + std::string param; + if (ci->GetParam(cm->Name, param)) + { + ret += " " + cm->NameAsString + " " + param; + } } } @@ -166,14 +174,14 @@ static BotInfo *CurBot = NULL; void Write(const std::string &data) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_extra` (data) VALUES(" << mysqlpp::quote << data << ")"; ExecuteQuery(query); } void WriteMetadata(const std::string &key, const std::string &data) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_metadata` (name, value) VALUES(" << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; ExecuteQuery(query); } @@ -183,7 +191,7 @@ void WriteNickMetadata(const std::string &key, const std::string &data) if (!CurNick) throw CoreException("WriteNickMetadata without a nick to write"); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_alias_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurNick->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; ExecuteQuery(query); } @@ -193,7 +201,7 @@ void WriteCoreMetadata(const std::string &key, const std::string &data) if (!CurCore) throw CoreException("WritCoreMetadata without a core to write"); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_core_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurCore->display << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; ExecuteQuery(query); } @@ -203,7 +211,7 @@ void WriteChannelMetadata(const std::string &key, const std::string &data) if (!CurChannel) throw CoreException("WriteChannelMetadata without a channel to write"); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_info_metadata` (channel, name, value) VALUES(" << mysqlpp::quote << CurChannel->name << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; ExecuteQuery(query); } @@ -213,14 +221,14 @@ void WriteBotMetadata(const std::string &key, const std::string &data) if (!CurBot) throw CoreException("WriteBotMetadata without a bot to write"); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_bs_info_metadata` (botname, name, value) VALUES(" << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; ExecuteQuery(query); } static void SaveDatabases() { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "TRUNCATE TABLE `anope_ns_core`"; ExecuteQuery(query); @@ -382,7 +390,7 @@ static void SaveDatabases() class CommandSyncSQL : public Command { public: - CommandSyncSQL(const std::string &cname) : Command(cname, 0, 0, "operserv/sqlsync") + CommandSyncSQL(const ci::string &cname) : Command(cname, 0, 0, "operserv/sqlsync") { } @@ -454,7 +462,7 @@ class DBMySQLWrite : public DBMySQL EventReturn OnSaveDatabase() { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "TRUNCATE TABLE `anope_os_core`"; ExecuteQuery(query); @@ -511,7 +519,7 @@ class DBMySQLWrite : public DBMySQL void OnPostCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (service == Config.s_NickServ) { @@ -685,28 +693,28 @@ class DBMySQLWrite : public DBMySQL void OnNickAddAccess(NickCore *nc, const std::string &entry) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << entry << ")"; ExecuteQuery(query); } void OnNickEraseAccess(NickCore *nc, const std::string &entry) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_ns_access` WHERE `display` = " << mysqlpp::quote << nc->display << " AND `access` = " << mysqlpp::quote << entry; ExecuteQuery(query); } void OnNickClearAccess(NickCore *nc) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_ns_access` WHERE `display` = " << mysqlpp::quote << nc->display; ExecuteQuery(query); } void OnDelCore(NickCore *nc) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_cs_access` WHERE `display` = " << mysqlpp::quote << nc->display; ExecuteQuery(query); query << "DELETE FROM `anope_cs_akick` WHERE `mask` = " << mysqlpp::quote << nc->display; @@ -724,7 +732,7 @@ class DBMySQLWrite : public DBMySQL void OnNickForbidden(NickAlias *na) { std::string flags = BuildFlagsList(na); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_ns_alias` SET `flags` = '" << (!flags.empty() ? flags : "") << "' WHERE `nick` = " << mysqlpp::quote << na->nick; ExecuteQuery(query); } @@ -736,7 +744,7 @@ class DBMySQLWrite : public DBMySQL void OnMakeNickRequest(NickRequest *nr) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_request` (nick, passcode, password, email, requested) VALUES(" << mysqlpp::quote << nr->nick << ", "; query << mysqlpp::quote << nr->passcode << ", " << mysqlpp::quote << nr->password << ", " << mysqlpp::quote << nr->email << ", '"; query << nr->requested << "')"; @@ -745,7 +753,7 @@ class DBMySQLWrite : public DBMySQL void OnDelNickRequest(NickRequest *nr) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_ns_request` WHERE `nick` = " << mysqlpp::quote << nr->nick; ExecuteQuery(query); } @@ -753,7 +761,7 @@ class DBMySQLWrite : public DBMySQL void OnNickRegister(NickAlias *na) { std::string flags = BuildFlagsList(na); - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_alias` (nick, last_quit, last_realname, last_usermask, time_registered, last_seen, flags, display) VALUES("; query << mysqlpp::quote << na->nick << ", " << mysqlpp::quote << (na->last_quit ? na->last_quit : "") << ", "; query << mysqlpp::quote << (na->last_realname ? na->last_realname : "") << ", "; @@ -776,7 +784,7 @@ class DBMySQLWrite : public DBMySQL void OnChangeCoreDisplay(NickCore *nc, const std::string &newdisplay) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_ns_core` SET `display` = " << mysqlpp::quote << newdisplay << " WHERE `display` = " << mysqlpp::quote << nc->display; ExecuteQuery(query); query << "UPDATE `anope_ns_alias` SET `display` = " << mysqlpp::quote << newdisplay << " WHERE `display` = " << mysqlpp::quote << nc->display; @@ -795,35 +803,35 @@ class DBMySQLWrite : public DBMySQL void OnNickSuspend(NickAlias *na) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_ns_core` SET `flags` = '" << BuildFlagsList(na->nc) << "' WHERE `display` = " << mysqlpp::quote << na->nc->display; ExecuteQuery(query); } void OnAccessAdd(ChannelInfo *ci, User *u, NickAlias *na, int level) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ")"; ExecuteQuery(query); } void OnAccessDel(ChannelInfo *ci, User *u, NickCore *nc) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_cs_access` WHERE `display` = " << mysqlpp::quote << nc->display << " AND `channel` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); } void OnAccessChange(ChannelInfo *ci, User *u, NickAlias *na, int level) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ") ON DUPLICATE KEY UPDATE level=VALUES(level), display=VALUES(display), channel=VALUES(channel), last_seen=VALUES(last_seen), creator=VALUES(creator)"; ExecuteQuery(query); } void OnAccessClear(ChannelInfo *ci, User *u) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_cs_access` WHERE `channel` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); } @@ -849,7 +857,7 @@ class DBMySQLWrite : public DBMySQL void OnChanForbidden(ChannelInfo *ci) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_info` (name, time_registered, last_used, flags, forbidby, forbidreason) VALUES ("; query << mysqlpp::quote << ci->name << ", " << ci->time_registered << ", " << ci->last_used << ", '" << BuildFlagsList(ci) << "', " << mysqlpp::quote << ci->forbidby << ", " << mysqlpp::quote << ci->forbidreason << ")"; ExecuteQuery(query); @@ -857,7 +865,7 @@ class DBMySQLWrite : public DBMySQL void OnDelChan(ChannelInfo *ci) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_cs_access` WHERE `channel` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); query << "DELETE FROM `anope_cs_akick` WHERE `channel` = " << mysqlpp::quote << ci->name; @@ -874,7 +882,7 @@ class DBMySQLWrite : public DBMySQL void OnChanRegistered(ChannelInfo *ci) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); std::string flags = BuildFlagsList(ci), mlockon = GetMLockOn(ci), mlockoff = GetMLockOff(ci), mlockparams = GetMLockParams(ci); query << "INSERT DELAYED INTO `anope_cs_info` (name, founder, successor, descr, url, email, time_registered, last_used, last_topic, last_topic_setter, last_topic_time, flags, forbidby, forbidreason, bantype, mlock_on, mlock_off, mlock_params, entry_message, memomax, botnick, botflags, capsmin, capspercent, floodlines, floodsecs, repeattimes) VALUES("; query << mysqlpp::quote << ci->name << ", " << mysqlpp::quote << (ci->founder ? ci->founder->display : "") << ", "; @@ -895,7 +903,7 @@ class DBMySQLWrite : public DBMySQL void OnChanSuspend(ChannelInfo *ci) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_cs_info` SET `flags` = '" << BuildFlagsList(ci) << "' WHERE `name` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); query << "UPDATE `anope_cs_info` SET `forbidby` = " << mysqlpp::quote << ci->forbidby << " WHERE `name` = " << mysqlpp::quote << ci->name; @@ -906,7 +914,7 @@ class DBMySQLWrite : public DBMySQL void OnAkickAdd(ChannelInfo *ci, AutoKick *ak) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_akick` (channel, flags, mask, reason, creator, created, last_used) VALUES("; query << mysqlpp::quote << ci->name << ", '"; if (ak->HasFlag(AK_ISNICK)) @@ -921,14 +929,14 @@ class DBMySQLWrite : public DBMySQL void OnAkickDel(ChannelInfo *ci, AutoKick *ak) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_cs_akick` WHERE `channel`= " << mysqlpp::quote << ci->name << " AND `mask` = " << mysqlpp::quote << (ak->HasFlag(AK_ISNICK) ? ak->nc->display : ak->mask); ExecuteQuery(query); } void OnBotCreate(BotInfo *bi) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES("; query << mysqlpp::quote << bi->nick << ", " << mysqlpp::quote << bi->user << ", " << mysqlpp::quote << bi->host << ", "; query << mysqlpp::quote << bi->real << ", '" << GetBotServFlags(bi) << "', " << bi->created << ", " << bi->chancount << ") "; @@ -943,7 +951,7 @@ class DBMySQLWrite : public DBMySQL void OnBotDelete(BotInfo *bi) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_bs_core` WHERE `nick` = " << mysqlpp::quote << bi->nick; ExecuteQuery(query); query << "UPDATE `anope_cs_info` SET `botnick` = '' WHERE `botnick` = " << mysqlpp::quote << bi->nick; @@ -952,7 +960,7 @@ class DBMySQLWrite : public DBMySQL EventReturn OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_cs_info` SET `botnick` = " << mysqlpp::quote << bi->nick << " WHERE `name` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); return EVENT_CONTINUE; @@ -960,7 +968,7 @@ class DBMySQLWrite : public DBMySQL EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "UPDATE `anope_cs_info` SET `botnick` = '' WHERE `name` = " << mysqlpp::quote << ci->name; ExecuteQuery(query); return EVENT_CONTINUE; @@ -968,7 +976,7 @@ class DBMySQLWrite : public DBMySQL void OnBadWordAdd(ChannelInfo *ci, BadWord *bw) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_bs_badwords` (channel, word, type) VALUES(" << mysqlpp::quote << ci->name << ", " << mysqlpp::quote << bw->word << ", '"; switch (bw->type) { @@ -990,7 +998,7 @@ class DBMySQLWrite : public DBMySQL void OnBadWordDel(ChannelInfo *ci, BadWord *bw) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_bs_badwords` WHERE `channel` = " << mysqlpp::quote << ci->name << " AND `word` = " << mysqlpp::quote << bw->word << " AND `type` = '"; switch (bw->type) { @@ -1012,7 +1020,7 @@ class DBMySQLWrite : public DBMySQL void OnMemoSend(User *, NickCore *nc, Memo *m) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ms_info` (receiver, number, flags, time, sender, text, serv) VALUES("; query << mysqlpp::quote << nc->display << ", " << m->number << ", '" << BuildFlagsList(m) << "', " << m->time << ", "; query << mysqlpp::quote << m->sender << ", " << mysqlpp::quote << m->text << ", 'NICK')"; @@ -1021,7 +1029,7 @@ class DBMySQLWrite : public DBMySQL void OnMemoSend(User *, ChannelInfo *ci, Memo *m) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ms_info` (receiver, number, flags, time, sender, text, serv) VALUES("; query << mysqlpp::quote << ci->name << ", " << m->number << ", '" << BuildFlagsList(m) << "', " << m->time << ", "; query << mysqlpp::quote << m->sender << ", " << mysqlpp::quote << m->text << ", 'CHAN')"; @@ -1030,7 +1038,7 @@ class DBMySQLWrite : public DBMySQL void OnMemoDel(NickCore *nc, MemoInfo *mi, int number) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (number) query << "DELETE FROM `anope_ms_info` WHERE `receiver` = " << mysqlpp::quote << nc->display << " AND `number` = " << number; else @@ -1040,7 +1048,7 @@ class DBMySQLWrite : public DBMySQL void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, int number) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (number) query << "DELETE FROM `anope_ms_info` WHERE `receiver` = " << mysqlpp::quote << ci->name << " AND `number` = " << number; else @@ -1050,7 +1058,7 @@ class DBMySQLWrite : public DBMySQL EventReturn OnAddAkill(User *, Akill *ak) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_os_akills` (user, host, xby, reason, seton, expire) VALUES("; query << mysqlpp::quote << ak->user << ", " << mysqlpp::quote << ak->host << ", " << mysqlpp::quote << ak->by; query << ", " << mysqlpp::quote << ak->reason << ", " << ak->seton << ", " << ak->expires << ")"; @@ -1060,7 +1068,7 @@ class DBMySQLWrite : public DBMySQL void OnDelAkill(User *, Akill *ak) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (ak) query << "DELETE FROM `anope_os_akills` WHERE `host` = " << mysqlpp::quote << ak->host; else @@ -1070,7 +1078,7 @@ class DBMySQLWrite : public DBMySQL EventReturn OnExceptionAdd(User *, Exception *ex) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_os_exceptions` (mask, slimit, who, reason, time, expires) VALUES("; query << mysqlpp::quote << ex->mask << ", " << ex->limit << ", " << mysqlpp::quote << ex->who << ", "; query << mysqlpp::quote << ex->reason << ", " << ex->time << ", " << ex->expires << ")"; @@ -1080,14 +1088,14 @@ class DBMySQLWrite : public DBMySQL void OnExceptionDel(User *, Exception *ex) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_os_exceptions` WHERE `mask` = " << mysqlpp::quote << ex->mask; ExecuteQuery(query); } EventReturn OnAddSXLine(User *, SXLine *sx, SXLineType Type) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_os_sxlines` (type, mask, xby, reason, seton, expire) VALUES('"; query << (Type == SX_SGLINE ? "SGLINE" : (Type == SX_SQLINE ? "SQLINE" : "SZLINE")) << "', "; query << mysqlpp::quote << sx->mask << ", " << mysqlpp::quote << sx->by << ", " << mysqlpp::quote << sx->reason; @@ -1098,7 +1106,7 @@ class DBMySQLWrite : public DBMySQL void OnDelSXLine(User *, SXLine *sx, SXLineType Type) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (sx) { query << "DELETE FROM `anope_os_sxlines` WHERE `mask` = " << mysqlpp::quote << sx->mask << " AND `type` = '"; -- cgit From f049124905bd9f53439293e873003cb027a17b91 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 14 May 2010 20:35:38 -0400 Subject: Rewrote the hashing system to use std::tr1::unordered_map --- src/modules/cs_appendtopic.c | 2 +- src/modules/cs_enforce.c | 2 +- src/modules/cs_tban.c | 2 +- src/modules/hs_request.c | 10 +- src/modules/mysql/db_mysql.h | 7 -- src/modules/mysql/db_mysql_execute.cpp | 25 ++--- src/modules/mysql/db_mysql_read.cpp | 8 +- src/modules/mysql/db_mysql_write.cpp | 174 ++++++++++++++------------------- src/modules/ns_maxemail.c | 13 +-- src/modules/os_info.c | 27 ++--- 10 files changed, 109 insertions(+), 161 deletions(-) (limited to 'src/modules') diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c index 22848b74a..311ac0717 100644 --- a/src/modules/cs_appendtopic.c +++ b/src/modules/cs_appendtopic.c @@ -141,7 +141,7 @@ class CSAppendTopic : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(CHANSERV, new CommandCSAppendTopic()); + this->AddCommand(ChanServ, new CommandCSAppendTopic()); /* English (US) */ const char* langtable_en_us[] = { diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c index 435f07d79..906e42ea6 100644 --- a/src/modules/cs_enforce.c +++ b/src/modules/cs_enforce.c @@ -229,7 +229,7 @@ class CSEnforce : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(CHANSERV, new CommandCSEnforce()); + this->AddCommand(ChanServ, new CommandCSEnforce()); /* English (US) */ const char* langtable_en_us[] = { diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 12fe8cd65..710840d52 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -92,7 +92,7 @@ class CSTBan : public Module { me = this; - this->AddCommand(CHANSERV, new CommandCSTBan()); + this->AddCommand(ChanServ, new CommandCSTBan()); this->SetAuthor(AUTHOR); this->SetVersion(VERSION); diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index 0113817b7..385dfc8c5 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -378,10 +378,10 @@ class HSRequest : public Module { me = this; - this->AddCommand(HOSTSERV, new CommandHSRequest()); - this->AddCommand(HOSTSERV, new CommandHSActivate()); - this->AddCommand(HOSTSERV, new CommandHSReject()); - this->AddCommand(HOSTSERV, new CommandHSWaiting()); + this->AddCommand(HostServ, new CommandHSRequest()); + this->AddCommand(HostServ, new CommandHSActivate()); + this->AddCommand(HostServ, new CommandHSReject()); + this->AddCommand(HostServ, new CommandHSWaiting()); this->SetAuthor(AUTHOR); this->SetVersion(VERSION); @@ -670,7 +670,7 @@ class HSRequest : public Module if (!key.empty() && key == "+req") { std::vector emptyParams; - Command *c = findCommand(HOSTSERV, "WAITING"); + Command *c = FindCommand(HostServ, "WAITING"); c->Execute(u, emptyParams); return EVENT_STOP; } diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h index 12956262a..f2885408f 100644 --- a/src/modules/mysql/db_mysql.h +++ b/src/modules/mysql/db_mysql.h @@ -98,13 +98,6 @@ struct BotServFlagInfo BotServFlagInfo BotServFlags[] = { {"PRIVATE", BI_PRIVATE}, - {"CHANSERV", BI_CHANSERV}, - {"BOTSERV", BI_BOTSERV}, - {"HOSTSERV", BI_HOSTSERV}, - {"OPERSERV", BI_OPERSERV}, - {"MEMOSERV", BI_MEMOSERV}, - {"NICKSERV", BI_NICKSERV}, - {"GLOBAL", BI_GLOBAL}, {"", static_cast(-1)} }; diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp index 3933d54d1..356f7c0f2 100644 --- a/src/modules/mysql/db_mysql_execute.cpp +++ b/src/modules/mysql/db_mysql_execute.cpp @@ -8,17 +8,12 @@ class FakeNickCore : public NickCore public: FakeNickCore() : NickCore("-SQLUser") { - if (this->next) - this->next->prev = this->prev; - if (this->prev) - this->prev->next = this->next; - else - nclists[HASH(this->display)] = this->next; + NickCoreList.erase(this->display); } ~FakeNickCore() { - insert_core(this); + NickCoreList[this->display] = this; Users.clear(); } @@ -39,23 +34,15 @@ class FakeUser : public User this->vhost = NULL; this->server = Me; - if (this->prev) - this->prev->next = this->next; - else - userlist[HASH(this->nick.c_str())] = this->next; - if (this->next) - this->next->prev = this->prev; + UserListByNick.erase("-SQLUser"); --usercnt; } ~FakeUser() { - User **list = &userlist[HASH(this->nick.c_str())]; - this->next = *list; - if (*list) - (*list)->prev = this; - *list = this; + UserListByNick["-SQLUser"] = this; ++usercnt; + nc = NULL; } @@ -145,7 +132,7 @@ class SQLTimer : public Timer // XXX this whole strtok thing needs to die char *cmdbuf = sstrdup(qres[i]["command"].c_str()); char *cmd = strtok(cmdbuf, " "); - mod_run_cmd(bi->nick, u, bi->cmdTable, cmd); + mod_run_cmd(bi, u, cmd); delete [] cmdbuf; if (logout) diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 728e4b882..79e59c9eb 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -166,7 +166,13 @@ static void LoadDatabase() { for (size_t i = 0; i < qres.num_rows(); ++i) { - BotInfo *bi = new BotInfo(SQLAssign(qres[i]["nick"]), SQLAssign(qres[i]["user"]), SQLAssign(qres[i]["host"]), SQLAssign(qres[i]["rname"])); + BotInfo *bi = findbot(SQLAssign(qres[i]["nick"])); + if (!bi) + bi = new BotInfo(SQLAssign(qres[i]["nick"])); + bi->user = SQLAssign(qres[i]["user"]); + bi->host = SQLAssign(qres[i]["host"]); + bi->real = SQLAssign(qres[i]["rname"]); + if (qres[i]["flags"].size()) { spacesepstream sep(SQLAssign(qres[i]["flags"])); diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index 5f3218381..2f7a42bb3 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -230,51 +230,47 @@ static void SaveDatabases() { mysqlpp::Query query(me->Con); - query << "TRUNCATE TABLE `anope_ns_core`"; - ExecuteQuery(query); query << "TRUNCATE TABLE `anope_ns_alias`"; ExecuteQuery(query); - for (int i = 0; i < 1024; ++i) + for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - for (NickAlias *na = nalists[i]; na; na = na->next) - { - me->OnNickRegister(na); - } + NickAlias *na = it->second; + + me->OnNickRegister(na); } - query << "TRUNCATE TABLE `anope_ns_access`"; + query << "TRUNCATE TABLE `anope_ns_core`"; ExecuteQuery(query); query << "TRUNCATE TABLE `anope_ms_info`"; ExecuteQuery(query); - - for (int i = 0; i < 1024; ++i) + + for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit) { - for (NickCore *nc = nclists[i]; nc; nc = nc->next) + NickCore *nc = nit->second; + + for (std::vector::iterator it = nc->access.begin(); it != nc->access.end(); ++it) { - for (std::vector::iterator it = nc->access.begin(); it != nc->access.end(); ++it) - { - query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")"; - ExecuteQuery(query); - } + query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < nc->memos.memos.size(); ++j) - { - Memo *m = nc->memos.memos[j]; + for (unsigned j = 0; j < nc->memos.memos.size(); ++j) + { + Memo *m = nc->memos.memos[j]; - me->OnMemoSend(NULL, nc, m); - } + me->OnMemoSend(NULL, nc, m); } } + query << "TRUNCATE TABLE `anope_bs_core`"; ExecuteQuery(query); - for (int i = 0; i < 256; ++i) + + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) { - for (BotInfo *bi = botlists[i]; bi; bi = bi->next) - { - me->OnBotCreate(bi); - } + BotInfo *bi = it->second; + me->OnBotCreate(bi); } query << "TRUNCATE TABLE `anope_cs_info`"; @@ -288,67 +284,54 @@ static void SaveDatabases() query << "TRUNCATE TABLE `anope_cs_levels`"; ExecuteQuery(query); - for (int i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next) - { - me->OnChanRegistered(ci); + ChannelInfo *ci = it->second; + + me->OnChanRegistered(ci); - for (unsigned j = 0; j < ci->GetBadWordCount(); ++j) - { - BadWord *bw = ci->GetBadWord(j); + for (unsigned j = 0; j < ci->GetBadWordCount(); ++j) + { + BadWord *bw = ci->GetBadWord(j); - if (bw->InUse) - { - me->OnBadWordAdd(ci, bw); - } - } + me->OnBadWordAdd(ci, bw); + } - for (unsigned j = 0; j < ci->GetAccessCount(); ++j) - { - ChanAccess *access = ci->GetAccess(j); + for (unsigned j = 0; j < ci->GetAccessCount(); ++j) + { + ChanAccess *access = ci->GetAccess(j); - if (access->in_use) - { - query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)"; - ExecuteQuery(query); - } - } + query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < ci->GetAkickCount(); ++j) - { - AutoKick *ak = ci->GetAkick(j); + for (unsigned j = 0; j < ci->GetAkickCount(); ++j) + { + AutoKick *ak = ci->GetAkick(j); - if (ak->InUse) - { - me->OnAkickAdd(ci, ak); - } - } + me->OnAkickAdd(ci, ak); + } - for (int k = 0; k < CA_SIZE; ++k) - { - query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)"; - ExecuteQuery(query); - } + for (int k = 0; k < CA_SIZE; ++k) + { + query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)"; + ExecuteQuery(query); + } - for (unsigned j = 0; j < ci->memos.memos.size(); ++j) - { - Memo *m = ci->memos.memos[j]; + for (unsigned j = 0; j < ci->memos.memos.size(); ++j) + { + Memo *m = ci->memos.memos[j]; - me->OnMemoSend(NULL, ci, m); - } + me->OnMemoSend(NULL, ci, m); } } query << "TRUNCATE TABLE `anope_ns_request`"; ExecuteQuery(query); - for (int i = 0; i < 1024; i++) + for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it) { - for (NickRequest *nr = nrlists[i]; nr; nr = nr->next) - { - me->OnMakeNickRequest(nr); - } + me->OnMakeNickRequest(it->second); } for (int i = 0; i < akills.count; ++i) @@ -418,7 +401,7 @@ class DBMySQLWrite : public DBMySQL ModuleManager::Attach(I_OnServerConnect, this); - this->AddCommand(OPERSERV, new CommandSyncSQL("SQLSYNC")); + this->AddCommand(OperServ, new CommandSyncSQL("SQLSYNC")); if (uplink_server) OnServerConnect(); @@ -470,46 +453,35 @@ class DBMySQLWrite : public DBMySQL query << maxusercnt << ", " << maxusertime << ", " << akills.count << ", " << sqlines.count << ", " << sglines.count << ", " << szlines.count << ")"; ExecuteQuery(query); - for (int i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - for (NickCore *nc = nclists[i]; nc; nc = nc->next) - { - CurCore = nc; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, nc)); - } + CurCore = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, CurCore)); } - for (int i = 0; i < 1024; ++i) + for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - for (NickAlias *na = nalists[i]; na; na = na->next) - { - CurNick = na; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, na)); - } + CurNick = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, CurNick)); } - for (int i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next) - { - CurChannel = ci; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, ci)); - } + CurChannel = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel)); } - for (int i = 0; i < 256; ++i) + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) { - for (BotInfo *bi = botlists[i]; bi; bi = bi->next) - { - CurBot = bi; - FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, bi)); - /* This is for the core bots, bots added by users are already handled by an event */ - query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES("; - query << mysqlpp::quote << bi->nick << ", " << mysqlpp::quote << bi->user << ", " << mysqlpp::quote << bi->host; - query << ", " << mysqlpp::quote << bi->real << ", '" << GetBotServFlags(bi) << "', " << bi->created << ", "; - query << bi->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)"; - ExecuteQuery(query); - } + CurBot = it->second; + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot)); + + /* This is for the core bots, bots added by users are already handled by an event */ + query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES("; + query << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << CurBot->user << ", " << mysqlpp::quote << CurBot->host; + query << ", " << mysqlpp::quote << CurBot->real << ", '" << GetBotServFlags(CurBot) << "', " << CurBot->created << ", "; + query << CurBot->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)"; + ExecuteQuery(query); } FOREACH_MOD(I_OnDatabaseWrite, OnDatabaseWrite(Write)); diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c index e98dc62d7..2399dba68 100644 --- a/src/modules/ns_maxemail.c +++ b/src/modules/ns_maxemail.c @@ -127,20 +127,17 @@ class NSMaxEmail : public Module int count_email_in_use(const char *email, User * u) { - NickCore *nc; - int i; int count = 0; if (!email) return 0; - for (i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - for (nc = nclists[i]; nc; nc = nc->next) - { - if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email)) - ++count; - } + NickCore *nc = it->second; + + if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email)) + ++count; } return count; diff --git a/src/modules/os_info.c b/src/modules/os_info.c index b486e32f6..a49fa8a88 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -193,8 +193,8 @@ class OSInfo : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - this->AddCommand(NICKSERV, new CommandNSOInfo()); - this->AddCommand(CHANSERV, new CommandCSOInfo()); + this->AddCommand(NickServ, new CommandNSOInfo()); + this->AddCommand(ChanServ, new CommandCSOInfo()); const char* langtable_en_us[] = { /* OINFO_SYNTAX */ @@ -415,27 +415,20 @@ class OSInfo : public Module ~OSInfo() { - int i; - NickCore *nc; - ChannelInfo *ci; - OnSaveDatabase(); - for (i = 0; i < 1024; ++i) + for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it) { - /* Remove the nick Cores */ - for (nc = nclists[i]; nc; nc = nc->next) - { - nc->Shrink("os_info"); - } + NickCore *nc = it->second; + + nc->Shrink("os_info"); } - for (i = 0; i < 256; ++i) + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) { - for (ci = chanlists[i]; ci; ci = ci->next) - { - ci->Shrink("os_info"); - } + ChannelInfo *ci = it->second; + + ci->Shrink("os_info"); } } -- cgit From 3a2c2a916a26f4fa1844e71a9f1c2fc25337fd2b Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 19 May 2010 16:59:16 -0400 Subject: Dont load mlock from the database until after Anope is connected, it doesnt know all of the available modes until then --- src/modules/mysql/db_mysql_read.cpp | 60 +++++++++--------------------------- src/modules/mysql/db_mysql_write.cpp | 4 +-- 2 files changed, 17 insertions(+), 47 deletions(-) (limited to 'src/modules') diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 79e59c9eb..1b4ce33fa 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -272,67 +272,37 @@ static void LoadDatabase() ci->bantype = atoi(qres[i]["bantype"].c_str()); if (qres[i]["mlock_on"].size()) { + std::vector modes; std::string buf; + spacesepstream sep(SQLAssign(qres[i]["mlock_on"])); while (sep.GetToken(buf)) - { - for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) - { - if ((*it)->Class == MC_CHANNEL) - { - ChannelMode *cm = dynamic_cast(*it); + modes.push_back(buf); - if (buf == cm->NameAsString) - { - ci->SetMLock(cm->Name, true); - break; - } - } - } - } + ci->Extend("db_mlock_modes_on", new ExtensibleItemRegular >(modes)); } if (qres[i]["mlock_off"].size()) { + std::vector modes; std::string buf; + spacesepstream sep(SQLAssign(qres[i]["mlock_off"])); while (sep.GetToken(buf)) - { - for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) - { - if ((*it)->Class == MC_CHANNEL) - { - ChannelMode *cm = dynamic_cast(*it); + modes.push_back(buf); - if (buf == cm->NameAsString) - { - ci->SetMLock(cm->Name, false); - break; - } - } - } - } + ci->Extend("db_mlock_modes_off", new ExtensibleItemRegular >(modes)); } if (qres[i]["mlock_params"].size()) { - std::string buf; + std::vector > mlp; + std::string buf, buf2; + spacesepstream sep(SQLAssign(qres[i]["mlock_params"])); - while (sep.GetToken(buf)) - { - for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) - { - if ((*it)->Class == MC_CHANNEL) - { - ChannelMode *cm = dynamic_cast(*it); - if (buf == cm->NameAsString) - { - sep.GetToken(buf); - ci->SetMLock(cm->Name, true, buf); - break; - } - } - } - } + while (sep.GetToken(buf) && sep.GetToken(buf2)) + mlp.push_back(std::make_pair(buf, buf2)); + + ci->Extend("db_mlp", new ExtensibleItemRegular > >(mlp)); } if (qres[i]["entry_message"].size()) ci->entry_message = sstrdup(qres[i]["entry_message"].c_str()); diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index 2f7a42bb3..1888195f3 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -309,7 +309,7 @@ static void SaveDatabases() { AutoKick *ak = ci->GetAkick(j); - me->OnAkickAdd(ci, ak); + me->OnAkickAdd(NULL, ci, ak); } for (int k = 0; k < CA_SIZE; ++k) @@ -810,7 +810,7 @@ class DBMySQLWrite : public DBMySQL void OnLevelChange(User *u, ChannelInfo *ci, int pos, int what) { - mysqlpp::Query query(Me->Con); + mysqlpp::Query query(me->Con); if (pos >= 0) { -- cgit From 2fba686904e6f78ebab35df171c5757afeebf05d Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2010 23:36:40 -0500 Subject: Burned slist, rewrote operservs XLine code --- src/modules/mysql/db_mysql_read.cpp | 57 +++++++++++++++----------- src/modules/mysql/db_mysql_write.cpp | 77 ++++++++++++++++++------------------ 2 files changed, 72 insertions(+), 62 deletions(-) (limited to 'src/modules') diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 1b4ce33fa..3c5fb359a 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -620,42 +620,51 @@ static void LoadDatabase() query << "SELECT * FROM `anope_os_akills`"; qres = StoreQuery(query); - if (qres) + if (qres && SGLine) { for (size_t i = 0; i < qres.size(); ++i) { - Akill *ak = new Akill; - ak->user = sstrdup(qres[i]["user"].c_str()); - ak->host = sstrdup(qres[i]["host"].c_str()); - ak->by = sstrdup(qres[i]["xby"].c_str()); - ak->reason = sstrdup(qres[i]["reason"].c_str()); - ak->seton = atol(qres[i]["seton"].c_str()); - ak->expires = atol(qres[i]["expire"].c_str()); - slist_add(&akills, ak); + ci::string user = qres[i]["user"].c_str(); + ci::string host = qres[i]["host"].c_str(); + ci::string by = qres[i]["xby"].c_str(); + std::string reason = SQLAssign(qres[i]["reason"]); + time_t seton = atol(qres[i]["seton"].c_str()); + time_t expires = atol(qres[i]["expire"].c_str()); + + XLine *x = SGLine->Add(NULL, NULL, user + "@" + host, expires, reason); + if (x) + { + x->By = by; + x->Created = seton; + } } } - query << "SELECT * FROM `anope_os_sxlines`"; + query << "SELECT * FROM `anope_os_xlines`"; qres = StoreQuery(query); if (qres) { for (size_t i = 0; i < qres.size(); ++i) { - SXLine *sx = new SXLine; - sx->mask = sstrdup(qres[i]["mask"].c_str()); - sx->by = sstrdup(qres[i]["xby"].c_str()); - sx->reason = sstrdup(qres[i]["reason"].c_str()); - sx->seton = atol(qres[i]["seton"].c_str()); - sx->expires = atol(qres[i]["expires"].c_str()); - if (qres[i]["type"] == "SGLINE") - slist_add(&sglines, sx); - else if (qres[i]["type"] == "SQLINE") - slist_add(&sqlines, sx); - else if (qres[i]["type"] == "SZLINE") - slist_add(&szlines, sx); - else - delete sx; + ci::string mask = qres[i]["mask"].c_str(); + ci::string by = qres[i]["xby"].c_str(); + std::string reason = SQLAssign(qres[i]["reason"]); + time_t seton = atol(qres[i]["seton"].c_str()); + time_t expires = atol(qres[i]["expires"].c_str()); + + XLine *x = NULL; + if (qres[i]["type"] == "SNLINE" && SNLine) + x = SNLine->Add(NULL, NULL, mask, expires, reason); + else if (qres[i]["type"] == "SQLINE" && SQLine) + x = SQLine->Add(NULL, NULL, mask, expires, reason); + else if (qres[i]["type"] == "SZLINE" && SZLine) + x = SZLine->Add(NULL, NULL,mask, expires, reason); + if (x) + { + x->By = by; + x->Created = seton; + } } } } diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index 1888195f3..427be43bd 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -235,9 +235,7 @@ static void SaveDatabases() for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - NickAlias *na = it->second; - - me->OnNickRegister(na); + me->OnNickRegister(it->second); } query << "TRUNCATE TABLE `anope_ns_core`"; @@ -269,8 +267,7 @@ static void SaveDatabases() for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) { - BotInfo *bi = it->second; - me->OnBotCreate(bi); + me->OnBotCreate(it->second); } query << "TRUNCATE TABLE `anope_cs_info`"; @@ -311,7 +308,7 @@ static void SaveDatabases() me->OnAkickAdd(NULL, ci, ak); } - + for (int k = 0; k < CA_SIZE; ++k) { query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)"; @@ -334,32 +331,36 @@ static void SaveDatabases() me->OnMakeNickRequest(it->second); } - for (int i = 0; i < akills.count; ++i) + if (SGLine) { - Akill *ak = static_cast(akills.list[i]); - - me->OnAddAkill(NULL, ak); + for (unsigned i = 0; i < SGLine->GetCount(); ++i) + { + me->OnAddAkill(NULL, SGLine->GetEntry(i)); + } } - for (int i = 0; i < sglines.count; ++i) + if (SZLine) { - SXLine *x = stat