mirror of
https://github.com/anope/anope.git
synced 2026-06-28 15:16:38 +02:00
Added os_forbid
This commit is contained in:
+3
-10
@@ -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
|
||||
|
||||
@@ -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 '',
|
||||
|
||||
@@ -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
|
||||
-------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,6 +25,8 @@ typedef std::list<UserContainer *> 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<ChannelFlag, 3>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+2
-7
@@ -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."
|
||||
|
||||
@@ -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 Flags<ChannelInfoFlag,
|
||||
Anope::string last_topic_setter; /* Setter */
|
||||
time_t last_topic_time; /* Time */
|
||||
|
||||
// These two should be using extensible
|
||||
Anope::string forbidby;
|
||||
Anope::string forbidreason;
|
||||
|
||||
int16 bantype;
|
||||
int16 *levels; /* Access levels for commands */
|
||||
|
||||
|
||||
@@ -38,16 +38,9 @@ class BotServBotInfo : 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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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<Anope::string> ¶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<Channel::ModeList::iterator, Channel::ModeList::iterator> 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)
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)") << ")";
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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<Anope::string>(u->nick));
|
||||
if (!reason.empty())
|
||||
ci->forbidreason = reason;
|
||||
ci->Extend("suspend_reason", new ExtensibleItemRegular<Anope::string>(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());
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<int>(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<int>(r.Get(i, "bantype")) : 2;
|
||||
ci->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int16>(r.Get(i, "memomax")) : 20;
|
||||
ci->capsmin = r.Get(i, "capsmin").is_number_only() ? convertTo<int>(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)
|
||||
|
||||
@@ -46,8 +46,6 @@ static void ChanInfoUpdate(const SQLResult &res)
|
||||
ci->time_registered = convertTo<time_t>(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<int>(res.Get(0, "bantype"));
|
||||
ci->memos.memomax = convertTo<unsigned>(res.Get(0, "memomax"));
|
||||
|
||||
|
||||
@@ -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<time_t>(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<Anope::string>(params[0]));
|
||||
ci->Extend("suspend_reason", new ExtensibleItemRegular<Anope::string>(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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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") << ")";
|
||||
|
||||
@@ -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<Anope::string> ¶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)
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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."));
|
||||
|
||||
@@ -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;
|
||||
|
||||
+14
-36
@@ -24,31 +24,17 @@ class CommandNSList : public Command
|
||||
|
||||
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 *> forbidData;
|
||||
|
||||
public:
|
||||
MyForbidService(Module *m) : ForbidService(m) { }
|
||||
|
||||
void AddForbid(ForbidData *d)
|
||||
{
|
||||
this->forbidData.push_back(d);
|
||||
}
|
||||
|
||||
void RemoveForbid(ForbidData *d)
|
||||
{
|
||||
std::vector<ForbidData *>::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<ForbidData *> &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<ForbidData *> &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<ForbidService> 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<Anope::string> ¶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<ForbidData *> &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<User> &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<Anope::string> ¶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<ForbidData *> 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<Anope::string> ¶ms)
|
||||
{
|
||||
if (params.size() > 5 && params[0] == "FORBID")
|
||||
{
|
||||
ForbidData *f = new ForbidData();
|
||||
f->mask = params[1];
|
||||
f->creator = params[2];
|
||||
f->created = convertTo<time_t>(params[3]);
|
||||
f->expires = convertTo<time_t>(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)
|
||||
@@ -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<ForbidData *> &GetForbids() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,77 @@
|
||||
|
||||
static service_reference<SessionService> 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<Exception *>::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<Exception *>::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;
|
||||
}
|
||||
|
||||
|
||||
+10
-58
@@ -6,74 +6,26 @@ class SessionService : public Service
|
||||
public:
|
||||
typedef Anope::map<Session *> SessionMap;
|
||||
typedef std::vector<Exception *> 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<Exception *>::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<Exception *>::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
|
||||
|
||||
@@ -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());
|
||||
|
||||
+6
-6
@@ -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)))
|
||||
|
||||
+5
-6
@@ -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);
|
||||
|
||||
@@ -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},
|
||||
|
||||
+2
-2
@@ -386,7 +386,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(receiver);
|
||||
/* Some paranoia checks */
|
||||
if (ci && !ci->HasFlag(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::vector<Anope::s
|
||||
Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")";
|
||||
|
||||
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 = reason;
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+10
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user