summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-09-01 21:01:52 -0400
committerAdam <Adam@anope.org>2010-09-01 21:01:52 -0400
commit7a522d1c348ebab4a9fe5d90a91683ea10922973 (patch)
treee9b7e5c2e0f0c534022135d40968b8a69c83d9aa /src
parentf2769273652f61f1d620c98a94b9c95983ed5647 (diff)
Only look up session exceptions if the user exceeds the session limit, really send akills for exceeding session limits, and fixed os akill del to really work
Diffstat (limited to 'src')
-rw-r--r--src/sessions.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/sessions.cpp b/src/sessions.cpp
index 6d3571d85..8f1039fd8 100644
--- a/src/sessions.cpp
+++ b/src/sessions.cpp
@@ -105,21 +105,26 @@ Session *findsession(const Anope::string &host)
* Returns 1 if the host was added or 0 if the user was killed.
*/
-int add_session(const Anope::string &nick, const Anope::string &host, const Anope::string &hostip)
+void add_session(const Anope::string &nick, const Anope::string &host, const Anope::string &hostip)
{
- Session *session;
- Exception *exception;
- int sessionlimit = 0;
-
- session = findsession(host);
+ Session *session = findsession(host);
if (session)
{
- exception = find_hostip_exception(host, hostip);
-
- sessionlimit = exception ? exception->limit : Config->DefSessionLimit;
+ bool kill = false;
+ if (Config->DefSessionLimit && session->count >= Config->DefSessionLimit)
+ {
+ kill = true;
+ Exception *exception = find_hostip_exception(host, hostip);
+ if (exception)
+ {
+ kill = false;
+ if (session->count >= exception->limit)
+ kill = true;
+ }
+ }
- if (sessionlimit && session->count >= sessionlimit)
+ if (kill)
{
if (!Config->SessionLimitExceeded.empty())
ircdproto->SendMessage(OperServ, nick, Config->SessionLimitExceeded.c_str(), host.c_str());
@@ -129,39 +134,36 @@ int add_session(const Anope::string &nick, const Anope::string &host, const Anop
/* Previously on IRCds that send a QUIT (InspIRCD) when a user is killed, the session for a host was
* decremented in do_quit, which caused problems and fixed here
*
- * Now, we create the user struture before calling this (to fix some user tracking issues..
- * read users.c), so we must increment this here no matter what because it will either be
+ * Now, we create the user struture before calling this to fix some user tracking issues,
+ * so we must increment this here no matter what because it will either be
* decremented in do_kill or in do_quit - Adam
*/
++session->count;
kill_user(Config->s_OperServ, nick, "Session limit exceeded");
++session->hits;
- if (Config->MaxSessionKill && session->hits >= Config->MaxSessionKill)
+ if (Config->MaxSessionKill && session->hits >= Config->MaxSessionKill && SGLine)
{
Anope::string akillmask = "*@" + host;
XLine *x = new XLine(akillmask, Config->s_OperServ, time(NULL) + Config->SessionAutoKillExpiry, "Session limit exceeded");
- if (x)
- x->By = Config->s_OperServ;
+ SGLine->AddXLine(x);
ircdproto->SendGlobops(OperServ, "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask.c_str());
}
- return 0;
}
else
{
++session->count;
- return 1;
}
}
+ else
+ {
+ session = new Session();
+ session->host = host;
+ session->count = 1;
+ session->hits = 0;
- session = new Session();
- session->host = host;
- session->count = 1;
- session->hits = 0;
-
- SessionList[session->host] = session;
-
- return 1;
+ SessionList[session->host] = session;
+ }
}
void del_session(const Anope::string &host)