diff --git a/data/example.conf b/data/example.conf index d6d38cf87..0a4827a98 100644 --- a/data/example.conf +++ b/data/example.conf @@ -843,7 +843,7 @@ nickserv * * This directive is optional, but highly recommended. */ - modules = "ns_help ns_register ns_group ns_identify ns_access ns_cert ns_set ns_saset ns_set_autoop ns_set_email ns_set_greet ns_set_hide ns_set_kill ns_set_language ns_set_message ns_set_private ns_set_secure ns_saset_noexpire ns_drop ns_recover ns_release ns_sendpass ns_ghost ns_alist ns_info ns_list ns_logout ns_status ns_update ns_getpass ns_getemail ns_forbid ns_suspend ns_resetpass ns_ajoin" + modules = "ns_help ns_register ns_group ns_identify ns_access ns_cert ns_set ns_saset ns_set_autoop ns_set_email ns_set_greet ns_set_hide ns_set_kill ns_set_language ns_set_message ns_set_private ns_set_secure ns_saset_noexpire ns_drop ns_recover ns_release ns_sendpass ns_ghost ns_alist ns_info ns_list ns_logout ns_status ns_update ns_getpass ns_getemail ns_suspend ns_resetpass ns_ajoin" /* * Force users to give an e-mail address when they register a nick. @@ -929,13 +929,6 @@ nickserv */ #suspendexpire = 90d - /* - * The lenth of time before a forbidden nick drops. - * - * This directive is optional. If not set, the default is to never. - */ - #forbidexpire = 90d - /* * The length of time a user using an unconfirmed account has * before the account will be released for general use again. @@ -1073,7 +1066,7 @@ chanserv * * This directive is optional, but highly recommended. */ - modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode" + modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_suspend cs_status cs_unban cs_clone cs_mode" /* * The default options for newly registered channels. Note that changing these options @@ -1427,7 +1420,7 @@ operserv * * This directive is optional, but highly recommended. */ - modules = "os_help os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login" + modules = "os_help os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login os_forbid" /* * If set, Services Admins will be able to use SUPERADMIN [ON|OFF] which will temporarily grant diff --git a/data/mysql/tables.sql b/data/mysql/tables.sql index 9fc0e55a0..5f49f7ea7 100644 --- a/data/mysql/tables.sql +++ b/data/mysql/tables.sql @@ -105,8 +105,6 @@ CREATE TABLE IF NOT EXISTS `anope_cs_info` ( `last_topic_setter` text NOT NULL, `last_topic_time` int(10) unsigned NOT NULL DEFAULT '0', `flags` text NOT NULL, - `forbidby` text NOT NULL, - `forbidreason` text NOT NULL, `bantype` smallint(6) NOT NULL DEFAULT '0', `memomax` smallint(5) unsigned NOT NULL DEFAULT '0', `botnick` varchar(255) NOT NULL DEFAULT '', diff --git a/docs/Changes.conf b/docs/Changes.conf index 650603e24..1cdf28ba9 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -6,6 +6,7 @@ global:globaloncycle global:globaloncycledown global:globaloncycleup global:anonymousglobal +operserv:modules added os_forbid ** MODIFIED CONFIGURATION DIRECTIVES ** opertype:permissions added memoserv/no-limit @@ -21,6 +22,8 @@ options:socketengine options:encryption options:database serverinfo:protocol +chanserv:modules removed cs_forbid +nickserv:modules removed ns_forbid Anope Version 1.9.4 ------------------- diff --git a/include/account.h b/include/account.h index 777efb5d0..15d2faa10 100644 --- a/include/account.h +++ b/include/account.h @@ -20,8 +20,6 @@ enum NickNameFlag { NS_BEGIN, - /* Nick may not be registered or used */ - NS_FORBIDDEN, /* Nick never expires */ NS_NO_EXPIRE, /* This nick is being held after a kill by an enforcer client diff --git a/include/channels.h b/include/channels.h index 5d18a381f..113b5c1f9 100644 --- a/include/channels.h +++ b/include/channels.h @@ -25,6 +25,8 @@ typedef std::list CUserList; enum ChannelFlag { + /* ChanServ is currently holding the channel */ + CH_INHABIT, /* Channel still exists when emptied */ CH_PERSIST, /* If set the channel is syncing users (channel was just created) and it should not be deleted */ @@ -33,6 +35,8 @@ enum ChannelFlag CH_LOGCHAN }; +const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "CH_LOGCHAN", "" }; + class CoreExport Channel : public Extensible, public Flags { public: diff --git a/include/commands.h b/include/commands.h index e966e9e39..89fd1436c 100644 --- a/include/commands.h +++ b/include/commands.h @@ -36,7 +36,6 @@ extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, ChannelInfo *ci, Comman enum CommandFlag { CFLAG_ALLOW_UNREGISTERED, - CFLAG_ALLOW_FORBIDDEN, CFLAG_ALLOW_SUSPENDED, CFLAG_ALLOW_UNREGISTEREDCHANNEL, CFLAG_STRIP_CHANNEL, @@ -45,7 +44,6 @@ enum CommandFlag const Anope::string CommandFlagStrings[] = { "CFLAG_ALLOW_UNREGISTERED", - "CFLAG_ALLOW_FORBIDDEN", "CFLAG_ALLOW_SUSPENDED", "CFLAG_ALLOW_UNREGISTEREDCHANNEL", "CFLAG_STRIP_CHANNEL", diff --git a/include/config.h b/include/config.h index 8a564e8ec..b06aa60d8 100644 --- a/include/config.h +++ b/include/config.h @@ -502,8 +502,6 @@ class CoreExport ServerConfig time_t NSExpire; /* How long before suspended nicks expire */ time_t NSSuspendExpire; - /* How long before forbidden nicks expire */ - time_t NSForbidExpire; /* Time before unconfirmed nicks expire */ time_t NSUnconfirmedExpire; /* Force email when registering */ diff --git a/include/language.h b/include/language.h index f4329a72b..8afd360de 100644 --- a/include/language.h +++ b/include/language.h @@ -19,15 +19,10 @@ #define NICK_X_NOT_REGISTERED "Nick \002%s\002 isn't registered." #define NICK_X_NOT_IN_USE "Nick \002%s\002 isn't currently in use." #define NICK_X_NOT_ON_CHAN "\002%s\002 is not currently on channel %s." -#define NICK_X_FORBIDDEN "Nick \002%s\002 may not be registered or used." -#define NICK_X_FORBIDDEN_OPER "Nick \002%s\002 has been forbidden by %s:\n" \ - "%s" -#define NICK_X_SUSPENDED "Nick %s is currently suspended." +#define NICK_X_SUSPENDED "Nick %s is currently suspended." +#define CHAN_X_SUSPENDED "Channel %s is currently suspended." #define CHAN_X_NOT_REGISTERED "Channel \002%s\002 isn't registered." #define CHAN_X_NOT_IN_USE "Channel \002%s\002 doesn't exist." -#define CHAN_X_FORBIDDEN "Channel \002%s\002 may not be registered or used." -#define CHAN_X_FORBIDDEN_OPER "Channel \002%s\002 has been forbidden by %s:\n" \ - "%s" #define NICK_IDENTIFY_REQUIRED "Password authentication required for that command.\n" \ "Retry after typing \002%s%s IDENTIFY \037password\037\002." #define MAIL_X_INVALID "\002%s\002 is not a valid e-mail address." diff --git a/include/regchannel.h b/include/regchannel.h index 851c4a7d1..8245b256d 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -18,8 +18,6 @@ enum ChannelInfoFlag { CI_BEGIN, - /* ChanServ is currently holding the channel */ - CI_INHABIT, /* Retain the topic even after the channel is emptied */ CI_KEEPTOPIC, /* Don't allow non-authorized users to be opped */ @@ -34,8 +32,6 @@ enum ChannelInfoFlag CI_PEACE, /* Don't allow any privileges unless a user is IDENTIFIED with NickServ */ CI_SECURE, - /* Don't allow the channel to be registered or used */ - CI_FORBIDDEN, /* Channel does not expire */ CI_NO_EXPIRE, /* Channel memo limit may not be changed */ @@ -63,7 +59,7 @@ enum ChannelInfoFlag }; const Anope::string ChannelInfoFlagStrings[] = { - "BEGIN", "INHABIT", "KEEPTOPIC", "SECUREOPS", "PRIVATE", "TOPICLOCK", "RESTRICTED", + "BEGIN", "KEEPTOPIC", "SECUREOPS", "PRIVATE", "TOPICLOCK", "RESTRICTED", "PEACE", "SECURE", "FORBIDDEN", "NO_EXPIRE", "MEMO_HARDMAX", "OPNOTICE", "SECUREFOUNDER", "SIGNKICK", "SIGNKICK_LEVEL", "XOP", "SUSPENDED", "PERSIST", "" }; @@ -154,10 +150,6 @@ class CoreExport ChannelInfo : public Extensible, public FlagsHasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN)) + if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED)) { - u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str()); - Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name; - PopLanguage(); - return; - } - else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED)) - { - u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str()); + u->SendMessage(this, _(_(CHAN_X_SUSPENDED)), ci->name.c_str()); Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name; PopLanguage(); return; diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 243d62057..23d8c4e16 100644 --- a/modules/core/cs_access.cpp +++ b/modules/core/cs_access.cpp @@ -202,11 +202,6 @@ class CommandCSAccess : public Command NickAlias *na = findnick(mask); if (!na && mask.find_first_of("!@*") == Anope::string::npos) mask += "!*@*"; - else if (na && na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), mask.c_str()); - return MOD_CONT; - } ChanAccess *access = ci->GetAccess(mask, 0, false); if (access) diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index 8650aebd4..149e782a9 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -181,15 +181,7 @@ class CommandCSAKick : public Command mask = nick + "!" + user + "@" + host; } else - { - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), mask.c_str()); - return; - } - nc = na->nc; - } /* Check excepts BEFORE we get this far */ if (ci->c) @@ -240,16 +232,13 @@ class CommandCSAKick : public Command * or higher access. - Viper */ for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it) { - NickAlias *na2 = it->second; + na = it->second; - if (na2->HasFlag(NS_FORBIDDEN)) - continue; - - ChanAccess *na2_access = ci->GetAccess(na2->nc), *u_access = ci->GetAccess(u); - int16 na2_level = na2_access ? na2_access->level : 0, u_level = u_access ? u_access->level : 0; - if (na2->nc && (na2->nc == ci->founder || na2_level >= u_level)) + ChanAccess *na_access = ci->GetAccess(na->nc), *u_access = ci->GetAccess(u); + int16 na_level = na_access ? na_access->level : 0, u_level = u_access ? u_access->level : 0; + if (na->nc && (na->nc == ci->founder || na_level >= u_level)) { - Anope::string buf = na2->nick + "!" + na2->last_usermask; + Anope::string buf = na->nick + "!" + na->last_usermask; if (Anope::Match(buf, mask)) { source.Reply(_(ACCESS_DENIED)); diff --git a/modules/core/cs_drop.cpp b/modules/core/cs_drop.cpp index 3a1026f21..a13006196 100644 --- a/modules/core/cs_drop.cpp +++ b/modules/core/cs_drop.cpp @@ -19,7 +19,6 @@ class CommandCSDrop : public Command public: CommandCSDrop() : Command("DROP", 1, 1) { - this->SetFlag(CFLAG_ALLOW_FORBIDDEN); this->SetFlag(CFLAG_ALLOW_SUSPENDED); this->SetDesc(_("Cancel the registration of a channel")); } @@ -39,15 +38,9 @@ class CommandCSDrop : public Command ci = cs_findchan(chan); - if (ci->HasFlag(CI_FORBIDDEN) && !u->HasCommand("chanserv/drop")) - { - source.Reply(_(CHAN_X_FORBIDDEN), chan.c_str()); - return MOD_CONT; - } - if (ci->HasFlag(CI_SUSPENDED) && !u->HasCommand("chanserv/drop")) { - source.Reply(_(CHAN_X_FORBIDDEN), chan.c_str()); + source.Reply(_(CHAN_X_SUSPENDED), chan.c_str()); return MOD_CONT; } @@ -60,12 +53,6 @@ class CommandCSDrop : public Command if (ci->c && ModeManager::FindChannelModeByName(CMODE_REGISTERED)) ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false); - if (ircd->chansqline && ci->HasFlag(CI_FORBIDDEN)) - { - XLine x(ci->name); - ircdproto->SendSQLineDel(&x); - } - bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !check_access(u, ci, CA_FOUNDER)); Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "founder: " << (ci->founder ? ci->founder->display : "none"); diff --git a/modules/core/cs_forbid.cpp b/modules/core/cs_forbid.cpp deleted file mode 100644 index e7f2b7894..000000000 --- a/modules/core/cs_forbid.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" -#include "chanserv.h" - -class CommandCSForbid : public Command -{ - public: - CommandCSForbid() : Command("FORBID", 1, 2, "chanserv/forbid") - { - this->SetFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL); - this->SetDesc(_("Prevent a channel from being used")); - } - - CommandReturn Execute(CommandSource &source, const std::vector ¶ms) - { - const Anope::string &chan = params[0]; - const Anope::string &reason = params.size() > 1 ? params[1] : ""; - - User *u = source.u; - ChannelInfo *ci = source.ci; - - if (Config->ForceForbidReason && reason.empty()) - { - SyntaxError(source, "FORBID", _("FORBID \037channel\037 \037reason\037")); - return MOD_CONT; - } - - if (chan[0] != '#') - { - source.Reply(_(CHAN_SYMBOL_REQUIRED)); - return MOD_CONT; - } - - if (readonly) - { - source.Reply(_(READ_ONLY_MODE)); - return MOD_CONT; - } - - if ((ci = cs_findchan(chan))) - delete ci; - - ci = new ChannelInfo(chan); - ci->SetFlag(CI_FORBIDDEN); - ci->forbidby = u->nick; - ci->forbidreason = reason; - - Channel *c = ci->c; - if (c) - { - /* Before banning everyone, it might be prudent to clear +e and +I lists.. - * to prevent ppl from rejoining.. ~ Viper */ - std::pair modes = c->GetModeList(CMODE_EXCEPT); - for (; modes.first != modes.second; ++modes.first) - c->RemoveMode(NULL, CMODE_EXCEPT, modes.first->second); - modes = c->GetModeList(CMODE_INVITEOVERRIDE); - for (; modes.first != modes.second; ++modes.first) - c->RemoveMode(NULL, CMODE_INVITEOVERRIDE, modes.first->second); - - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) - { - UserContainer *uc = *it++; - - if (uc->user->HasMode(UMODE_OPER)) - continue; - - c->Kick(chanserv->Bot(), uc->user, "%s", !reason.empty() ? reason.c_str() : GetString(uc->user->Account(), "This channel has been forbidden.").c_str()); - } - } - - if (ircd->chansqline) - { - XLine x(chan, "Forbidden"); - ircdproto->SendSQLine(NULL, &x); - } - - Log(LOG_ADMIN, u, this, ci) << (!ci->forbidreason.empty() ? ci->forbidreason : "No reason"); - - source.Reply(_("Channel \002%s\002 is now forbidden."), chan.c_str()); - - FOREACH_MOD(I_OnChanForbidden, OnChanForbidden(ci)); - - return MOD_CONT; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002FORBID \037channel\037 [\037reason\037]\002\n" - " \n" - "Disallows anyone from registering or using the given\n" - "channel. May be cancelled by dropping the channel.\n" - " \n" - "Reason may be required on certain networks.")); - return true; - } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - SyntaxError(source, "FORBID", _("FORBID \037channel\037 [\037reason\037]")); - } -}; - -class CSForbid : public Module -{ - CommandCSForbid commandcsforbid; - - public: - CSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) - { - this->SetAuthor("Anope"); - - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - - this->AddCommand(chanserv->Bot(), &commandcsforbid); - } -}; - -MODULE_INIT(CSForbid) diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp index 71a8b132f..ba26a8c77 100644 --- a/modules/core/cs_info.cpp +++ b/modules/core/cs_info.cpp @@ -32,7 +32,6 @@ class CommandCSInfo : public Command { this->SetFlag(CFLAG_ALLOW_UNREGISTERED); this->SetFlag(CFLAG_ALLOW_SUSPENDED); - this->SetFlag(CFLAG_ALLOW_FORBIDDEN); this->SetDesc(_("Lists information about the named registered channel")); } @@ -46,16 +45,6 @@ class CommandCSInfo : public Command bool has_auspex = u->IsIdentified() && u->HasPriv("chanserv/auspex"); bool show_all = false; - if (ci->HasFlag(CI_FORBIDDEN)) - { - if (u->HasMode(UMODE_OPER) && !ci->forbidby.empty()) - source.Reply(_(CHAN_X_FORBIDDEN_OPER), chan.c_str(), ci->forbidby.c_str(), !ci->forbidreason.empty() ? ci->forbidreason.c_str() : _(NO_REASON)); - else - source.Reply(_(CHAN_X_FORBIDDEN), chan.c_str()); - - return MOD_CONT; - } - /* Should we show all fields? Only for sadmins and identified users */ if (has_auspex || check_access(u, ci, CA_INFO)) show_all = true; @@ -106,7 +95,12 @@ class CommandCSInfo : public Command source.Reply(_(" Expires on: %s"), do_strftime(ci->last_used + Config->CSExpire).c_str()); } if (ci->HasFlag(CI_SUSPENDED)) - source.Reply(_(" Suspended: [%s] %s"), ci->forbidby.c_str(), !ci->forbidreason.empty() ? ci->forbidreason.c_str() : _(NO_REASON)); + { + Anope::string by, reason; + ci->GetExtRegular("suspend_by", by); + ci->GetExtRegular("suspend_reason", reason); + source.Reply(_(" Suspended: [%s] %s"), by.c_str(), !reason.empty() ? reason.c_str() : _(NO_REASON)); + } FOREACH_MOD(I_OnChanInfo, OnChanInfo(source, ci, show_all)); diff --git a/modules/core/cs_list.cpp b/modules/core/cs_list.cpp index e434abf80..7e9a7b21e 100644 --- a/modules/core/cs_list.cpp +++ b/modules/core/cs_list.cpp @@ -29,10 +29,9 @@ class CommandCSList : public Command Anope::string pattern = params[0]; unsigned nchans; - char buf[BUFSIZE]; bool is_servadmin = u->HasCommand("chanserv/list"); int count = 0, from = 0, to = 0; - bool forbidden = false, suspended = false, channoexpire = false; + bool suspended = false, channoexpire = false; if (Config->CSListOpersOnly && !u->HasMode(UMODE_OPER)) { @@ -69,8 +68,6 @@ class CommandCSList : public Command spacesepstream keywords(params[1]); while (keywords.GetToken(keyword)) { - if (keyword.equals_ci("FORBIDDEN")) - forbidden = true; if (keyword.equals_ci("SUSPENDED")) suspended = true; if (keyword.equals_ci("NOEXPIRE")) @@ -86,9 +83,7 @@ class CommandCSList : public Command { ChannelInfo *ci = it->second; - if (!is_servadmin && (ci->HasFlag(CI_PRIVATE) || ci->HasFlag(CI_FORBIDDEN) || ci->HasFlag(CI_SUSPENDED))) - continue; - if (forbidden && !ci->HasFlag(CI_FORBIDDEN)) + if (!is_servadmin && (ci->HasFlag(CI_PRIVATE) || ci->HasFlag(CI_SUSPENDED))) continue; else if (suspended && !ci->HasFlag(CI_SUSPENDED)) continue; @@ -103,14 +98,13 @@ class CommandCSList : public Command if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE))) noexpire_char = '!'; - if (ci->HasFlag(CI_FORBIDDEN)) - snprintf(buf, sizeof(buf), "%-20s [Forbidden]", ci->name.c_str()); - else if (ci->HasFlag(CI_SUSPENDED)) - snprintf(buf, sizeof(buf), "%-20s [Suspended]", ci->name.c_str()); + Anope::string buf; + if (ci->HasFlag(CI_SUSPENDED)) + buf = Anope::printf("%-20s [Suspended]", ci->name.c_str()); else - snprintf(buf, sizeof(buf), "%-20s %s", ci->name.c_str(), !ci->desc.empty() ? ci->desc.c_str() : ""); + buf = Anope::printf("%-20s %s", ci->name.c_str(), !ci->desc.empty() ? ci->desc.c_str() : ""); - source.Reply(" %c%s", noexpire_char, buf); + source.Reply(" %c%s", noexpire_char, buf.c_str()); } ++count; } diff --git a/modules/core/cs_main.cpp b/modules/core/cs_main.cpp index 20da089df..766f696a8 100644 --- a/modules/core/cs_main.cpp +++ b/modules/core/cs_main.cpp @@ -44,16 +44,9 @@ class ChanServBotInfo : public BotInfo ChannelInfo *ci = cs_findchan(param); if (ci) { - if (ci->HasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN)) + if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED)) { - u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str()); - Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name; - PopLanguage(); - return; - } - else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED)) - { - u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str()); + u->SendMessage(this, _(_(CHAN_X_SUSPENDED)), ci->name.c_str()); Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name; PopLanguage(); return; @@ -113,11 +106,6 @@ class ExpireCallback : public CallBack if (Config->CSSuspendExpire && Anope::CurTime - ci->last_used >= Config->CSSuspendExpire) expire = true; } - else if (ci->HasFlag(CI_FORBIDDEN)) - { - if (Config->CSForbidExpire && Anope::CurTime - ci->last_used >= Config->CSForbidExpire) - expire = true; - } else if (!ci->c && Anope::CurTime - ci->last_used >= Config->CSExpire) expire = true; @@ -132,9 +120,7 @@ class ExpireCallback : public CallBack continue; Anope::string extra; - if (ci->HasFlag(CI_FORBIDDEN)) - extra = "forbidden "; - else if (ci->HasFlag(CI_SUSPENDED)) + if (ci->HasFlag(CI_SUSPENDED)) extra = "suspended "; Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << ")"; diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp index e6430eb99..88ddabd86 100644 --- a/modules/core/cs_set_founder.cpp +++ b/modules/core/cs_set_founder.cpp @@ -43,11 +43,6 @@ class CommandCSSetFounder : public Command source.Reply(_(NICK_X_NOT_REGISTERED), params[1].c_str()); return MOD_CONT; } - else if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - return MOD_CONT; - } nc = na->nc; if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit")) diff --git a/modules/core/cs_set_successor.cpp b/modules/core/cs_set_successor.cpp index a9a1e7498..25ee2b098 100644 --- a/modules/core/cs_set_successor.cpp +++ b/modules/core/cs_set_successor.cpp @@ -46,11 +46,6 @@ class CommandCSSetSuccessor : public Command source.Reply(_(NICK_X_NOT_REGISTERED), params[1].c_str()); return MOD_CONT; } - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - return MOD_CONT; - } if (na->nc == ci->founder) { source.Reply(_("%s cannot be the successor on channel %s because he is its founder."), na->nick.c_str(), ci->name.c_str()); diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp index 374e44bc2..1836da858 100644 --- a/modules/core/cs_suspend.cpp +++ b/modules/core/cs_suspend.cpp @@ -37,20 +37,13 @@ class CommandCSSuspend : public Command return MOD_CONT; } - /* You should not SUSPEND a FORBIDEN channel */ - if (ci->HasFlag(CI_FORBIDDEN)) - { - source.Reply(_("Channel \002%s\002 may not be registered."), ci->name.c_str()); - return MOD_CONT; - } - if (readonly) source.Reply(_(READ_ONLY_MODE)); ci->SetFlag(CI_SUSPENDED); - ci->forbidby = u->nick; + ci->Extend("suspend_by", new ExtensibleItemRegular(u->nick)); if (!reason.empty()) - ci->forbidreason = reason; + ci->Extend("suspend_reason", new ExtensibleItemRegular(u->nick)); if (c) { @@ -115,11 +108,14 @@ class CommandCSUnSuspend : public Command return MOD_CONT; } - Log(LOG_ADMIN, u, this, ci) << " was suspended for: " << (!ci->forbidreason.empty() ? ci->forbidreason : "No reason"); + Anope::string by, reason; + ci->GetExtRegular("suspend_by", by); + ci->GetExtRegular("suspend_reason", reason); + Log(LOG_ADMIN, u, this, ci) << " which was suspended by " << by << " for: " << (!reason.empty() ? reason : "No reason"); ci->UnsetFlag(CI_SUSPENDED); - ci->forbidreason.clear(); - ci->forbidby.clear(); + ci->Shrink("suspend_by"); + ci->Shrink("suspend_reason"); source.Reply(_("Channel \002%s\002 is now released."), ci->name.c_str()); diff --git a/modules/core/cs_xop.cpp b/modules/core/cs_xop.cpp index 72471a868..666cb4da1 100644 --- a/modules/core/cs_xop.cpp +++ b/modules/core/cs_xop.cpp @@ -141,11 +141,6 @@ class XOPBase : public Command NickAlias *na = findnick(mask); if (!na && mask.find_first_of("!@*") == Anope::string::npos) mask += "!*@*"; - else if (na && na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - return MOD_CONT; - } access = ci->GetAccess(mask, 0, false); if (access) diff --git a/modules/core/db_mysql.cpp b/modules/core/db_mysql.cpp index 386e20740..746dd8f25 100644 --- a/modules/core/db_mysql.cpp +++ b/modules/core/db_mysql.cpp @@ -348,8 +348,6 @@ class DBMySQL : public Module ci->last_topic = r.Get(i, "last_topic"); ci->last_topic_setter = r.Get(i, "last_topic_setter"); ci->last_topic_time = r.Get(i, "last_topic_time").is_number_only() ? convertTo(r.Get(i, "last_topic_time")) : Anope::CurTime; - ci->forbidby = r.Get(i, "forbidby"); - ci->forbidreason = r.Get(i, "forbidreason"); ci->bantype = r.Get(i, "bantype").is_number_only() ? convertTo(r.Get(i, "bantype")) : 2; ci->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo(r.Get(i, "memomax")) : 20; ci->capsmin = r.Get(i, "capsmin").is_number_only() ? convertTo(r.Get(i, "capsmin")) : 0; @@ -1080,13 +1078,11 @@ class DBMySQL : public Module void OnChanForbidden(ChannelInfo *ci) { - SQLQuery query("INSERT INTO `anope_cs_info` (name, time_registered, last_used, flags, forbidby, forbidreason) VALUES (@name, @time_registered, @last_used, @flags, @forbidby, @forbidreason)"); + SQLQuery query("INSERT INTO `anope_cs_info` (name, time_registered, last_used, flags) VALUES (@name, @time_registered, @last_used, @flags)"); query.setValue("name", ci->name); query.setValue("time_registered", ci->time_registered); query.setValue("last_used", ci->last_used); query.setValue("flags", ToString(ci->ToString())); - query.setValue("forbidby", ci->forbidby); - query.setValue("forbidreason", ci->forbidreason); this->RunQuery(query); } @@ -1099,7 +1095,7 @@ class DBMySQL : public Module void OnChanRegistered(ChannelInfo *ci) { - SQLQuery query("INSERT INTO `anope_cs_info` (name, founder, successor, descr, time_registered, last_used, last_topic, last_topic_setter, last_topic_time, flags, forbidby, forbidreason, bantype, memomax, botnick, botflags, capsmin, capspercent, floodlines, floodsecs, repeattimes) VALUES(@name, @founder, @successor, @descr, @time_registered, @last_used, @last_topic_text, @last_topic_setter, @last_topic_time, @flags, @forbidby, @forbidreason, @bantype, @memomax, @botnick, @botflags, @capsmin, @capspercent, @floodlines, @floodsecs, @repeattimes) ON DUPLICATE KEY UPDATE founder=VALUES(founder), successor=VALUES(successor), descr=VALUES(descr), time_registered=VALUES(time_registered), last_used=VALUES(last_used), last_topic=VALUES(last_topic), last_topic_setter=VALUES(last_topic_setter), last_topic_time=VALUES(last_topic_time), flags=VALUES(flags), forbidby=VALUES(forbidby), forbidreason=VALUES(forbidreason), bantype=VALUES(bantype), memomax=VALUES(memomax), botnick=VALUES(botnick), botflags=VALUES(botflags), capsmin=VALUES(capsmin), capspercent=VALUES(capspercent), floodlines=VALUES(floodlines), floodsecs=VALUES(floodsecs), repeattimes=VALUES(repeattimes)"); + SQLQuery query("INSERT INTO `anope_cs_info` (name, founder, successor, descr, time_registered, last_used, last_topic, last_topic_setter, last_topic_time, flags, bantype, memomax, botnick, botflags, capsmin, capspercent, floodlines, floodsecs, repeattimes) VALUES(@name, @founder, @successor, @descr, @time_registered, @last_used, @last_topic_text, @last_topic_setter, @last_topic_time, @flags, @bantype, @memomax, @botnick, @botflags, @capsmin, @capspercent, @floodlines, @floodsecs, @repeattimes) ON DUPLICATE KEY UPDATE founder=VALUES(founder), successor=VALUES(successor), descr=VALUES(descr), time_registered=VALUES(time_registered), last_used=VALUES(last_used), last_topic=VALUES(last_topic), last_topic_setter=VALUES(last_topic_setter), last_topic_time=VALUES(last_topic_time), flags=VALUES(flags), bantype=VALUES(bantype), memomax=VALUES(memomax), botnick=VALUES(botnick), botflags=VALUES(botflags), capsmin=VALUES(capsmin), capspercent=VALUES(capspercent), floodlines=VALUES(floodlines), floodsecs=VALUES(floodsecs), repeattimes=VALUES(repeattimes)"); query.setValue("name", ci->name); query.setValue("founder", ci->founder ? ci->founder->display : ""); query.setValue("successor", ci->successor ? ci->successor->display : ""); @@ -1110,8 +1106,6 @@ class DBMySQL : public Module query.setValue("last_topic_setter", ci->last_topic_setter); query.setValue("last_topic_time", ci->last_topic_time); query.setValue("flags", ToString(ci->ToString())); - query.setValue("forbidby", ci->forbidby); - query.setValue("forbidreason", ci->forbidreason); query.setValue("bantype", ci->bantype); query.setValue("memomax", ci->memos.memomax); query.setValue("botnick", ci->bi ? ci->bi->nick : ""); @@ -1151,16 +1145,6 @@ class DBMySQL : public Module query.setValue("flags", ToString(ci->ToString())); query.setValue("name", ci->name); this->RunQuery(query); - - query = "UPDATE `anope_cs_info` SET `forbidby` = @forbidby WHERE `name` = @name"; - query.setValue("forbidby", ci->forbidby); - query.setValue("name", ci->name); - this->RunQuery(query); - - query = "UPDATE `anope_cs_info` SET `forbidreason` = @forbidreason WHERE `name` = @name"; - query.setValue("forbidreason", ci->forbidreason); - query.setValue("name", ci->name); - this->RunQuery(query); } void OnAkickAdd(ChannelInfo *ci, AutoKick *ak) diff --git a/modules/core/db_mysql_live.cpp b/modules/core/db_mysql_live.cpp index 04a9e53c6..4c7bd4f0b 100644 --- a/modules/core/db_mysql_live.cpp +++ b/modules/core/db_mysql_live.cpp @@ -46,8 +46,6 @@ static void ChanInfoUpdate(const SQLResult &res) ci->time_registered = convertTo(res.Get(0, "time_registered")); ci->ClearFlags(); ci->FromString(BuildStringVector(res.Get(0, "flags"))); - ci->forbidby = res.Get(0, "forbidby"); - ci->forbidreason = res.Get(0, "forbidreason"); ci->bantype = convertTo(res.Get(0, "bantype")); ci->memos.memomax = convertTo(res.Get(0, "memomax")); diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index a233f66f6..f194f3ae9 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -524,9 +524,7 @@ class DBPlain : public Module { for (unsigned j = 0, end = params.size(); j < end; ++j) { - if (params[j].equals_ci("FORBIDDEN")) - na->SetFlag(NS_FORBIDDEN); - else if (params[j].equals_ci("NOEXPIRE")) + if (params[j].equals_ci("NOEXPIRE")) na->SetFlag(NS_NO_EXPIRE); } } @@ -579,10 +577,10 @@ class DBPlain : public Module ci->last_topic_time = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; ci->last_topic = params[2]; } - else if (key.equals_ci("FORBID")) + else if (key.equals_ci("SUSPEND")) { - ci->forbidby = params[0]; - ci->forbidreason = params[1]; + ci->Extend("suspend_by", new ExtensibleItemRegular(params[0])); + ci->Extend("suspend_reason", new ExtensibleItemRegular(params[1])); } else if (key.equals_ci("ACCESS")) { @@ -803,8 +801,13 @@ class DBPlain : public Module db_buffer << endl; if (ci->FlagCount()) db_buffer << "MD FLAGS " << ToString(ci->ToString()) << endl; - if (ci->HasFlag(CI_FORBIDDEN)) - db_buffer << "MD FORBID " << ci->forbidby << " :" << ci->forbidreason << endl; + if (ci->HasFlag(CI_SUSPENDED)) + { + Anope::string by, reason; + ci->GetExtRegular("suspend_by", by); + ci->GetExtRegular("suspend_reason", reason); + db_buffer << "MD SUSPEND " << by << " :" << reason << endl; + } for (unsigned k = 0, end = ci->GetAccessCount(); k < end; ++k) db_buffer << "MD ACCESS " << ci->GetAccess(k)->GetMask() << " " << ci->GetAccess(k)->level << " " << ci->GetAccess(k)->last_seen << " " << ci->GetAccess(k)->creator << endl; for (unsigned k = 0, end = ci->GetAkickCount(); k < end; ++k) diff --git a/modules/core/hs_del.cpp b/modules/core/hs_del.cpp index b6dddf89c..ea27633b0 100644 --- a/modules/core/hs_del.cpp +++ b/modules/core/hs_del.cpp @@ -29,11 +29,6 @@ class CommandHSDel : public Command NickAlias *na = findnick(nick); if (na) { - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - return MOD_CONT; - } Log(LOG_ADMIN, u, this) << "for user " << na->nick; FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); na->hostinfo.RemoveVhost(); diff --git a/modules/core/hs_delall.cpp b/modules/core/hs_delall.cpp index c7e0d4cfd..d55b3a161 100644 --- a/modules/core/hs_delall.cpp +++ b/modules/core/hs_delall.cpp @@ -29,11 +29,6 @@ class CommandHSDelAll : public Command NickAlias *na = findnick(nick); if (na) { - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - return MOD_CONT; - } FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); NickCore *nc = na->nc; for (std::list::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it) diff --git a/modules/core/hs_set.cpp b/modules/core/hs_set.cpp index bb1be1d5b..9f2cb6526 100644 --- a/modules/core/hs_set.cpp +++ b/modules/core/hs_set.cpp @@ -76,12 +76,6 @@ class CommandHSSet : public Command NickAlias *na = findnick(nick); if ((na = findnick(nick))) { - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - return MOD_CONT; - } - Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; na->hostinfo.SetVhost(vIdent, hostmask, u->nick); diff --git a/modules/core/hs_setall.cpp b/modules/core/hs_setall.cpp index bc0d6d9cb..aef76d424 100644 --- a/modules/core/hs_setall.cpp +++ b/modules/core/hs_setall.cpp @@ -37,11 +37,6 @@ class CommandHSSetAll : public Command source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); return MOD_CONT; } - else if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - return MOD_CONT; - } Anope::string vIdent = myStrGetToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ if (!vIdent.empty()) diff --git a/modules/core/memoserv.h b/modules/core/memoserv.h index 3252a2a2b..f6ea4772b 100644 --- a/modules/core/memoserv.h +++ b/modules/core/memoserv.h @@ -19,10 +19,9 @@ class MemoServService : public Service /** Retrieve the memo info for a nick or channel * @param target Target * @param ischan Set to true if target is a channel - * @param isforbid Set to true if the target is forbidden * @return A memoinfo structure or NULL */ - virtual MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan, bool &isforbid) = 0; + virtual MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan) = 0; /** Sends a memo. * @param source The source of the memo, can be anythin. diff --git a/modules/core/ms_cancel.cpp b/modules/core/ms_cancel.cpp index f70888d32..178f62d2f 100644 --- a/modules/core/ms_cancel.cpp +++ b/modules/core/ms_cancel.cpp @@ -28,16 +28,11 @@ class CommandMSCancel : public Command const Anope::string &nname = params[0]; - bool ischan, isforbid; - MemoInfo *mi = memoserv->GetMemoInfo(nname, ischan, isforbid); + bool ischan; + MemoInfo *mi = memoserv->GetMemoInfo(nname, ischan); if (mi == NULL) - { - if (isforbid) - source.Reply(ischan ? _(CHAN_X_FORBIDDEN) : _(NICK_X_FORBIDDEN), nname.c_str()); - else - source.Reply(ischan ? _(CHAN_X_NOT_REGISTERED) : _(NICK_X_NOT_REGISTERED), nname.c_str()); - } + source.Reply(ischan ? _(CHAN_X_NOT_REGISTERED) : _(NICK_X_NOT_REGISTERED), nname.c_str()); else { for (int i = mi->memos.size() - 1; i >= 0; --i) diff --git a/modules/core/ms_check.cpp b/modules/core/ms_check.cpp index 6b56a66c0..49b7f8c07 100644 --- a/modules/core/ms_check.cpp +++ b/modules/core/ms_check.cpp @@ -37,12 +37,6 @@ class CommandMSCheck : public Command return MOD_CONT; } - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), recipient.c_str()); - return MOD_CONT; - } - MemoInfo *mi = &na->nc->memos; /* Okay, I know this looks strange but we wanna get the LAST memo, so we diff --git a/modules/core/ms_ignore.cpp b/modules/core/ms_ignore.cpp index f110bd345..45536d42f 100644 --- a/modules/core/ms_ignore.cpp +++ b/modules/core/ms_ignore.cpp @@ -37,15 +37,10 @@ class CommandMSIgnore : public Command channel = u->nick; } - bool ischan, isforbid; - MemoInfo *mi = memoserv->GetMemoInfo(channel, ischan, isforbid); + bool ischan; + MemoInfo *mi = memoserv->GetMemoInfo(channel, ischan); if (!mi) - { - if (isforbid) - source.Reply(ischan ? _(CHAN_X_FORBIDDEN) : _(NICK_X_FORBIDDEN), channel.c_str()); - else - source.Reply(ischan ? _(CHAN_X_NOT_REGISTERED) : _(NICK_X_NOT_REGISTERED), channel.c_str()); - } + source.Reply(ischan ? _(CHAN_X_NOT_REGISTERED) : _(NICK_X_NOT_REGISTERED), channel.c_str()); else if (ischan && !check_access(u, cs_findchan(channel), CA_MEMO)) source.Reply(_(ACCESS_DENIED)); else if (command.equals_ci("ADD") && !param.empty()) diff --git a/modules/core/ms_info.cpp b/modules/core/ms_info.cpp index 95e186e29..37ff64450 100644 --- a/modules/core/ms_info.cpp +++ b/modules/core/ms_info.cpp @@ -40,11 +40,6 @@ class CommandMSInfo : public Command source.Reply(_(NICK_X_NOT_REGISTERED), nname.c_str()); return MOD_CONT; } - else if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), nname.c_str()); - return MOD_CONT; - } mi = &na->nc->memos; hardmax = na->nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0; } diff --git a/modules/core/ms_main.cpp b/modules/core/ms_main.cpp index 39fc94b49..393c2b89e 100644 --- a/modules/core/ms_main.cpp +++ b/modules/core/ms_main.cpp @@ -39,29 +39,21 @@ class MyMemoServService : public MemoServService return MemoServ; } - MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan, bool &isforbid) + MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan) { - isforbid = false; - if (!target.empty() && target[0] == '#') { ischan = true; ChannelInfo *ci = cs_findchan(target); if (ci != NULL) - { - isforbid = ci->HasFlag(CI_FORBIDDEN); return &ci->memos; - } } else { ischan = false; NickAlias *na = findnick(target); if (na != NULL) - { - isforbid = na->HasFlag(NS_FORBIDDEN); return &na->nc->memos; - } } return NULL; @@ -69,10 +61,10 @@ class MyMemoServService : public MemoServService MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) { - bool ischan, isforbid; - MemoInfo *mi = this->GetMemoInfo(target, ischan, isforbid); + bool ischan; + MemoInfo *mi = this->GetMemoInfo(target, ischan); - if (mi == NULL || isforbid == true) + if (mi == NULL) return MEMO_INVALID_TARGET; User *sender = finduser(source); diff --git a/modules/core/ms_rsend.cpp b/modules/core/ms_rsend.cpp index 4aa53e17a..0cc3b2b79 100644 --- a/modules/core/ms_rsend.cpp +++ b/modules/core/ms_rsend.cpp @@ -57,8 +57,8 @@ class CommandMSRSend : public Command { source.Reply(_("Memo sent to \002%s\002."), name.c_str()); - bool ischan, isforbid; - MemoInfo *mi = memoserv->GetMemoInfo(nick, ischan, isforbid); + bool ischan; + MemoInfo *mi = memoserv->GetMemoInfo(nick, ischan); if (mi == NULL) throw CoreException("NULL mi in ms_rsend"); Memo *m = (mi->memos.size() ? mi->memos[mi->memos.size() - 1] : NULL); diff --git a/modules/core/ns_ajoin.cpp b/modules/core/ns_ajoin.cpp index 2cd34c8d1..52866c13a 100644 --- a/modules/core/ns_ajoin.cpp +++ b/modules/core/ns_ajoin.cpp @@ -143,7 +143,7 @@ class NSAJoin : public Module if (ci != NULL) { - if (ci->HasFlag(CI_SUSPENDED) || ci->HasFlag(CI_FORBIDDEN)) + if (ci->HasFlag(CI_SUSPENDED)) continue; } if (c != NULL) diff --git a/modules/core/ns_alist.cpp b/modules/core/ns_alist.cpp index 5ae5d570c..cf0807709 100644 --- a/modules/core/ns_alist.cpp +++ b/modules/core/ns_alist.cpp @@ -86,8 +86,6 @@ class CommandNSAList : public Command if (!na) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (min_level <= ACCESS_INVALID || min_level > ACCESS_FOUNDER) source.Reply(_(CHAN_ACCESS_LEVEL_RANGE), ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); else diff --git a/modules/core/ns_cert.cpp b/modules/core/ns_cert.cpp index 0029bfe34..213ddbe7c 100644 --- a/modules/core/ns_cert.cpp +++ b/modules/core/ns_cert.cpp @@ -195,7 +195,7 @@ class NSCert : public Module return; if (u->IsIdentified() && u->Account() == na->nc) return; - if (na->HasFlag(NS_FORBIDDEN) || na->nc->HasFlag(NI_SUSPENDED)) + if (na->nc->HasFlag(NI_SUSPENDED)) return; if (!na->nc->FindCert(u->fingerprint)) return; diff --git a/modules/core/ns_drop.cpp b/modules/core/ns_drop.cpp index 80ae23d9e..ff6078002 100644 --- a/modules/core/ns_drop.cpp +++ b/modules/core/ns_drop.cpp @@ -61,12 +61,6 @@ class CommandNSDrop : public Command if (readonly) source.Reply(_(READ_ONLY_MODE)); - if (ircd->sqline && na->HasFlag(NS_FORBIDDEN)) - { - XLine x(na->nick); - ircdproto->SendSQLineDel(&x); - } - FOREACH_MOD(I_OnNickDrop, OnNickDrop(u, na)); Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, u, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; diff --git a/modules/core/ns_forbid.cpp b/modules/core/ns_forbid.cpp deleted file mode 100644 index 8fd433123..000000000 --- a/modules/core/ns_forbid.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* NickServ core functions - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" -#include "nickserv.h" - -class CommandNSForbid : public Command -{ - public: - CommandNSForbid() : Command("FORBID", 1, 2, "nickserv/forbid") - { - this->SetDesc(_("Prevents a nickname from being registered")); - } - - CommandReturn Execute(CommandSource &source, const std::vector ¶ms) - { - User *u = source.u; - const Anope::string &nick = params[0]; - const Anope::string &reason = params.size() > 1 ? params[1] : ""; - - /* Assumes that permission checking has already been done. */ - if (Config->ForceForbidReason && reason.empty()) - { - this->OnSyntaxError(source, ""); - return MOD_CONT; - } - - if (readonly) - source.Reply(_(READ_ONLY_MODE)); - if (!ircdproto->IsNickValid(nick)) - { - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - return MOD_CONT; - } - - NickAlias *na = findnick(nick); - if (na) - { - if (Config->NSSecureAdmins && na->nc->IsServicesOper()) - { - source.Reply(_(ACCESS_DENIED)); - return MOD_CONT; - } - delete na; - } - NickCore *nc = new NickCore(nick); - nc->SetFlag(NI_FORBIDDEN); - na = new NickAlias(nick, nc); - na->SetFlag(NS_FORBIDDEN); - na->last_usermask = u->nick; - if (!reason.empty()) - na->last_realname = reason; - - User *curr = finduser(na->nick); - - if (curr) - { - curr->SendMessage(nickserv->Bot(), _(FORCENICKCHANGE_NOW)); - curr->Collide(na); - } - - if (ircd->sqline) - { - XLine x(na->nick, !reason.empty() ? reason : "Forbidden"); - ircdproto->SendSQLine(NULL, &x); - } - - Log(LOG_ADMIN, u, this) << "to forbid nick " << nick; - source.Reply(_("Nick \002%s\002 is now forbidden."), nick.c_str()); - - FOREACH_MOD(I_OnNickForbidden, OnNickForbidden(na)); - - return MOD_CONT; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002FORBID \037nickname\037 [\037reason\037]\002\n" - " \n" - "Disallows a nickname from being registered or used by\n" - "anyone. May be cancelled by dropping the nick.\n" - " \n" - "On certain networks, reason is required.")); - return true; - } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - SyntaxError(source, "FORBID", Config->ForceForbidReason ? _("FORBID \037nickname\037 \037reason\037") : _("FORBID \037nickname\037 [\037reason\037]")); - } -}; - -class NSForbid : public Module -{ - CommandNSForbid commandnsforbid; - - public: - NSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) - { - this->SetAuthor("Anope"); - - if (!nickserv) - throw ModuleException("NickServ is not loaded!"); - - this->AddCommand(nickserv->Bot(), &commandnsforbid); - } -}; - -MODULE_INIT(NSForbid) diff --git a/modules/core/ns_getpass.cpp b/modules/core/ns_getpass.cpp index e66cf8ff7..3d7ceb3ae 100644 --- a/modules/core/ns_getpass.cpp +++ b/modules/core/ns_getpass.cpp @@ -31,8 +31,6 @@ class CommandNSGetPass : public Command if (!(na = findnick(nick))) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (Config->NSSecureAdmins && na->nc->IsServicesOper()) source.Reply(_(ACCESS_DENIED)); else diff --git a/modules/core/ns_ghost.cpp b/modules/core/ns_ghost.cpp index 14a89a85c..0a8306734 100644 --- a/modules/core/ns_ghost.cpp +++ b/modules/core/ns_ghost.cpp @@ -36,8 +36,6 @@ class CommandNSGhost : public Command source.Reply(_(NICK_X_NOT_IN_USE), nick.c_str()); else if (!na) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str()); else if (nick.equals_ci(u->nick)) diff --git a/modules/core/ns_group.cpp b/modules/core/ns_group.cpp index 2be6f7b6b..ef88ab656 100644 --- a/modules/core/ns_group.cpp +++ b/modules/core/ns_group.cpp @@ -36,12 +36,6 @@ class CommandNSGroup : public Command return MOD_CONT; } - if (!ircdproto->IsNickValid(u->nick)) - { - source.Reply(_(NICK_X_FORBIDDEN), u->nick.c_str()); - return MOD_CONT; - } - if (Config->RestrictOperNicks) for (unsigned i = 0; i < Config->Opers.size(); ++i) { @@ -69,8 +63,6 @@ class CommandNSGroup : public Command Log(LOG_COMMAND, u, this) << "tried to use GROUP for SUSPENDED nick " << target->nick; source.Reply(_(NICK_X_SUSPENDED), target->nick.c_str()); } - else if (target->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); else if (na && target->nc == na->nc) source.Reply(_("You are already a member of the group of \002%s\002."), target->nick.c_str()); else if (na && na->nc != u->Account()) diff --git a/modules/core/ns_identify.cpp b/modules/core/ns_identify.cpp index a9d935966..6eb5c7e5c 100644 --- a/modules/core/ns_identify.cpp +++ b/modules/core/ns_identify.cpp @@ -31,9 +31,7 @@ class CommandNSIdentify : public Command Anope::string pass = params[params.size() - 1]; NickAlias *na = findnick(nick); - if (na && na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - else if (na && na->nc->HasFlag(NI_SUSPENDED)) + if (na && na->nc->HasFlag(NI_SUSPENDED)) source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str()); else if (u->Account() && na && u->Account() == na->nc) source.Reply(_("You are already identified.")); diff --git a/modules/core/ns_info.cpp b/modules/core/ns_info.cpp index 6e16099a9..584ea67bf 100644 --- a/modules/core/ns_info.cpp +++ b/modules/core/ns_info.cpp @@ -50,13 +50,6 @@ class CommandNSInfo : public Command else source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); } - else if (na->HasFlag(NS_FORBIDDEN)) - { - if (u->HasMode(UMODE_OPER) && !na->last_usermask.empty()) - source.Reply(_(NICK_X_FORBIDDEN_OPER), nick.c_str(), na->last_usermask.c_str(), !na->last_realname.empty() ? na->last_realname.c_str() : _(NO_REASON)); - else - source.Reply(_(NICK_X_FORBIDDEN), nick.c_str()); - } else { bool nick_online = false, show_hidden = false; diff --git a/modules/core/ns_list.cpp b/modules/core/ns_list.cpp index 7d7844def..c4536a613 100644 --- a/modules/core/ns_list.cpp +++ b/modules/core/ns_list.cpp @@ -24,31 +24,17 @@ class CommandNSList : public Command CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - /* SADMINS can search for nicks based on their NS_FORBIDDEN and NS_NO_EXPIRE - * status. The keywords FORBIDDEN and NOEXPIRE represent these two states - * respectively. These keywords should be included after the search pattern. - * Multiple keywords are accepted and should be separated by spaces. Only one - * of the keywords needs to match a nick's state for the nick to be displayed. - * Forbidden nicks can be identified by "[Forbidden]" appearing in the last - * seen address field. Nicks with NOEXPIRE set are preceeded by a "!". Only - * SADMINS will be shown forbidden nicks and the "!" indicator. - * Syntax for sadmins: LIST pattern [FORBIDDEN] [NOEXPIRE] - * -TheShadow - * - * UPDATE: SUSPENDED keyword is now accepted as well. - */ User *u = source.u; Anope::string pattern = params[0]; const NickCore *mync; unsigned nnicks; - char buf[BUFSIZE]; bool is_servadmin = u->IsServicesOper(); char noexpire_char = ' '; int count = 0, from = 0, to = 0; - bool suspended, nsnoexpire, forbidden, unconfirmed; + bool suspended, nsnoexpire, unconfirmed; - suspended = nsnoexpire = forbidden = unconfirmed = false; + suspended = nsnoexpire = unconfirmed = false; if (Config->NSListOpersOnly && !u->HasMode(UMODE_OPER)) /* reverse the help logic */ { @@ -83,8 +69,6 @@ class CommandNSList : public Command spacesepstream keywords(params[1]); while (keywords.GetToken(keyword)) { - if (keyword.equals_ci("FORBIDDEN")) - forbidden = true; if (keyword.equals_ci("NOEXPIRE")) nsnoexpire = true; if (keyword.equals_ci("SUSPENDED")) @@ -101,12 +85,8 @@ class CommandNSList : public Command { NickAlias *na = it->second; - /* Don't show private and forbidden nicks to non-services admins. */ - if (na->HasFlag(NS_FORBIDDEN) && !is_servadmin) - continue; - else if (na->nc->HasFlag(NI_PRIVATE) && !is_servadmin && na->nc != mync) - continue; - else if (forbidden && !na->HasFlag(NS_FORBIDDEN)) + /* Don't show private nicks to non-services admins. */ + if (na->nc->HasFlag(NI_PRIVATE) && !is_servadmin && na->nc != mync) continue; else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE)) continue; @@ -118,7 +98,7 @@ class CommandNSList : public Command /* We no longer compare the pattern against the output buffer. * Instead we build a nice nick!user@host buffer to compare. * The output is then generated separately. -TheShadow */ - snprintf(buf, sizeof(buf), "%s!%s", na->nick.c_str(), !na->last_usermask.empty() && !na->HasFlag(NS_FORBIDDEN) ? na->last_usermask.c_str() : "*@*"); + Anope::string buf = Anope::printf("%s!%s", na->nick.c_str(), !na->last_usermask.empty() ? na->last_usermask.c_str() : "*@*"); if (na->nick.equals_ci(pattern) || Anope::Match(buf, pattern)) { if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= Config->NSListMax) @@ -128,16 +108,14 @@ class CommandNSList : public Command else noexpire_char = ' '; if (na->nc->HasFlag(NI_HIDE_MASK) && !is_servadmin && na->nc != mync) - snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick.c_str()); + buf = Anope::printf("%-20s [Hostname Hidden]", na->nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) - snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick.c_str()); + buf = Anope::printf("%-20s [Suspended]", na->nick.c_str()); else if (na->nc->HasFlag(NI_UNCONFIRMED)) - snprintf(buf, sizeof(buf), "%-20s [Unconfirmed]", na->nick.c_str()); + buf = Anope::printf("%-20s [Unconfirmed]", na->nick.c_str()); else - snprintf(buf, sizeof(buf), "%-20s %s", na->nick.c_str(), na->last_usermask.c_str()); - source.Reply(" %c%s", noexpire_char, buf); + buf = Anope::printf("%-20s %s", na->nick.c_str(), na->last_usermask.c_str()); + source.Reply(" %c%s", noexpire_char, buf.c_str()); } ++count; } @@ -152,7 +130,7 @@ class CommandNSList : public Command { User *u = source.u; if (u->IsServicesOper()) - source.Reply(_("Syntax: \002LIST \037pattern\037 [FORBIDDEN] [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]\002\n" + source.Reply(_("Syntax: \002LIST \037pattern\037 [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]\002\n" " \n" "Lists all registered nicknames which match the given\n" "pattern, in \037nick!user@host\037 format. Nicks with the \002PRIVATE\002\n" @@ -160,8 +138,8 @@ class CommandNSList : public Command "with the \002NOEXPIRE\002 option set will have a \002!\002 appended to\n" "the nickname for Services Operators.\n" " \n" - "If the FORBIDDEN, SUSPENDED, NOEXPIRE or UNCONFIRMED options are given, only\n" - "nicks which, respectively, are FORBIDDEN, SUSPENDED, UNCONFIRMED or have the\n" + "If the SUSPENDED, NOEXPIRE or UNCONFIRMED options are given, only\n" + "nicks which, respectively, are SUSPENDED, UNCONFIRMED or have the\n" "NOEXPIRE flag set will be displayed. If multiple options are\n" "given, all nicks matching at least one option will be displayed.\n" "These options are limited to \037Services Operators\037. \n" @@ -203,7 +181,7 @@ class CommandNSList : public Command { User *u = source.u; if (u->IsServicesOper()) - SyntaxError(source, "LIST", _("LIST \037pattern\037 [FORBIDDEN] [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]")); + SyntaxError(source, "LIST", _("LIST \037pattern\037 [SUSPENDED] [NOEXPIRE] [UNCONFIRMED]")); else SyntaxError(source, "LIST", _(NICK_LIST_SYNTAX)); } diff --git a/modules/core/ns_main.cpp b/modules/core/ns_main.cpp index ecb7e1944..25960e023 100644 --- a/modules/core/ns_main.cpp +++ b/modules/core/ns_main.cpp @@ -32,13 +32,6 @@ class MyNickServService : public NickServService if (!na) return; - if (na->HasFlag(NS_FORBIDDEN)) - { - u->SendMessage(NickServ, _("This nickname may not be used. Please choose another one.")); - u->Collide(na); - return; - } - if (na->nc->HasFlag(NI_SUSPENDED)) { u->SendMessage(NickServ, _(NICK_X_SUSPENDED), u->nick.c_str()); @@ -121,11 +114,6 @@ class ExpireCallback : public CallBack if (Config->NSSuspendExpire && Anope::CurTime - na->last_seen >= Config->NSSuspendExpire) expire = true; } - else if (na->HasFlag(NS_FORBIDDEN)) - { - if (Config->NSForbidExpire && Anope::CurTime - na->last_seen >= Config->NSForbidExpire) - expire = true; - } else if (Config->NSExpire && Anope::CurTime - na->last_seen >= Config->NSExpire) expire = true; if (na->HasFlag(NS_NO_EXPIRE)) @@ -138,9 +126,7 @@ class ExpireCallback : public CallBack if (MOD_RESULT == EVENT_STOP) continue; Anope::string extra; - if (na->HasFlag(NS_FORBIDDEN)) - extra = "forbidden "; - else if (na->nc->HasFlag(NI_SUSPENDED)) + if (na->nc->HasFlag(NI_SUSPENDED)) extra = "suspended "; Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; FOREACH_MOD(I_OnNickExpire, OnNickExpire(na)); diff --git a/modules/core/ns_recover.cpp b/modules/core/ns_recover.cpp index 2da749296..bbac98e09 100644 --- a/modules/core/ns_recover.cpp +++ b/modules/core/ns_recover.cpp @@ -36,8 +36,6 @@ class CommandNSRecover : public Command source.Reply(_(NICK_X_NOT_IN_USE), nick.c_str()); else if (!(na = findnick(u2->nick))) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str()); else if (nick.equals_ci(u->nick)) diff --git a/modules/core/ns_register.cpp b/modules/core/ns_register.cpp index 8927a9aa2..e6b56143b 100644 --- a/modules/core/ns_register.cpp +++ b/modules/core/ns_register.cpp @@ -129,12 +129,6 @@ class CommandNSRegister : public Command return MOD_CONT; } - if (!ircdproto->IsNickValid(u->nick)) - { - source.Reply(_(NICK_X_FORBIDDEN), u->nick.c_str()); - return MOD_CONT; - } - if (Config->RestrictOperNicks) for (unsigned i = 0; i < Config->Opers.size(); ++i) { @@ -152,16 +146,7 @@ class CommandNSRegister : public Command else if (Anope::CurTime < u->lastnickreg + Config->NSRegDelay) source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + Config->NSRegDelay) - Anope::CurTime); else if ((na = findnick(u->nick))) - { - /* i.e. there's already such a nick regged */ - if (na->HasFlag(NS_FORBIDDEN)) - { - Log(nickserv->Bot()) << u->GetMask() << " tried to register FORBIDden nick " << u->nick; - source.Reply(_(NICK_CANNOT_BE_REGISTERED), u->nick.c_str()); - } - else - source.Reply(_(NICK_ALREADY_REGISTERED), u->nick.c_str()); - } + source.Reply(_(NICK_ALREADY_REGISTERED), u->nick.c_str()); else if (pass.equals_ci(u->nick) || (Config->StrictPasswords && pass.length() < 5)) source.Reply(_(MORE_OBSCURE_PASSWORD)); else if (pass.length() > Config->PassLen) diff --git a/modules/core/ns_release.cpp b/modules/core/ns_release.cpp index 98d2b4645..c22efebad 100644 --- a/modules/core/ns_release.cpp +++ b/modules/core/ns_release.cpp @@ -32,8 +32,6 @@ class CommandNSRelease : public Command if (!(na = findnick(nick))) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str()); else if (!na->HasFlag(NS_HELD)) diff --git a/modules/core/ns_resetpass.cpp b/modules/core/ns_resetpass.cpp index 983800d0a..d84f12e24 100644 --- a/modules/core/ns_resetpass.cpp +++ b/modules/core/ns_resetpass.cpp @@ -34,8 +34,6 @@ class CommandNSResetPass : public Command source.Reply(_(ACCESS_DENIED)); else if (!(na = findnick(params[0]))) source.Reply(_(NICK_X_NOT_REGISTERED), params[0].c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else { if (SendResetEmail(u, na)) diff --git a/modules/core/ns_saset.cpp b/modules/core/ns_saset.cpp index d466af7c3..c8915c38b 100644 --- a/modules/core/ns_saset.cpp +++ b/modules/core/ns_saset.cpp @@ -45,8 +45,6 @@ class CommandNSSASet : public Command NickAlias *na = findnick(nick); if (!na) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str()); else diff --git a/modules/core/ns_sendpass.cpp b/modules/core/ns_sendpass.cpp index a7501e438..47e8d6a82 100644 --- a/modules/core/ns_sendpass.cpp +++ b/modules/core/ns_sendpass.cpp @@ -35,8 +35,6 @@ class CommandNSSendPass : public Command source.Reply(_(ACCESS_DENIED)); else if (!(na = findnick(nick))) source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); - else if (na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); else { Anope::string tmp_pass; diff --git a/modules/core/ns_suspend.cpp b/modules/core/ns_suspend.cpp index 34a9165a2..3764f9dc6 100644 --- a/modules/core/ns_suspend.cpp +++ b/modules/core/ns_suspend.cpp @@ -42,12 +42,6 @@ class CommandNSSuspend : public Command return MOD_CONT; } - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - return MOD_CONT; - } - if (Config->NSSecureAdmins && na->nc->IsServicesOper()) { source.Reply(_(ACCESS_DENIED)); @@ -124,12 +118,6 @@ class CommandNSUnSuspend : public Command return MOD_CONT; } - if (na->HasFlag(NS_FORBIDDEN)) - { - source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str()); - return MOD_CONT; - } - if (Config->NSSecureAdmins && na->nc->IsServicesOper()) { source.Reply(_(ACCESS_DENIED)); diff --git a/modules/core/os_forbid.cpp b/modules/core/os_forbid.cpp new file mode 100644 index 000000000..26314d966 --- /dev/null +++ b/modules/core/os_forbid.cpp @@ -0,0 +1,344 @@ +/* OperServ core functions + * + * (C) 2003-2011 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +/*************************************************************************/ + +#include "module.h" +#include "operserv.h" +#include "os_forbid.h" + +class MyForbidService : public ForbidService +{ + std::vector forbidData; + + public: + MyForbidService(Module *m) : ForbidService(m) { } + + void AddForbid(ForbidData *d) + { + this->forbidData.push_back(d); + } + + void RemoveForbid(ForbidData *d) + { + std::vector::iterator it = std::find(this->forbidData.begin(), this->forbidData.end(), d); + if (it != this->forbidData.end()) + this->forbidData.erase(it); + delete d; + } + + ForbidData *FindForbid(const Anope::string &mask, ForbidType type) + { + const std::vector &forbids = this->GetForbids(); + for (unsigned i = forbids.size(); i > 0; --i) + { + ForbidData *d = this->forbidData[i - 1]; + + if ((type == FT_NONE || type == d->type) && Anope::Match(mask, d->mask)) + return d; + } + return NULL; + } + + const std::vector &GetForbids() + { + for (unsigned i = this->forbidData.size(); i > 0; --i) + { + ForbidData *d = this->forbidData[i - 1]; + + if (d->expires && Anope::CurTime >= d->expires) + { + Anope::string type = "none"; + if (d->type == FT_NICK) + type = "nick"; + else if (d->type == FT_CHAN) + type = "chan"; + else if (d->type == FT_EMAIL) + type = "email"; + + Log(operserv->Bot(), Config->s_OperServ + "/forbid") << "Expiring forbid for " << d->mask << " type " << type; + this->forbidData.erase(this->forbidData.begin() + i - 1); + delete d; + } + } + + return this->forbidData; + } +}; + +class CommandOSForbid : public Command +{ + service_reference fs; + public: + CommandOSForbid() : Command("FORBID", 1, 5, "operserv/forbid"), fs("forbid") + { + this->SetDesc(_("Forbid usage of nicknames, channels, and emails")); + } + + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) + { + if (!this->fs) + return MOD_CONT; + + const Anope::string &command = params[0]; + const Anope::string &subcommand = params.size() > 1 ? params[1] : ""; + + ForbidType type = FT_NONE; + if (subcommand.equals_ci("NICK")) + type = FT_NICK; + else if (subcommand.equals_ci("CHAN")) + type = FT_CHAN; + else if (subcommand.equals_ci("EMAIL")) + type = FT_EMAIL; + + if (command.equals_ci("ADD") && params.size() > 2 && type != FT_NONE) + { + const Anope::string &expiry = params[2][0] == '+' ? params[2] : ""; + const Anope::string &entry = params.size() > 3 && !expiry.empty() ? params[3] : params[2]; + Anope::string reason = !expiry.empty() && params.size() > 4 ? params[4] : (params.size() > 3 ? params[3] : ""); + + time_t expiryt = 0; + if (!expiry.empty()) + { + expiryt = dotime(expiry); + if (expiryt) + expiryt += Anope::CurTime; + } + + ForbidData *d = this->fs->FindForbid(entry, type); + bool created = false; + if (d == NULL) + { + d = new ForbidData(); + created = true; + } + + d->mask = entry; + d->creator = source.u->nick; + d->reason = reason; + d->created = Anope::CurTime; + d->expires = expiryt; + d->type = type; + if (created) + this->fs->AddForbid(d); + + Log(LOG_ADMIN, source.u, this) << "to add a forbid on " << entry << " of type " << subcommand; + source.Reply(_("Added a%s forbid on %s to expire on %s"), type == FT_CHAN ? "n" : "", entry.c_str(), d->expires ? do_strftime(d->expires).c_str() : "never"); + } + else if (command.equals_ci("DEL") && params.size() > 2 && type != FT_NONE) + { + const Anope::string &entry = params[2]; + + ForbidData *d = this->fs->FindForbid(entry, type); + if (d != NULL) + { + Log(LOG_ADMIN, source.u, this) << "to remove forbid " << d->mask << " of type " << subcommand; + source.Reply(_("%s deleted from the %s forbid list."), d->mask.c_str(), subcommand.c_str()); + } + else + source.Reply(_("Forbid on %s was not found."), entry.c_str()); + } + else if (command.equals_ci("LIST")) + { + const std::vector &forbids = this->fs->GetForbids(); + if (forbids.empty()) + source.Reply(_("Forbid list is empty.")); + else + { + source.Reply(_("Forbid list:")); + source.Reply(_("Mask Type Reason")); + + for (unsigned i = 0; i < forbids.size(); ++i) + { + ForbidData *d = forbids[i]; + + Anope::string ftype; + if (d->type == FT_NICK) + ftype = "NICK"; + else if (d->type == FT_CHAN) + ftype = "CHAN"; + else if (d->type == FT_EMAIL) + ftype = "EMAIL"; + else + continue; + + source.Reply("%-10s %-5s %s", d->mask.c_str(), ftype.c_str(), d->reason.c_str()); + source.Reply(_("By %s, expires on %s"), d->creator.c_str(), d->expires ? do_strftime(d->expires).c_str() : "never"); + } + + source.Reply(_("End of forbid list.")); + } + } + else + this->OnSyntaxError(source, command); + + return MOD_CONT; + } + + bool OnHelp(CommandSource &source, const Anope::string &subcommand) + { + source.Reply(_("Syntax: \002FORBID ADD {NICK|CHAN|EMAIL} [+\037expiry\037] \037entry\037\002 [\037reason\037]\n" + " \002FORBID DEL {NICK|CHAN|EMAIL} \037entry\037\002\n" + " \002FORBID LIST (NICK|CHAN|EMAIL)" + "\n" + "Forbid allows you to forbid usage of certain nicknames, channels,\n" + "and email addresses. Wildcards are accepted for all entries.")); + return true; + } + + void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) + { + SyntaxError(source, "FORBID", _("FORBID {ADD|DEL|LIST} {NICK|CHAN|EMAIL} [+\037expiry\037] \037entry\037 [\037reason\037]")); + } +}; + +class OSForbid : public Module +{ + MyForbidService forbidService; + CommandOSForbid commandosforbid; + + public: + OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), forbidService(this) + { + this->SetAuthor("Anope"); + + if (!operserv) + throw ModuleException("OperServ is not loaded!"); + + Implementation i[] = { I_OnUserConnect, I_OnUserNickChange, I_OnJoinChannel, I_OnPreCommand, I_OnDatabaseWrite, I_OnDatabaseRead }; + ModuleManager::Attach(i, this, 6); + + ModuleManager::RegisterService(&this->forbidService); + + this->AddCommand(operserv->Bot(), &commandosforbid); + } + + void OnUserConnect(dynamic_reference &u, bool &exempt) + { + if (!u || exempt || !operserv) + return; + + this->OnUserNickChange(u, ""); + } + + void OnUserNickChange(User *u, const Anope::string &) + { + if (!operserv || u->HasMode(UMODE_OPER)) + return; + + ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK); + if (d != NULL) + { + if (d->reason.empty()) + u->SendMessage(operserv->Bot(), _("This nickname has been forbidden.")); + else + u->SendMessage(operserv->Bot(), _("This nickname has been forbidden: %s"), d->reason.c_str()); + u->Collide(NULL); + } + } + + void OnJoinChannel(User *u, Channel *c) + { + if (!operserv || u->HasMode(UMODE_OPER)) + return; + + ForbidData *d = this->forbidService.FindForbid(c->name, FT_CHAN); + if (d != NULL) + { + if (!c->HasFlag(CH_INHABIT)) + { + /* Join ChanServ and set a timer for this channel to part ChanServ later */ + new ChanServTimer(c); + + /* Set +si to prevent rejoin */ + c->SetMode(NULL, CMODE_NOEXTERNAL); + c->SetMode(NULL, CMODE_TOPIC); + c->SetMode(NULL, CMODE_SECRET); + c->SetMode(NULL, CMODE_INVITE); + } + + if (d->reason.empty()) + c->Kick(operserv->Bot(), u, _("This channel has been forbidden.")); + else + c->Kick(operserv->Bot(), u, _("This channel has been forbidden: %s"), d->reason.c_str()); + } + } + + EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector ¶ms) + { + if (source.u->HasMode(UMODE_OPER)) + return EVEMT_CONTINUE; + else if (command->service->nick == Config->s_NickServ && command->name == "REGISTER" && params.size() > 1) + { + ForbidData *d = this->forbidService.FindForbid(params[1], FT_EMAIL); + if (d != NULL) + { + source.Reply("Your email address is not allowed, choose a different one."); + return EVENT_STOP; + } + } + else if (command->service->nick == Config->s_NickServ && command->name == "SET" && params.size() > 2 && params[0].equals_ci("EMAIL")) + { + ForbidData *d =this->forbidService.FindForbid(params[1], FT_EMAIL); + if (d != NULL) + { + source.Reply("Your email address is not allowed, choose a different one."); + return EVENT_STOP; + } + } + + return EVENT_CONTINUE; + } + + void OnDatabaseWrite(void (*Write)(const Anope::string &)) + { + std::vector forbids = this->forbidService.GetForbids(); + for (unsigned i = 0; i < forbids.size(); ++i) + { + ForbidData *f = forbids[i]; + Anope::string ftype; + if (f->type == FT_NICK) + ftype = "NICK"; + else if (f->type == FT_CHAN) + ftype = "CHAN"; + else if (f->type == FT_EMAIL) + ftype = "EMAIL"; + Write("FORBID " + f->mask + " " + f->creator + " " + stringify(f->created) + " " + stringify(f->expires) + " " + ftype + " " + f->reason); + } + } + + EventReturn OnDatabaseRead(const std::vector ¶ms) + { + if (params.size() > 5 && params[0] == "FORBID") + { + ForbidData *f = new ForbidData(); + f->mask = params[1]; + f->creator = params[2]; + f->created = convertTo(params[3]); + f->expires = convertTo(params[4]); + if (params[5] == "NICK") + f->type = FT_NICK; + else if (params[5] == "CHAN") + f->type = FT_CHAN; + else if (params[5] == "EMAIL") + f->type = FT_EMAIL; + else + f->type = FT_NONE; + f->reason = params.size() > 6 ? params[6] : ""; + + this->forbidService.AddForbid(f); + } + + return EVENT_CONTINUE; + } +}; + +MODULE_INIT(OSForbid) diff --git a/modules/core/os_forbid.h b/modules/core/os_forbid.h new file mode 100644 index 000000000..b91aa3be8 --- /dev/null +++ b/modules/core/os_forbid.h @@ -0,0 +1,37 @@ +#ifndef OS_FORBID_H +#define OS_FORBID_H + +enum ForbidType +{ + FT_NONE, + FT_NICK, + FT_CHAN, + FT_EMAIL +}; + +struct ForbidData +{ + Anope::string mask; + Anope::string creator; + Anope::string reason; + time_t created; + time_t expires; + ForbidType type; +}; + +class ForbidService : public Service +{ + public: + ForbidService(Module *m) : Service(m, "forbid") { } + + virtual void AddForbid(ForbidData *d) = 0; + + virtual void RemoveForbid(ForbidData *d) = 0; + + virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0; + + virtual const std::vector &GetForbids() = 0; +}; + +#endif + diff --git a/modules/core/os_session.cpp b/modules/core/os_session.cpp index 80df50391..3926fbee1 100644 --- a/modules/core/os_session.cpp +++ b/modules/core/os_session.cpp @@ -17,6 +17,77 @@ static service_reference sessionservice("session"); +class MySessionService : public SessionService +{ + SessionMap Sessions; + ExceptionVector Exceptions; + public: + MySessionService(Module *m) : SessionService(m) { } + + void AddException(Exception *e) + { + this->Exceptions.push_back(e); + } + + void DelException(Exception *e) + { + ExceptionVector::iterator it = std::find(this->Exceptions.begin(), this->Exceptions.end(), e); + if (it != this->Exceptions.end()) + this->Exceptions.erase(it); + } + + Exception *FindException(User *u) + { + for (std::vector::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it) + { + Exception *e = *it; + if (Anope::Match(u->host, e->mask) || (u->ip() && Anope::Match(u->ip.addr(), e->mask))) + return e; + } + return NULL; + } + + Exception *FindException(const Anope::string &host) + { + for (std::vector::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it) + { + Exception *e = *it; + if (Anope::Match(host, e->mask)) + return e; + } + + return NULL; + } + + ExceptionVector &GetExceptions() + { + return this->Exceptions; + } + + void AddSession(Session *s) + { + this->Sessions[s->host] = s; + } + + void DelSession(Session *s) + { + this->Sessions.erase(s->host); + } + + Session *FindSession(const Anope::string &mask) + { + SessionMap::iterator it = this->Sessions.find(mask); + if (it != this->Sessions.end()) + return it->second; + return NULL; + } + + SessionMap &GetSessions() + { + return this->Sessions; + } +}; + class ExpireTimer : public Timer { public: @@ -566,14 +637,14 @@ class CommandOSException : public Command class OSSession : public Module { - SessionService ss; + MySessionService ss; ExpireTimer expiretimer; CommandOSSession commandossession; CommandOSException commandosexception; void AddSession(User *u, bool exempt) { - Session *session = sessionservice->FindSession(u->host); + Session *session = this->ss.FindSession(u->host); if (session) { @@ -581,7 +652,7 @@ class OSSession : public Module if (Config->DefSessionLimit && session->count >= Config->DefSessionLimit) { kill = true; - Exception *exception = sessionservice->FindException(u); + Exception *exception = this->ss.FindException(u); if (exception) { kill = false; @@ -625,13 +696,13 @@ class OSSession : public Module session->count = 1; session->hits = 0; - sessionservice->AddSession(session); + this->ss.AddSession(session); } } void DelSession(User *u) { - Session *session = sessionservice->FindSession(u->host); + Session *session = this->ss.FindSession(u->host); if (!session) { if (debug) @@ -645,7 +716,7 @@ class OSSession : public Module return; } - sessionservice->DelSession(session); + this->ss.DelSession(session); delete session; } diff --git a/modules/core/os_session.h b/modules/core/os_session.h index e08ed70fa..faab37934 100644 --- a/modules/core/os_session.h +++ b/modules/core/os_session.h @@ -6,74 +6,26 @@ class SessionService : public Service public: typedef Anope::map SessionMap; typedef std::vector ExceptionVector; - private: - SessionMap Sessions; - ExceptionVector Exceptions; - public: + SessionService(Module *m) : Service(m, "session") { } - void AddException(Exception *e) - { - this->Exceptions.push_back(e); - } + virtual void AddException(Exception *e) = 0; - void DelException(Exception *e) - { - ExceptionVector::iterator it = std::find(this->Exceptions.begin(), this->Exceptions.end(), e); - if (it != this->Exceptions.end()) - this->Exceptions.erase(it); - } + virtual void DelException(Exception *e) = 0; - Exception *FindException(User *u) - { - for (std::vector::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it) - { - Exception *e = *it; - if (Anope::Match(u->host, e->mask) || (u->ip() && Anope::Match(u->ip.addr(), e->mask))) - return e; - } - return NULL; - } + virtual Exception *FindException(User *u) = 0; - Exception *FindException(const Anope::string &host) - { - for (std::vector::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it) - { - Exception *e = *it; - if (Anope::Match(host, e->mask)) - return e; - } + virtual Exception *FindException(const Anope::string &host) = 0; - return NULL; - } + virtual ExceptionVector &GetExceptions() = 0; - ExceptionVector &GetExceptions() - { - return this->Exceptions; - } + virtual void AddSession(Session *s) = 0; - void AddSession(Session *s) - { - this->Sessions[s->host] = s; - } + virtual void DelSession(Session *s) = 0; - void DelSession(Session *s) - { - this->Sessions.erase(s->host); - } + virtual Session *FindSession(const Anope::string &mask) = 0; - Session *FindSession(const Anope::string &mask) - { - SessionMap::iterator it = this->Sessions.find(mask); - if (it != this->Sessions.end()) - return it->second; - return NULL; - } - - SessionMap &GetSessions() - { - return this->Sessions; - } + virtual SessionMap &GetSessions() = 0; }; #endif diff --git a/modules/core/os_svsnick.cpp b/modules/core/os_svsnick.cpp index 444ef1e8f..2422e0a4c 100644 --- a/modules/core/os_svsnick.cpp +++ b/modules/core/os_svsnick.cpp @@ -29,8 +29,6 @@ class CommandOSSVSNick : public Command Anope::string newnick = params[1]; User *u2; - NickAlias *na; - /* Truncate long nicknames to Config->NickLen characters */ if (newnick.length() > Config->NickLen) { @@ -56,8 +54,6 @@ class CommandOSSVSNick : public Command source.Reply(_(NICK_X_NOT_IN_USE), nick.c_str()); else if (finduser(newnick)) source.Reply(_("Nick \002%s\002 is currently in use."), newnick.c_str()); - else if ((na = findnick(newnick)) && na->HasFlag(NS_FORBIDDEN)) - source.Reply(_(NICK_X_FORBIDDEN), newnick.c_str()); else { source.Reply(_("The nick \002%s\002 is now being changed to \002%s\002."), nick.c_str(), newnick.c_str()); diff --git a/src/channels.cpp b/src/channels.cpp index 1c852aae2..66066ce37 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -14,8 +14,6 @@ channel_map ChannelList; -static const Anope::string ChannelFlagString[] = { "CH_PERSIST", "CH_SYNCING", "CH_LOGCHAN", "" }; - /** Default constructor * @param name The channel name * @param ts The time the channel was created @@ -191,7 +189,7 @@ void Channel::DeleteUser(User *user) return; /* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */ - if (this->ci && this->ci->HasFlag(CI_INHABIT)) + if (this->HasFlag(CH_INHABIT)) return; /* check for BSMinUsers and part the BotServ bot from the channel @@ -791,6 +789,8 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic if (target->FindChannel(this)) { FOREACH_MOD(I_OnUserKicked, OnUserKicked(this, target, source, reason)); + if (bi) + this->SetFlag(CH_INHABIT); this->DeleteUser(target); } else @@ -798,7 +798,10 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic /* Bots get rejoined */ if (bi) + { bi->Join(this, &Config->BotModeList); + this->UnsetFlag(CH_INHABIT); + } } /** Kick a user from the channel @@ -1110,9 +1113,6 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes) if (!c || !(ci = c->ci)) return; - if (ci->HasFlag(CI_FORBIDDEN) || c->name[0] == '+') - return; - Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)"; if (give_modes && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP))) diff --git a/src/chanserv.cpp b/src/chanserv.cpp index f850b5f6a..393ad935d 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -367,10 +367,9 @@ Anope::string get_xop_level(int level) ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) { - if (!chanserv) + if (!chanserv || !c) return; - if (c->ci) - c->ci->SetFlag(CI_INHABIT); + c->SetFlag(CH_INHABIT); if (!c->ci || !c->ci->bi) chanserv->Bot()->Join(c); else if (!c->FindUser(c->ci->bi)) @@ -379,12 +378,12 @@ ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) void ChanServTimer::Tick(time_t) { - if (!c || !c->ci) + if (!c) return; - c->ci->UnsetFlag(CI_INHABIT); + c->UnsetFlag(CH_INHABIT); - if (!c->ci->bi) + if (!c->ci || !c->ci->bi) { if (chanserv) chanserv->Bot()->Part(c); diff --git a/src/config.cpp b/src/config.cpp index 288e33685..671cf3ed7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1049,7 +1049,6 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"nickserv", "resenddelay", "0", new ValueContainerTime(&conf->NSResendDelay), DT_TIME, NoValidation}, {"nickserv", "expire", "21d", new ValueContainerTime(&conf->NSExpire), DT_TIME, NoValidation}, {"nickserv", "suspendexpire", "0", new ValueContainerTime(&conf->NSSuspendExpire), DT_TIME, NoValidation}, - {"nickserv", "forbidexpire", "0", new ValueContainerTime(&conf->NSForbidExpire), DT_TIME, NoValidation}, {"nickserv", "unconfirmedexpire", "0", new ValueContainerTime(&conf->NSUnconfirmedExpire), DT_TIME, ValidateEmailReg}, {"nickserv", "maxaliases", "0", new ValueContainerUInt(&conf->NSMaxAliases), DT_UINTEGER, NoValidation}, {"nickserv", "accessmax", "0", new ValueContainerUInt(&conf->NSAccessMax), DT_UINTEGER, ValidateNotZero}, diff --git a/src/protocol.cpp b/src/protocol.cpp index 4724559fb..dc1c5960d 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -386,7 +386,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vectorHasFlag(CI_FORBIDDEN) && ci->c) + if (ci && ci->c) { FOREACH_MOD(I_OnPrivmsg, OnPrivmsg(u, ci, message)); } @@ -459,7 +459,7 @@ bool IRCdMessage::OnQuit(const Anope::string &source, const std::vectornick); - if (na && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) + if (na && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) { na->last_seen = Anope::CurTime; na->last_quit = reason; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 4d8dc8198..5a94027ae 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -789,10 +789,10 @@ bool ChannelInfo::CheckKick(User *user) do_kick = true; Anope::string mask, reason; - if (!user->HasMode(UMODE_OPER) && (this->HasFlag(CI_SUSPENDED) || this->HasFlag(CI_FORBIDDEN))) + if (!user->HasMode(UMODE_OPER) && this->HasFlag(CI_SUSPENDED)) { get_idealban(this, user, mask); - reason = this->forbidreason.empty() ? GetString(user->Account(), _("This channel may not be used.")) : this->forbidreason; + reason = GetString(user->Account(), _("This channel may not be used.")); set_modes = true; do_kick = true; } @@ -850,9 +850,9 @@ bool ChannelInfo::CheckKick(User *user) * ChanServ always enforces channels like this to keep people from deleting bots etc * that are holding channels. */ - if (this->c->users.size() == (this->bi && this->c->FindUser(this->bi) ? 2 : 1) && !this->HasFlag(CI_INHABIT) && !this->c->HasFlag(CH_SYNCING)) + if (this->c->users.size() == (this->bi && this->c->FindUser(this->bi) ? 2 : 1) && !this->c->HasFlag(CH_INHABIT) && !this->c->HasFlag(CH_SYNCING)) { - /* If channel was forbidden, etc, set it +si to prevent rejoin */ + /* Set +si to prevent rejoin */ if (set_modes) { c->SetMode(NULL, CMODE_NOEXTERNAL); diff --git a/src/servers.cpp b/src/servers.cpp index a1935c109..763fed707 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -73,7 +73,7 @@ Server::~Server() if (u->server == this) { NickAlias *na = findnick(u->nick); - if (na && !na->HasFlag(NS_FORBIDDEN) && (!na->nc->HasFlag(NI_SUSPENDED)) && (u->IsRecognized() || u->IsIdentified())) + if (na && !na->nc->HasFlag(NI_SUSPENDED) && (u->IsRecognized() || u->IsIdentified())) { na->last_seen = Anope::CurTime; na->last_quit = this->QReason; diff --git a/src/users.cpp b/src/users.cpp index 0e986cc93..1b06461ed 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -315,13 +315,19 @@ void User::Collide(NickAlias *na) { Anope::string guestnick; + int i = 0; do { guestnick = Config->NSGuestNickPrefix + stringify(getrandom16()); - } while (finduser(guestnick)); + } while (finduser(guestnick) && i++ < 10); - this->SendMessage(nickserv->Bot(), _("Your nickname is now being changed to \002%s\002"), guestnick.c_str()); - ircdproto->SendForceNickChange(this, guestnick, Anope::CurTime); + if (i == 11) + this->Kill(Config->s_NickServ, "Services nickname-enforcer kill"); + else + { + this->SendMessage(nickserv->Bot(), _("Your nickname is now being changed to \002%s\002"), guestnick.c_str()); + ircdproto->SendForceNickChange(this, guestnick, Anope::CurTime); + } } else this->Kill(Config->s_NickServ, "Services nickname-enforcer kill"); @@ -883,7 +889,7 @@ void do_kill(User *user, const Anope::string &msg) Log(user, "killed") << "was killed (Reason: " << msg << ")"; NickAlias *na = findnick(user->nick); - if (na && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) + if (na && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) { na->last_seen = Anope::CurTime; na->last_quit = msg;