1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 03:56:37 +02:00
Files
anope/src/actions.cpp
T
Adam 49d3c97b67 Bug #1079 - Don't use users real host and IPs when matching against
bans and excepts, except when a user is unbanning themselves, in an
attempt to prevent people from gaining other users IPs.
This removes support for Unreal and Bahamuts SVSMode -b because
it will unban users by real host and IP.
2010-12-13 16:36:36 -05:00

89 lines
2.4 KiB
C++

/* Various routines to perform simple actions.
*
* (C) 2003-2010 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 "services.h"
/*************************************************************************/
/**
* Note a bad password attempt for the given user. If they've used up
* their limit, toss them off.
* @param u the User to check
* @return true if the user was killed, otherwise false
*/
bool bad_password(User *u)
{
if (!u || !Config->BadPassLimit)
return false;
if (Config->BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < Anope::CurTime - Config->BadPassTimeout)
u->invalid_pw_count = 0;
++u->invalid_pw_count;
u->invalid_pw_time = Anope::CurTime;
if (u->invalid_pw_count >= Config->BadPassLimit)
{
kill_user("", u, "Too many invalid passwords");
return true;
}
return false;
}
/*************************************************************************/
/**
* Remove a user from the IRC network.
* @param source is the nick which should generate the kill, or empty for a server-generated kill.
* @param user to remove
* @param reason for the kill
* @return void
*/
void kill_user(const Anope::string &source, User *user, const Anope::string &reason)
{
if (!user)
return;
Anope::string real_source = source.empty() ? Config->ServerName : source;
Anope::string buf = real_source + " (" + reason + ")";
ircdproto->SendSVSKill(findbot(source), user, "%s", buf.c_str());
if (!ircd->quitonkill)
do_kill(user, buf);
}
/*************************************************************************/
/**
* Unban the user from a channel
* @param ci channel info for the channel
* @param u The user to unban
* @param full True to match against the users real host and IP
* @return void
*/
void common_unban(ChannelInfo *ci, User *u, bool full)
{
if (!u || !ci || !ci->c || !ci->c->HasMode(CMODE_BAN))
return;
std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = ci->c->GetModeList(CMODE_BAN);
for (; bans.first != bans.second;)
{
Entry ban(bans.first->second);
++bans.first;
if (ban.Matches(u, full))
ci->c->RemoveMode(NULL, CMODE_BAN, ban.GetMask());
}
}
/*************************************************************************/