From 2ba89de64d3b755f731f202dd97c48d256db8031 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 24 Apr 2010 16:30:49 -0400 Subject: Tell users when their nicks expire in /ns glist and /ns info --- src/core/ns_group.c | 14 ++++++-------- src/core/ns_info.c | 11 ++++------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src/core') diff --git a/src/core/ns_group.c b/src/core/ns_group.c index 2aa47ac1f..dab27af27 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -182,16 +182,14 @@ class CommandNSGList : public Command for (i = 0; i < nc->aliases.count; ++i) { NickAlias *na2 = static_cast(nc->aliases.list[i]); - if (na2->nc == nc) + + if (!(wont_expire = na2->HasFlag(NS_NO_EXPIRE))) { - if (!(wont_expire = na2->HasFlag(NS_NO_EXPIRE))) - { - expt = na2->last_seen + Config.NSExpire; - tm = localtime(&expt); - strftime_lang(buf, sizeof(buf), finduser(na2->nick), STRFTIME_DATE_TIME_FORMAT, tm); - } - notice_lang(Config.s_NickServ, u, u->Account()->IsServicesOper() && !wont_expire ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY, wont_expire ? '!' : ' ', na2->nick, buf); + expt = na2->last_seen + Config.NSExpire; + tm = localtime(&expt); + strftime_lang(buf, sizeof(buf), finduser(na2->nick), STRFTIME_DATE_TIME_FORMAT, tm); } + notice_lang(Config.s_NickServ, u, wont_expire ? NICK_GLIST_REPLY_NOEXPIRE : NICK_GLIST_REPLY, na2->nick, buf); } notice_lang(Config.s_NickServ, u, NICK_GLIST_FOOTER, nc->aliases.count); } diff --git a/src/core/ns_info.c b/src/core/ns_info.c index 0635e52df..421d33f97 100644 --- a/src/core/ns_info.c +++ b/src/core/ns_info.c @@ -171,13 +171,10 @@ class CommandNSInfo : public Command notice_lang(Config.s_NickServ, u, NICK_INFO_NO_EXPIRE); else { - if (u->Account()->IsServicesOper()) - { - expt = na->last_seen + Config.NSExpire; - tm = localtime(&expt); - strftime_lang(buf, sizeof(buf), finduser(na->nick), STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(Config.s_NickServ, u, NICK_INFO_EXPIRE, buf); - } + expt = na->last_seen + Config.NSExpire; + tm = localtime(&expt); + strftime_lang(buf, sizeof(buf), finduser(na->nick), STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(Config.s_NickServ, u, NICK_INFO_EXPIRE, buf); } } -- cgit 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/core/cs_ban.c | 2 +- src/core/cs_info.c | 4 ++-- src/core/cs_kick.c | 2 +- src/core/cs_xop.c | 2 +- src/core/ns_identify.c | 2 +- src/core/ns_info.c | 18 +++++++++--------- src/core/ns_register.c | 2 +- src/core/os_news.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/core') diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index d0bbbfbb4..bacc8dff8 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -17,7 +17,7 @@ class CommandCSBan : public Command { public: - CommandCSBan(const std::string &cname) : Command(cname, 2, 3) + CommandCSBan(const ci::string &cname) : Command(cname, 2, 3) { } diff --git a/src/core/cs_info.c b/src/core/cs_info.c index 60e8ebf50..9131d1a3a 100644 --- a/src/core/cs_info.c +++ b/src/core/cs_info.c @@ -43,7 +43,7 @@ class CommandCSInfo : public Command ChannelInfo *ci; char buf[BUFSIZE]; struct tm *tm; - bool has_auspex = u->Account() && u->Account()->HasPriv("chanserv/auspex"); + bool has_auspex = u->IsIdentified() && u->Account()->HasPriv("chanserv/auspex"); int show_all = 0; time_t expt; @@ -146,7 +146,7 @@ class CommandCSInfo : public Command bool OnHelp(User *u, const ci::string &subcommand) { notice_lang(Config.s_ChanServ, u, CHAN_HELP_INFO); - if (u->Account() && u->Account()->HasPriv("chanserv/auspex")) + if (u->IsIdentified() && u->Account()->HasPriv("chanserv/auspex")) notice_lang(Config.s_ChanServ, u, CHAN_SERVADMIN_HELP_INFO); return true; diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index bce32d401..9614c8cc3 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -17,7 +17,7 @@ class CommandCSKick : public Command { public: - CommandCSKick(const std::string& cname) : Command(cname, 2, 3) + CommandCSKick(const ci::string &cname) : Command(cname, 2, 3) { } diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 702919d8e..a6f980ad0 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -396,7 +396,7 @@ class XOPBase : public Command return MOD_CONT; } public: - XOPBase(const std::string &command) : Command(command, 2, 3) + XOPBase(const ci::string &command) : Command(command, 2, 3) { } diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index 866497fc0..b574c1207 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -17,7 +17,7 @@ class CommandNSIdentify : public Command { public: - CommandNSIdentify(const std::string &cname) : Command(cname, 1, 1) + CommandNSIdentify(const ci::string &cname) : Command(cname, 1, 1) { this->SetFlag(CFLAG_ALLOW_UNREGISTERED); } diff --git a/src/core/ns_info.c b/src/core/ns_info.c index 421d33f97..020745008 100644 --- a/src/core/ns_info.c +++ b/src/core/ns_info.c @@ -79,19 +79,19 @@ class CommandNSInfo : public Command { struct tm *tm; char buf[BUFSIZE]; - int nick_online = 0; - int show_hidden = 0; + bool nick_online = false, show_hidden = false; time_t expt; + bool has_auspex = u->IsIdentified() && u->Account()->HasPriv("nickserv/auspex"); /* Is the real owner of the nick we're looking up online? -TheShadow */ User *u2 = finduser(na->nick); if (u2 && u2->Account() == na->nc) - nick_online = 1; + nick_online = true; /* Only show hidden fields to owner and sadmins and only when the ALL * parameter is used. -TheShadow */ - if (!param.empty() && param == "ALL" && u->Account() && (na->nc == u->Account() || u->Account()->IsServicesOper())) - show_hidden = 1; + if (!param.empty() && param == "ALL" && u->Account() && (na->nc == u->Account() || has_auspex)) + show_hidden = true; notice_lang(Config.s_NickServ, u, NICK_INFO_REALNAME, na->nick, na->last_realname); @@ -100,7 +100,6 @@ class CommandNSInfo : public Command if (show_hidden || (!(na->nc->HasFlag(NI_HIDE_STATUS)))) { notice_lang(Config.s_NickServ, u, NICK_INFO_SERVICES_OPERTYPE, na->nick, na->nc->ot->GetName().c_str()); - } } @@ -111,7 +110,8 @@ class CommandNSInfo : public Command else notice_lang(Config.s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST, na->nick); } - else { + else + { if (show_hidden || !(na->nc->HasFlag(NI_HIDE_MASK))) notice_lang(Config.s_NickServ, u, NICK_INFO_ADDRESS, na->last_usermask); } @@ -178,7 +178,7 @@ class CommandNSInfo : public Command } } - if (!show_hidden && u->Account() && (na->nc == u->Account() || u->Account()->IsServicesOper())) + if (!show_hidden && u->Account() && (na->nc == u->Account() || has_auspex)) notice_lang(Config.s_NickServ, u, NICK_INFO_FOR_MORE, Config.s_NickServ, na->nick); } return MOD_CONT; @@ -187,7 +187,7 @@ class CommandNSInfo : public Command bool OnHelp(User *u, const ci::string &subcommand) { notice_help(Config.s_NickServ, u, NICK_HELP_INFO); - if (u->Account() && u->Account()->IsServicesOper()) + if (u->IsIdentified() && u->Account()->HasPriv("nickserv/auspex")) notice_help(Config.s_NickServ, u, NICK_SERVADMIN_HELP_INFO); return true; diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 4a9bfb6fe..9074f109f 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -143,7 +143,7 @@ class CommandNSConfirm : public Command } public: - CommandNSConfirm(const std::string &cmdn, int min, int max) : Command(cmdn, min, max) + CommandNSConfirm(const ci::string &cmdn, int min, int max) : Command(cmdn, min, max) { this->SetFlag(CFLAG_ALLOW_UNREGISTERED); } diff --git a/src/core/os_news.c b/src/core/os_news.c index 9daf1b443..e39db8011 100644 --- a/src/core/os_news.c +++ b/src/core/os_news.c @@ -300,7 +300,7 @@ class NewsBase : public Command return MOD_CONT; } public: - NewsBase(const std::string &newstype) : Command(newstype, 1, 2, "operserv/news") + NewsBase(const ci::string &newstype) : Command(newstype, 1, 2, "operserv/news") { } -- cgit From c1d161dec451ea790ff87078b5d80b1f71a3e9f0 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Apr 2010 17:31:34 -0400 Subject: Rewrote all of the server handling code --- src/core/cs_modes.c | 2 +- src/core/cs_xop.c | 2 +- src/core/os_defcon.c | 6 ++---- src/core/os_jupe.c | 12 +++++++----- src/core/os_noop.c | 2 +- src/core/os_stats.c | 21 ++++++++++++--------- 6 files changed, 24 insertions(+), 21 deletions(-) (limited to 'src/core') diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 3df93d912..06e737eff 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -380,7 +380,7 @@ class CSModes : public Module this->AddCommand(CHANSERV, new CommandCSVoice()); this->AddCommand(CHANSERV, new CommandCSDeVoice()); - if (serv_uplink && is_sync(serv_uplink)) + if (Me && Me->IsSynced()) OnUplinkSync(); Implementation i[] = { diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index a6f980ad0..18ff222b1 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -544,7 +544,7 @@ class CSXOP : public Module this->AddCommand(CHANSERV, new CommandCSAOP()); this->AddCommand(CHANSERV, new CommandCSVOP()); - if (serv_uplink && is_sync(serv_uplink)) + if (Me && Me->IsSynced()) OnUplinkSync(); Implementation i[] = { diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c index 403ac1281..654ed89cc 100644 --- a/src/core/os_defcon.c +++ b/src/core/os_defcon.c @@ -156,13 +156,11 @@ class OSDEFCON : public Module EventReturn OnPreUserConnect(User *u) { - std::string mask; - - if (u && is_sync(u->server) && CheckDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(u->server->name)) + if (u->server->IsSynced() && CheckDefCon(DEFCON_AKILL_NEW_CLIENTS) && !u->server->IsULined()) { if (CheckDefCon(DEFCON_AKILL_NEW_CLIENTS)) { - mask = "*@" + std::string(u->host); + std::string mask = "*@" + std::string(u->host); Alog() << "DEFCON: adding akill for " << mask; add_akill(NULL, mask.c_str(), Config.s_OperServ, time(NULL) + Config.DefConAKILL, diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c index 9af3d3176..899dd4ea4 100644 --- a/src/core/os_jupe.c +++ b/src/core/os_jupe.c @@ -25,18 +25,20 @@ class CommandOSJupe : public Command { const char *jserver = params[0].c_str(); const char *reason = params.size() > 1 ? params[1].c_str() : NULL; - Server *server = findserver(servlist, jserver); + Server *server = Server::Find(jserver); if (!isValidHost(jserver, 3)) notice_lang(Config.s_OperServ, u, OPER_JUPE_HOST_ERROR); - else if (server && (server->HasFlag(SERVER_ISME) || server->HasFlag(SERVER_ISUPLINK))) + else if (server && (server == Me || server == Me->GetUplink())) notice_lang(Config.s_OperServ, u, OPER_JUPE_INVALID_SERVER); - else { + else + { char rbuf[256]; snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", u->nick.c_str(), reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) + if (server) ircdproto->SendSquit(jserver, rbuf); - Server *juped_server = new_server(me_server, jserver, rbuf, SERVER_JUPED, ircd->ts6 ? ts6_sid_retrieve() : ""); + Server *juped_server = new Server(Me, jserver, 0, rbuf, ircd->ts6 ? ts6_sid_retrieve() : ""); + juped_server->SetFlag(SERVER_JUPED); ircdproto->SendServer(juped_server); if (Config.WallOSJupe) diff --git a/src/core/os_noop.c b/src/core/os_noop.c index c0fc33161..eec054ea4 100644 --- a/src/core/os_noop.c +++ b/src/core/os_noop.c @@ -44,7 +44,7 @@ class CommandOSNOOP : public Command for (u2 = firstuser(); u2; u2 = u3) { u3 = nextuser(); - if (u2 && is_oper(u2) && u2->server->name && Anope::Match(u2->server->name, server, true)) + if (u2 && is_oper(u2) && Anope::Match(u2->server->GetName(), server, true)) kill_user(Config.s_OperServ, u2->nick.c_str(), reason.c_str()); } } diff --git a/src/core/os_stats.c b/src/core/os_stats.c index 711e1f646..9dae3474a 100644 --- a/src/core/os_stats.c +++ b/src/core/os_stats.c @@ -21,16 +21,19 @@ void get_operserv_stats(long *nrec, long *memuse); * @param s The server to start counting from * @return Amount of servers connected to server s **/ -int stats_count_servers(Server *s) +static int stats_count_servers(Server *s) { - int count = 0; + if (!s) + return 0; + + int count = 1; - while (s) + if (s->GetLinks()) { - ++count; - if (s->links) - count += stats_count_servers(s->links); - s = s->next; + for (std::list::const_iterator it = s->GetLinks()->begin(); it != s->GetLinks()->end(); ++it) + { + count += stats_count_servers(*it); + } } return count; @@ -214,9 +217,9 @@ class CommandOSStats : public Command if (!buf.empty()) buf.erase(buf.begin()); - notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name); + notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, Me->GetUplink()->GetName().c_str()); notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf.c_str()); - notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(serv_uplink)); + notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(Me->GetUplink())); return MOD_CONT; } -- 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/core/cs_ban.c | 4 ++-- src/core/cs_kick.c | 4 ++-- src/core/cs_modes.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index bacc8dff8..95c5c6556 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -62,9 +62,9 @@ class CommandCSBan : public Command */ } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && 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 { + else { char mask[BUFSIZE]; get_idealban(ci, u2, mask, sizeof(mask)); diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index 9614c8cc3..42059a01b 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -56,9 +56,9 @@ class CommandCSKick : public Command } else if (!is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (is_protected(u2)) { + } else if (u2->IsProtected()) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (!c->FindUser(u2)) { + else if (!c->FindUser(u2)) { notice_lang(Config.s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); } else { if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 06e737eff..788c1adac 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -49,7 +49,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (!set && !is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci))) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - else if (!set && is_protected(u2) && !is_same) + else if (!set && u2->IsProtected() && !is_same) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else if (!c->FindUser(u2)) notice_lang(Config.s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); -- 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/core/cs_info.c | 6 ++++-- src/core/ns_info.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/cs_info.c b/src/core/cs_info.c index 9131d1a3a..b3e7a1077 100644 --- a/src/core/cs_info.c +++ b/src/core/cs_info.c @@ -44,7 +44,7 @@ class CommandCSInfo : public Command char buf[BUFSIZE]; struct tm *tm; bool has_auspex = u->IsIdentified() && u->Account()->HasPriv("chanserv/auspex"); - int show_all = 0; + bool show_all = false; time_t expt; ci = cs_findchan(chan); @@ -64,7 +64,7 @@ class CommandCSInfo : public Command /* Should we show all fields? Only for sadmins and identified users */ if (!param.empty() && param == "ALL" && (check_access(u, ci, CA_INFO) || has_auspex)) - show_all = 1; + show_all = true; notice_lang(Config.s_ChanServ, u, CHAN_INFO_HEADER, chan); notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_FOUNDER, ci->founder->display); @@ -138,6 +138,8 @@ class CommandCSInfo : public Command notice_lang(Config.s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON))); } + FOREACH_MOD(I_OnChanInfo, OnChanInfo(u, ci, show_all)); + if (!show_all && (check_access(u, ci, CA_INFO) || has_auspex)) notice_lang(Config.s_ChanServ, u, NICK_INFO_FOR_MORE, Config.s_ChanServ, ci->name.c_str()); return MOD_CONT; diff --git a/src/core/ns_info.c b/src/core/ns_info.c index 020745008..976e3d458 100644 --- a/src/core/ns_info.c +++ b/src/core/ns_info.c @@ -178,6 +178,8 @@ class CommandNSInfo : public Command } } + FOREACH_MOD(I_OnNickInfo, OnNickInfo(u, na, show_hidden)); + if (!show_hidden && u->Account() && (na->nc == u->Account() || has_auspex)) notice_lang(Config.s_NickServ, u, NICK_INFO_FOR_MORE, Config.s_NickServ, na->nick); } -- 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/core/db_plain.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 65f936650..0ae6c47f8 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -556,8 +556,7 @@ class DBPlain : public Module void BackupDatabase() { /* Do not backup a database that doesn't exist */ - struct stat DBInfo; - if (stat(DatabaseFile.c_str(), &DBInfo)) + if (!IsFile(DatabaseFile)) { return; } -- cgit From 6db15e17834163975f6122d3913d260d8327d516 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 8 May 2010 15:49:08 -0400 Subject: Added the nickserv/ungroup command --- src/core/ns_group.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/ns_group.c b/src/core/ns_group.c index dab27af27..e74b69e2e 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -51,9 +51,7 @@ class CommandNSGroup : public Command { for (it = Config.Opers.begin(); it != Config.Opers.end(); ++it) { - std::string nick = it->first; - - if (stristr(u->nick.c_str(), nick.c_str()) && !is_oper(u)) + if (!is_oper(u) && u->nick.find(it->first) != std::string::npos) { notice_lang(Config.s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); return MOD_CONT; @@ -153,6 +151,67 @@ class CommandNSGroup : public Command } }; +class CommandNSUngroup : public Command +{ + public: + CommandNSUngroup() : Command("UNGROUP", 0, 1) + { + } + + CommandReturn Execute(User *u, const std::vector ¶ms) + { + const char *nick = params.size() ? params[0].c_str() : NULL; + NickAlias *na = nick ? findnick(nick) : findnick(u->nick); + + if (u->Account()->aliases.count == 1) + notice_lang(Config.s_NickServ, u, NICK_UNGROUP_ONE_NICK); + else if (!na) + notice_lang(Config.s_NickServ, u, NICK_X_NOT_REGISTERED, nick ? nick : u->nick.c_str()); + else if (na->nc != u->Account()) + notice_lang(Config.s_NickServ, u, NICK_UNGROUP_NOT_IN_GROUP, na->nick); + else + { + NickCore *oldcore = na->nc; + + slist_remove(&oldcore->aliases, na); + if (!stricmp(oldcore->display, na->nick)) + { + change_core_display(oldcore); + } + + na->nc = new NickCore(na->nick); + slist_add(&na->nc->aliases, na); + + na->nc->pass = oldcore->pass; + if (oldcore->email) + na->nc->email = sstrdup(oldcore->email); + if (oldcore->greet) + na->nc->greet = sstrdup(oldcore->greet); + na->nc->icq = oldcore->icq; + if (oldcore->url) + na->nc->url = sstrdup(oldcore->url); + na->nc->language = oldcore->language; + + notice_lang(Config.s_NickServ, u, NICK_UNGROUP_SUCCESSFUL, na->nick, oldcore->display); + + User *user = finduser(na->nick); + if (user) + { + /* The user on the nick who was ungrouped may be identified to the old group, set -r */ + user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED); + } + } + + return MOD_CONT; + } + + bool OnHelp(User *u, const ci::string &subcommand) + { + notice_help(Config.s_NickServ, u, NICK_HELP_UNGROUP); + return true; + } +}; + class CommandNSGList : public Command { public: @@ -218,13 +277,16 @@ class NSGroup : public Module this->SetType(CORE); this->AddCommand(NICKSERV, new CommandNSGroup()); + this->AddCommand(NICKSERV, new CommandNSUngroup()); this->AddCommand(NICKSERV, new CommandNSGList()); ModuleManager::Attach(I_OnNickServHelp, this); } + void OnNickServHelp(User *u) { notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_GROUP); + notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_UNGROUP); notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_GLIST); } }; -- cgit From 4e1286ca109d079f32d32f07c344a1ab93899032 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 May 2010 19:02:50 -0400 Subject: Rewrote the mail system to use threading --- src/core/ns_register.c | 40 +++++++------------------ src/core/ns_resetpass.c | 80 +++++++++++++++++++++++++------------------------ src/core/ns_sendpass.c | 43 +++++++++++--------------- 3 files changed, 70 insertions(+), 93 deletions(-) (limited to 'src/core') diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 9074f109f..89495eb57 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -14,7 +14,7 @@ #include "module.h" -int do_sendregmail(User *u, NickRequest *nr); +static bool SendRegmail(User *u, NickRequest *nr); class CommandNSConfirm : public Command { @@ -279,7 +279,7 @@ class CommandNSRegister : public CommandNSConfirm FOREACH_MOD(I_OnMakeNickRequest, OnMakeNickRequest(nr)); if (Config.NSEmailReg) { - if (!do_sendregmail(u, nr)) + if (SendRegmail(u, nr)) { notice_lang(Config.s_NickServ, u, NICK_ENTER_REG_CODE, email, Config.s_NickServ); Alog() << Config.s_NickServ << ": sent registration verification code to " << nr->email; @@ -337,7 +337,7 @@ class CommandNSResend : public Command notice_lang(Config.s_NickServ, u, MAIL_LATER); return MOD_CONT; } - if (!do_sendregmail(u, nr)) + if (!SendRegmail(u, nr)) { nr->lastmail = time(NULL); notice_lang(Config.s_NickServ, u, NICK_REG_RESENT, nr->email); @@ -375,6 +375,7 @@ class NSRegister : public Module ModuleManager::Attach(I_OnNickServHelp, this); } + void OnNickServHelp(User *u) { notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_REGISTER); @@ -386,33 +387,14 @@ class NSRegister : public Module } }; -/*************************************************************************/ - -int do_sendregmail(User *u, NickRequest *nr) +static bool SendRegmail(User *u, NickRequest *nr) { - MailInfo *mail = NULL; - char buf[BUFSIZE]; - - if (!nr && !u) - return -1; - snprintf(buf, sizeof(buf), getstring(NICK_REG_MAIL_SUBJECT), nr->nick); - mail = MailRegBegin(u, nr, buf, Config.s_NickServ); - if (!mail) - return -1; - fprintf(mail->pipe, "%s", getstring(NICK_REG_MAIL_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(NICK_REG_MAIL_LINE_1), nr->nick); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(NICK_REG_MAIL_LINE_2), Config.s_NickServ, nr->passcode.c_str()); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(NICK_REG_MAIL_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(NICK_REG_MAIL_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(NICK_REG_MAIL_LINE_5), Config.NetworkName); - fprintf(mail->pipe, "\n.\n"); - MailEnd(mail); - return 0; + char subject[BUFSIZE], message[BUFSIZE]; + + snprintf(subject, sizeof(subject), getstring(NICK_REG_MAIL_SUBJECT), nr->nick); + snprintf(message, sizeof(message), getstring(NICK_REG_MAIL), nr->nick, Config.NetworkName, Config.s_NickServ, nr->passcode.c_str(), Config.NetworkName); + + return Mail(u, nr, Config.s_NickServ, subject, message); } MODULE_INIT(NSRegister) diff --git a/src/core/ns_resetpass.c b/src/core/ns_resetpass.c index c47fa0308..fc904d66c 100644 --- a/src/core/ns_resetpass.c +++ b/src/core/ns_resetpass.c @@ -14,6 +14,8 @@ #include "module.h" +static bool SendResetEmail(User *u, NickAlias *na); + class CommandNSResetPass : public Command { public: @@ -33,41 +35,11 @@ class CommandNSResetPass : public Command notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick); else { - char buf[BUFSIZE], message[BUFSIZE]; - snprintf(buf, sizeof(buf), getstring(na, NICK_RESETPASS_SUBJECT), na->nick); - - MailInfo *mail = MailBegin(u, na->nc, buf, Config.s_NickServ); - if (!mail) - return MOD_CONT; - - char passcode[20]; - int min = 1, max = 62; - int chars[] = { - ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', - 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', - 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' - }; - - int idx; - for (idx = 0; idx < 20; ++idx) - passcode[idx] = chars[1 + static_cast((static_cast(max - min)) * getrandom16() / 65536.0) + min]; - passcode[idx] = '\0'; - - snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick, Config.s_NickServ, passcode, Config.NetworkName); - fprintf(mail->pipe, "%s", message); - fprintf(mail->pipe, "\n.\n"); - MailEnd(mail); - - na->nc->Shrink("ns_resetpass_code"); - na->nc->Shrink("ns_resetpass_time"); - - na->nc->Extend("ns_resetpass_code", new ExtensibleItemPointerArray(sstrdup(passcode))); - na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular(time(NULL))); - - Alog() << Config.s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")"; - notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick); + if (SendResetEmail(u, na)) + { + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")"; + notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick); + } } return MOD_CONT; @@ -110,14 +82,13 @@ class NSResetPass : public Module EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) { - time_t t; - char *c; - if (service == Config.s_NickServ && command == "CONFIRM" && !params.empty()) { NickAlias *na = findnick(u->nick); - if (na && na->nc->GetExtArray("ns_resetpass_code", c) && na->nc->GetExtRegular("ns_resetpass_time", t)) + time_t t; + std::string c; + if (na && na->nc->GetExtRegular("ns_resetpass_code", c) && na->nc->GetExtRegular("ns_resetpass_time", t)) { if (t < time(NULL) - 3600) { @@ -167,4 +138,35 @@ class NSResetPass : public Module } }; +static bool SendResetEmail(User *u, NickAlias *na) +{ + char subject[BUFSIZE], message[BUFSIZE], passcode[20]; + + snprintf(subject, sizeof(subject), getstring(na, NICK_RESETPASS_SUBJECT), na->nick); + + int min = 1, max = 62; + int chars[] = { + ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + }; + + int idx; + for (idx = 0; idx < 20; ++idx) + passcode[idx] = chars[1 + static_cast((static_cast(max - min)) * getrandom16() / 65536.0) + min]; + passcode[idx] = '\0'; + + snprintf(message, sizeof(message), getstring(na, NICK_RESETPASS_MESSAGE), na->nick, Config.s_NickServ, passcode, Config.NetworkName); + + na->nc->Shrink("ns_resetpass_code"); + na->nc->Shrink("ns_resetpass_time"); + + na->nc->Extend("ns_resetpass_code", new ExtensibleItemRegular(passcode)); + na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular(time(NULL))); + + return Mail(u, na->nc, Config.s_NickServ, subject, message); +} + MODULE_INIT(NSResetPass) diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c index 0ce8f6c5c..ffa4b6ece 100644 --- a/src/core/ns_sendpass.c +++ b/src/core/ns_sendpass.c @@ -14,6 +14,8 @@ #include "module.h" +static bool SendPassMail(User *u, NickAlias *na, const std::string &pass); + class CommandNSSendPass : public Command { public: @@ -34,34 +36,14 @@ class CommandNSSendPass : public Command notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick); else { - char buf[BUFSIZE]; std::string tmp_pass; if (enc_decrypt(na->nc->pass,tmp_pass) == 1) { - MailInfo *mail; - - snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT), na->nick); - mail = MailBegin(u, na->nc, buf, Config.s_NickServ); - if (!mail) - return MOD_CONT; - - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2), tmp_pass.c_str()); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring(na, NICK_SENDPASS_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5), Config.NetworkName); - fprintf(mail->pipe, "\n.\n"); - - MailEnd(mail); - - Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; - notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick); + if (SendPassMail(u, na, tmp_pass)) + { + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; + notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick); + } } else notice_lang(Config.s_NickServ, u, NICK_SENDPASS_UNAVAILABLE); @@ -102,10 +84,21 @@ class NSSendPass : public Module ModuleManager::Attach(I_OnNickServHelp, this); } + void OnNickServHelp(User *u) { notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SENDPASS); } }; +static bool SendPassMail(User *u, NickAlias *na, const std::string &pass) +{ + char subject[BUFSIZE], message[BUFSIZE]; + + snprintf(subject, sizeof(subject), getstring(na, NICK_SENDPASS_SUBJECT), na->nick); + snprintf(message, sizeof(message), getstring(na, NICK_SENDPASS), na->nick, pass.c_str(), Config.NetworkName); + + return Mail(u, na->nc, Config.s_NickServ, subject, message); +} + MODULE_INIT(NSSendPass) -- 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/core/db_plain.cpp | 187 +++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 95 deletions(-) (limited to 'src/core') diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 0ae6c47f8..21164584f 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -39,7 +39,6 @@ static const char endl = '\n'; */ static void ReadDatabase(Module *m = NULL) { - std::string buf; EventReturn MOD_RESULT; MDType Type = MD_NONE; @@ -56,6 +55,7 @@ static void ReadDatabase(Module *m = NULL) BotInfo *bi = NULL; ChannelInfo *ci = NULL; + std::string buf; while (std::getline(db, buf)) { if (buf.empty()) @@ -87,7 +87,6 @@ static void ReadDatabase(Module *m = NULL) if (MOD_RESULT == EVENT_STOP) continue; - std::string mdbuf; if (!params.empty()) { if (params[0] == "NC") @@ -198,12 +197,6 @@ struct LangInfo int LanguageId; }; -struct ChannelModeInfo -{ - std::string Name; - ChannelModeName Value; -}; - struct ChannelFlagInfo { std::string Name; @@ -245,42 +238,6 @@ LangInfo LangInfos[] = { {"", -1} }; -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)} -}; - ChannelFlagInfo ChannelInfoFlags[] = { {"KEEPTOPIC", CI_KEEPTOPIC}, {"SECUREOPS", CI_SECUREOPS}, @@ -740,8 +697,6 @@ class DBPlain : public Module EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const std::string &key, const std::vector ¶ms) { - int i; - if (key == "FOUNDER") { ci->founder = findcore(params[0].c_str()); @@ -757,14 +712,14 @@ class DBPlain : public Module else if (key == "LEVELS") { for (unsigned j = 0; j < params.size(); ++j, ++j) - for (i = 0; ChannelLevels[i].Level != -1; ++i) + for (int i = 0; ChannelLevels[i].Level != -1; ++i) if (ChannelLevels[i].Name == params[j]) ci->levels[ChannelLevels[i].Level] = atoi(params[j + 1].c_str()); } else if (key == "FLAGS") { for (unsigned j = 0; j < params.size(); ++j) - for (i = 0; ChannelInfoFlags[i].Flag != -1; ++i) + for (int i = 0; ChannelInfoFlags[i].Flag != -1; ++i) if (ChannelInfoFlags[i].Name == params[j]) ci->SetFlag(ChannelInfoFlags[i].Flag); } @@ -830,16 +785,38 @@ class DBPlain : public Module bool Set = key == "MLOCK_ON" ? true : false; for (unsigned j = 0; j < params.size(); ++j) - for (i = 0; ChannelModes[i].Value != -1; ++i) - if (ChannelModes[i].Name == params[j]) - ci->SetMLock(ChannelModes[i].Value, Set); + { + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) + { + if ((*it)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast(*it); + + if (cm->NameAsString == params[j]) + { + ci->SetMLock(cm->Name, Set); + } + } + } + } } else if (key == "MLP") { for (unsigned j = 0; j < params.size(); ++j, ++j) - for (i = 0; ChannelModes[i].Value != -1; ++i) - if (ChannelModes[i].Name == params[j]) - ci->SetMLock(ChannelModes[i].Value, true, params[j + 1]); + { + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) + { + if ((*it)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast(*it); + + if (cm->NameAsString == params[j]) + { + ci->SetMLock(cm->Name, true, params[j + 1]); + } + } + } + } } else if (key == "MI") { @@ -868,7 +845,7 @@ class DBPlain : public Module else if (params[0] == "FLAGS") { for (unsigned j = 1; j < params.size(); ++j) - for (i = 0; BotFlags[i].Flag != -1; ++i) + for (int i = 0; BotFlags[i].Flag != -1; ++i) if (BotFlags[i].Name == params[j]) ci->botflags.SetFlag(BotFlags[i].Flag); } @@ -936,10 +913,7 @@ class DBPlain : public Module db << "VER 1" << endl; - int i, j; - unsigned k; - - for (i = 0; i < 1024; ++i) + for (int i = 0; i < 1024; ++i) { for (NickRequest *nr = nrlists[i]; nr; nr = nr->next) { @@ -947,10 +921,9 @@ class DBPlain : public Module } } - NickCore *nc; - for (i = 0; i < 1024; ++i) + for (int i = 0; i < 1024; ++i) { - for (nc = nclists[i]; nc; nc = nc->next) + for (NickCore *nc = nclists[i]; nc; nc = nc->next) { if (nc->HasFlag(NI_FORBIDDEN)) { @@ -963,7 +936,7 @@ class DBPlain : public Module { db << "NC " << nc->display << " " << nc->pass << " "; } - for (j = 0; LangInfos[j].LanguageId != -1; ++j) + for (int j = 0; LangInfos[j].LanguageId != -1; ++j) if (nc->language == LangInfos[j].LanguageId) db << LangInfos[j].Name; db << " " << nc->memos.memomax << " " << nc->channelcount << endl; @@ -984,7 +957,7 @@ class DBPlain : public Module if (nc->FlagCount()) { db << "MD FLAGS"; - for (j = 0; NickCoreFlags[j].Flag != -1; ++j) + for (int j = 0; NickCoreFlags[j].Flag != -1; ++j) if (nc->HasFlag(NickCoreFlags[j].Flag)) db << " " << NickCoreFlags[j].Name; db << endl; @@ -992,7 +965,7 @@ class DBPlain : public Module if (!nc->memos.memos.empty()) { MemoInfo *mi = &nc->memos; - for (k = 0; k < mi->memos.size(); ++k) + for (unsigned k = 0; k < mi->memos.size(); ++k) { db << "MD MI " << mi->memos[k]->number << " " << mi->memos[k]->time << " " << mi->memos[k]->sender; if (mi->memos[k]->HasFlag(MF_UNREAD)) @@ -1010,10 +983,9 @@ class DBPlain : public Module } } - NickAlias *na; - for (i = 0; i < 1024; ++i) + for (int i = 0; i < 1024; ++i) { - for (na = nalists[i]; na; na = na->next) + for (NickAlias *na = nalists[i]; na; na = na->next) { db << "NA " << na->nc->display << " " << na->nick << " " << na->time_registered << " " << na->last_seen << endl; if (na->last_usermask) @@ -1035,10 +1007,9 @@ class DBPlain : public Module } } - BotInfo *bi; - for (i = 0; i < 256; ++i) + for (int i = 0; i < 256; ++i) { - for (bi = botlists[i]; bi; bi = bi->next) + for (BotInfo *bi = botlists[i]; bi; bi = bi->next) { db << "BI " << bi->nick << " " << bi->user << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->real << endl; if (bi->FlagCount()) @@ -1067,10 +1038,9 @@ class DBPlain : public Module } } - ChannelInfo *ci; - for (i = 0; i < 256; ++i) + for (int i = 0; i < 256; ++i) { - for (ci = chanlists[i]; ci; ci = ci->next) + for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next) { db << "CH " << ci->name << " " << ci->time_registered << " " << ci->last_used; db << " " << ci->bantype << " " << ci->memos.memomax << endl; @@ -1087,24 +1057,24 @@ class DBPlain : public Module if (ci->last_topic) db << "MD TOPIC " << ci->last_topic_setter << " " << ci->last_topic_time << " :" << ci->last_topic << endl; db << "MD LEVELS"; - for (j = 0; ChannelLevels[j].Level != -1; ++j) + for (int j = 0; ChannelLevels[j].Level != -1; ++j) db << " " << ChannelLevels[j].Name << " " << ci->levels[ChannelLevels[j].Level]; db << endl; if (ci->FlagCount()) { db << "MD FLAGS"; - for (j = 0; ChannelInfoFlags[j].Flag != -1; ++j) + for (int j = 0; ChannelInfoFlags[j].Flag != -1; ++j) if (ci->HasFlag(ChannelInfoFlags[j].Flag)) db << " " << ChannelInfoFlags[j].Name; db << endl; if (ci->HasFlag(CI_FORBIDDEN)) db << "MD FORBID " << ci->forbidby << " :" << ci->forbidreason << endl; } - for (k = 0; k < ci->GetAccessCount(); ++k) + for (unsigned k = 0; k < ci->GetAccessCount(); ++k) if (ci->GetAccess(k)->in_use) db << "MD ACCESS " << ci->GetAccess(k)->nc->display << " " << ci->GetAccess(k)->level << " " << ci->GetAccess(k)->last_seen << " " << ci->GetAccess(k)->creator << endl; - for (k = 0; k < ci->GetAkickCount(); ++k) + for (unsigned k = 0; k < ci->GetAkickCount(); ++k) { db << "MD AKICK " << (ci->GetAkick(k)->HasFlag(AK_STUCK) ? "STUCK " : "UNSTUCK ") @@ -1119,28 +1089,55 @@ class DBPlain : public Module if (ci->GetMLockCount(true)) { db << "MD MLOCK_ON"; - for (j = 0; ChannelModes[j].Value != -1; ++j) - if (ci->HasMLock(ChannelModes[j].Value, true)) - db << " " << ChannelModes[j].Name; + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) + { + if ((*it)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast(*it); + + if (ci->HasMLock(cm->Name, true)) + { + db << " " << cm->NameAsString; + } + } + } db << endl; } if (ci->GetMLockCount(false)) { db << "MD MLOCK_OFF"; - for (j = 0; ChannelModes[j].Value != -1; ++j) - if (ci->HasMLock(ChannelModes[j].Value, false)) - db << " " << ChannelModes[j].Name; + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) + { + if ((*it)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast(*it); + + if (ci->HasMLock(cm->Name, false)) + { + db << " " << cm->NameAsString; + } + } + } db << endl; } std::string Param; - for (j = 0; ChannelModes[j].Value != -1; ++j) - if (ci->GetParam(ChannelModes[j].Value, Param)) - db << "MD MLP " << ChannelModes[j].Name << " " << Param << endl; + for (std::list::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it) + { + if ((*it)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast(*it); + + if (ci->GetParam(cm->Name, Param)) + { + db << "MD MLP " << cm->NameAsString << " " << Param << endl; + } + } + } if (!ci->memos.memos.empty()) { MemoInfo *memos = &ci->memos; - for (k = 0; k < memos->memos.size(); ++k) + for (unsigned k = 0; k < memos->memos.size(); ++k) { db << "MD MI " << memos->memos[k]->number << " " << memos->memos[k]->time << " " << memos->memos[k]->sender; if (memos->memos[k]->HasFlag(MF_UNREAD)) @@ -1159,7 +1156,7 @@ class DBPlain : public Module if (ci->botflags.FlagCount()) { db << "MD BI FLAGS"; - for (j = 0; BotFlags[j].Flag != -1; ++j) + for (int j = 0; BotFlags[j].Flag != -1; ++j) if (ci->botflags.HasFlag(BotFlags[j].Flag)) db << " " << BotFlags[j].Name; db << endl; @@ -1175,7 +1172,7 @@ class DBPlain : public Module db << "MD BI FLOODSECS " << ci->floodsecs << endl; if (ci->repeattimes) db << "MD BI REPEATTIMES " << ci->repeattimes << endl; - for (k = 0; k < ci->GetBadWordCount(); ++k) + for (unsigned k = 0; k < ci->GetBadWordCount(); ++k) db << "MD BI BADWORD " << (ci->GetBadWord(k)->type == BW_ANY ? "ANY " : "") << (ci->GetBadWord(k)->type == BW_SINGLE ? "SINGLE " : "") @@ -1187,7 +1184,7 @@ class DBPlain : public Module } } - for (i = 0; i < akills.count; ++i) + for (int i = 0; i < akills.count; ++i) { Akill *ak = static_cast(akills.list[i]); db << "OS AKILL " << ak->user << " " << ak->host << " " << ak->by << " " << ak->seton << " " << ak->expires << " :" << ak->reason << endl; @@ -1195,23 +1192,23 @@ class DBPlain : public Module db << "OS STATS " << maxusercnt << " " << maxusertime << endl; SXLine *sx; - for (i = 0; i < sglines.count; ++i) + for (int i = 0; i < sglines.count; ++i) { sx = static_cast(sglines.list[i]); db << "OS SGLINE " << sx->mask << " " << sx->by << " " << sx->seton << " " << sx->expires << " :" << sx->reason << endl; } - for (i = 0; i < sqlines.count; ++i) + for (int i = 0; i < sqlines.count; ++i) { sx = static_cast(sqlines.list[i]); db << "OS SQLINE " << sx->mask << " " << sx->by << " " << sx->seton << " " << sx->expires << " :" << sx->reason << endl; } - for (i = 0; i < szlines.count; ++i) + for (int i = 0; i < szlines.count; ++i) { sx = static_cast(szlines.list[i]); db << "OS SZLINE " << sx->mask << " " << sx->by << " " << sx->seton << " " << sx->expires << " :" << sx->reason << endl; } - for (i = 0; i < nexceptions; i++) + for (int i = 0; i < nexceptions; i++) { db << "OS EXCEPTION " << exceptions[i].mask << " " << exceptions[i].limit << " " << exceptions[i].who << " " << exceptions[i].time << " " << exceptions[i].expires << " " << exceptions[i].reason << endl; } -- cgit From e6263dba84b80f03d02c379ace081e602f8ef199 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 11 May 2010 14:36:53 -0400 Subject: Allow attaching metadata to nickrequests and storing it in the databases and fixed windows build --- src/core/db_plain.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/core') diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 21164584f..fba374667 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -24,6 +24,7 @@ enum MDType MD_NONE, MD_NC, MD_NA, + MD_NR, MD_BI, MD_CH }; @@ -99,6 +100,11 @@ static void ReadDatabase(Module *m = NULL) na = findnick(params[2].c_str()); Type = MD_NA; } + else if (params[0] == "NR") + { + nr = findrequestnick(params[1].c_str()); + Type = MD_NR; + } else if (params[0] == "BI") { bi = findbot(params[1]); @@ -147,6 +153,22 @@ static void ReadDatabase(Module *m = NULL) Alog() << "[db_plain]: " << ex.GetReason(); } } + else if (Type == MD_NR && nr) + { + try + { + if (m) + m->OnDatabaseReadMetadata(nr, key, params); + else + { + FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nr, key, params)); + } + } + catch (DatabaseException& ex) + { + Alog() << "[db_plain]: " << ex.GetReason(); + } + } else if (Type == MD_BI && bi) { try @@ -918,6 +940,8 @@ class DBPlain : public Module for (NickRequest *nr = nrlists[i]; nr; nr = nr->next) { db << "NR " << nr->nick << " " << nr->passcode << " " << nr->password << " " << nr->email << " " << nr->requested << endl; + + FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nr)); } } -- cgit From 81a45520a773732c9f46785f27aa1956150775d7 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 13 May 2010 14:56:13 -0400 Subject: Added some global variables for the core pseudo clients, keeps us from having to call findbot() everywhere --- src/core/db_plain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index fba374667..24b494d82 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -53,6 +53,7 @@ static void ReadDatabase(Module *m = NULL) NickCore *nc = NULL; NickAlias *na = NULL; + NickRequest *nr = NULL; BotInfo *bi = NULL; ChannelInfo *ci = NULL; @@ -550,7 +551,7 @@ class DBPlain : public Module snprintf(newname, DatabaseFile.length() + 30, "backups/%s.%d%d%d", DatabaseFile.c_str(), tm->tm_year, tm->tm_mon, tm->tm_mday); /* Backup already exists */ - if (!stat(newname, &DBInfo)) + if (IsFile(newname)) { delete [] newname; return; -- 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/core/bs_act.c | 2 +- src/core/bs_assign.c | 2 +- src/core/bs_badwords.c | 2 +- src/core/bs_bot.c | 2 +- src/core/bs_botlist.c | 44 +++-- src/core/bs_help.c | 4 +- src/core/bs_info.c | 27 ++- src/core/bs_kick.c | 2 +- src/core/bs_say.c | 2 +- src/core/bs_set.c | 2 +- src/core/bs_unassign.c | 2 +- src/core/cs_access.c | 4 +- src/core/cs_akick.c | 49 +++--- src/core/cs_ban.c | 4 +- src/core/cs_clear.c | 2 +- src/core/cs_drop.c | 4 +- src/core/cs_forbid.c | 6 +- src/core/cs_getkey.c | 2 +- src/core/cs_help.c | 4 +- src/core/cs_info.c | 2 +- src/core/cs_invite.c | 2 +- src/core/cs_kick.c | 4 +- src/core/cs_list.c | 88 +++++----- src/core/cs_modes.c | 32 ++-- src/core/cs_register.c | 4 +- src/core/cs_set.c | 8 +- src/core/cs_status.c | 2 +- src/core/cs_suspend.c | 8 +- src/core/cs_topic.c | 10 +- src/core/cs_unban.c | 2 +- src/core/cs_xop.c | 14 +- src/core/db_plain.cpp | 444 ++++++++++++++++++++++------------------------- src/core/hs_del.c | 2 +- src/core/hs_delall.c | 2 +- src/core/hs_group.c | 2 +- src/core/hs_help.c | 4 +- src/core/hs_list.c | 69 ++++---- src/core/hs_off.c | 2 +- src/core/hs_on.c | 2 +- src/core/hs_set.c | 2 +- src/core/hs_setall.c | 2 +- src/core/ms_cancel.c | 2 +- src/core/ms_check.c | 2 +- src/core/ms_del.c | 2 +- src/core/ms_help.c | 4 +- src/core/ms_info.c | 2 +- src/core/ms_list.c | 2 +- src/core/ms_read.c | 2 +- src/core/ms_rsend.c | 2 +- src/core/ms_send.c | 2 +- src/core/ms_sendall.c | 20 +-- src/core/ms_set.c | 2 +- src/core/ms_staff.c | 17 +- src/core/ns_access.c | 2 +- src/core/ns_alist.c | 36 ++-- src/core/ns_drop.c | 6 +- src/core/ns_forbid.c | 4 +- src/core/ns_getemail.c | 23 +-- src/core/ns_getpass.c | 6 +- src/core/ns_ghost.c | 2 +- src/core/ns_group.c | 8 +- src/core/ns_help.c | 4 +- src/core/ns_identify.c | 4 +- src/core/ns_info.c | 2 +- src/core/ns_list.c | 95 +++++----- src/core/ns_logout.c | 2 +- src/core/ns_recover.c | 2 +- src/core/ns_register.c | 6 +- src/core/ns_release.c | 2 +- src/core/ns_resetpass.c | 2 +- src/core/ns_saset.c | 4 +- src/core/ns_sendpass.c | 2 +- src/core/ns_set.c | 2 +- src/core/ns_status.c | 2 +- src/core/ns_suspend.c | 8 +- src/core/ns_update.c | 2 +- src/core/os_akill.c | 4 +- src/core/os_chankill.c | 4 +- src/core/os_chanlist.c | 31 ++-- src/core/os_clearmodes.c | 4 +- src/core/os_defcon.c | 24 +-- src/core/os_global.c | 4 +- src/core/os_help.c | 4 +- src/core/os_ignore.c | 2 +- src/core/os_jupe.c | 4 +- src/core/os_kick.c | 6 +- src/core/os_mode.c | 6 +- src/core/os_modinfo.c | 49 +++--- src/core/os_modlist.c | 109 ++++++------ src/core/os_modload.c | 12 +- src/core/os_modunload.c | 12 +- src/core/os_news.c | 6 +- src/core/os_noop.c | 12 +- src/core/os_oline.c | 8 +- src/core/os_quit.c | 2 +- src/core/os_reload.c | 2 +- src/core/os_restart.c | 2 +- src/core/os_session.c | 19 +- src/core/os_set.c | 10 +- src/core/os_sgline.c | 4 +- src/core/os_shutdown.c | 2 +- src/core/os_sqline.c | 4 +- src/core/os_staff.c | 6 +- src/core/os_stats.c | 2 +- src/core/os_svsnick.c | 4 +- src/core/os_szline.c | 4 +- src/core/os_umode.c | 6 +- src/core/os_update.c | 2 +- src/core/os_userlist.c | 32 ++-- src/core/ss_main.c | 19 +- 110 files changed, 759 insertions(+), 820 deletions(-) (limited to 'src/core') diff --git a/src/core/bs_act.c b/src/core/bs_act.c index d0b9c8b08..1bf11e078 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -75,7 +75,7 @@ class BSAct : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSAct()); + this->AddCommand(BotServ, new CommandBSAct()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index f37db9aca..dc847eb66 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -85,7 +85,7 @@ class BSAssign : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSAssign); + this->AddCommand(BotServ, new CommandBSAssign); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index af616c41a..3db6f1e42 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -229,7 +229,7 @@ class BSBadwords : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSBadwords); + this->AddCommand(BotServ, new CommandBSBadwords); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c index 8abfecde8..d8cb3db6d 100644 --- a/src/core/bs_bot.c +++ b/src/core/bs_bot.c @@ -414,7 +414,7 @@ class BSBot : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSBot()); + this->AddCommand(BotServ, new CommandBSBot()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 540cac30d..935e6d18a 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -23,34 +23,39 @@ class CommandBSBotList : public Command CommandReturn Execute(User *u, const std::vector ¶ms) { - int i, count = 0; - BotInfo *bi; + unsigned count = 0; - if (!nbots) { + if (BotList.empty()) + { notice_lang(Config.s_BotServ, u, BOT_BOTLIST_EMPTY); return MOD_CONT; } - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (!(bi->HasFlag(BI_PRIVATE))) { - if (!count) - notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER); - count++; - u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); - } + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) + { + BotInfo *bi = it->second; + + if (!bi->HasFlag(BI_PRIVATE)) + { + if (!count) + notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER); + count++; + u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); } } - if (u->Account()->HasCommand("botserv/botlist") && count < nbots) { + if (u->Account()->HasCommand("botserv/botlist") && count < BotList.size()) + { notice_lang(Config.s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (bi->HasFlag(BI_PRIVATE)) { - u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); - count++; - } + for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it) + { + BotInfo *bi = it->second; + + if (bi->HasFlag(BI_PRIVATE)) + { + u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str()); + count++; } } } @@ -59,6 +64,7 @@ class CommandBSBotList : public Command notice_lang(Config.s_BotServ, u, BOT_BOTLIST_EMPTY); else notice_lang(Config.s_BotServ, u, BOT_BOTLIST_FOOTER, count); + return MOD_CONT; } @@ -77,7 +83,7 @@ class BSBotList : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSBotList()); + this->AddCommand(BotServ, new CommandBSBotList()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_help.c b/src/core/bs_help.c index d28595986..a3e53df5c 100644 --- a/src/core/bs_help.c +++ b/src/core/bs_help.c @@ -25,7 +25,7 @@ class CommandBSHelp : public Command CommandReturn Execute(User *u, const std::vector ¶ms) { - mod_help_cmd(Config.s_BotServ, u, BOTSERV, params[0].c_str()); + mod_help_cmd(findbot(Config.s_BotServ), u, params[0].c_str()); return MOD_CONT; } @@ -46,7 +46,7 @@ class BSHelp : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSHelp()); + this->AddCommand(BotServ, new CommandBSHelp()); } }; diff --git a/src/core/bs_info.c b/src/core/bs_info.c index 3ac3e9540..3f873aafd 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -19,25 +19,24 @@ class CommandBSInfo : public Command private: void send_bot_channels(User * u, BotInfo * bi) { - int i; - ChannelInfo *ci; char buf[307], *end; *buf = 0; end = buf; - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - if (ci->bi == bi) { - if (strlen(buf) + strlen(ci->name.c_str()) > 300) { - u->SendMessage(Config.s_BotServ, "%s", buf); - *buf = 0; - end = buf; - } - end += - snprintf(end, sizeof(buf) - (end - buf), " %s ", - ci->name.c_str()); + for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it) + { + ChannelInfo *ci = it->second; + + if (ci->bi == bi) + { + if (strlen(buf) + strlen(ci->name.c_str()) > 300) + { + u->SendMessage(Config.s_BotServ, "%s", buf); + *buf = 0; + end = buf; } + end += snprintf(end, sizeof(buf) - (end - buf), " %s ", ci->name.c_str()); } } @@ -251,7 +250,7 @@ class BSInfo : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSInfo()); + this->AddCommand(BotServ, new CommandBSInfo()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index 766239c73..ab2782c8d 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -335,7 +335,7 @@ class BSKick : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSKick()); + this->AddCommand(BotServ, new CommandBSKick()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 9cd630eb8..8dfc55115 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -81,7 +81,7 @@ class BSSay : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSSay()); + this->AddCommand(BotServ, new CommandBSSay()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_set.c b/src/core/bs_set.c index 0614651cc..3468198a2 100644 --- a/src/core/bs_set.c +++ b/src/core/bs_set.c @@ -185,7 +185,7 @@ class BSSet : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSSet()); + this->AddCommand(BotServ, new CommandBSSet()); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c index e053f75d7..067e4cc14 100644 --- a/src/core/bs_unassign.c +++ b/src/core/bs_unassign.c @@ -63,7 +63,7 @@ class BSUnassign : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(BOTSERV, new CommandBSUnassign); + this->AddCommand(BotServ, new CommandBSUnassign); ModuleManager::Attach(I_OnBotServHelp, this); } diff --git a/src/core/cs_access.c b/src/core/cs_access.c index e4e1d0e4b..718a7dc0f 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -573,8 +573,8 @@ class CSAccess : public Module this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(CHANSERV, new CommandCSAccess()); - this->AddCommand(CHANSERV, new CommandCSLevels()); + this->AddCommand(ChanServ, new CommandCSAccess()); + this->AddCommand(ChanServ, new CommandCSLevels()); ModuleManager::Attach(I_OnChanServHelp, this); } diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index ac17ef504..abd00be6a 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -152,7 +152,6 @@ class CommandCSAKick : public Command NickAlias *na = findnick(mask.c_str()); NickCore *nc = NULL; AutoKick *akick; - int i; if (!na) { @@ -197,42 +196,40 @@ class CommandCSAKick : public Command } else if ((ci->HasFlag(CI_PEACE))) { - char buf[BUFSIZE]; /* Match against all currently online users with equal or * higher access. - Viper */ - for (i = 0; i < 1024; i++) + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - for (User *u2 = userlist[i]; u2; u2 = u2->next) + User *u2 = it->second; + + if (IsFounder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci))) { - if (IsFounder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci))) + if (match_usermask(mask.c_str(), u2)) { - if (match_usermask(mask.c_str(), u2)) - { - notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - return; - } + notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); + return; } } - } - + } - /* Match against the lastusermask of all nickalias's with equal - * or higher access. - Viper */ - for (i = 0; i < 1024; i++) + /* Match against the lastusermask of all nickalias's with equal + * or higher access. - Viper */ + for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it) { - for (NickAlias *na2 = nalists[i]; na2; na2 = na2->next) + NickAlias *na2 = it->second; + + if (na2->HasFlag(NS_FORBIDDEN)) + continue; + + if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci)))) { - if (na2->HasFlag(NS_FORBIDDEN)) - continue; + char buf[BUFSIZE]; - if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci)))) + snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); + if (Anope::Match(buf, mask.c_str(), false)) { - snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); - if (Anope::Match(buf, mask.c_str(), false)) - { - notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - return; - } + notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); + return; } } } @@ -577,7 +574,7 @@ class CSAKick : public Module this->SetAuthor("Anope"); this->SetVersion(VERSION_STRING); this->SetType(CORE); - this->AddCommand(CHANSERV, new CommandCSAKick()); + this->AddCommand(ChanServ, new CommandCSAKick()); ModuleManager::Attach(I_OnChanServHelp, this); } diff --git a/src/core/cs_ban.c b/src/c