summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/extern.h2
-rw-r--r--include/services.h4
-rw-r--r--modules/core/os_akill.cpp2
-rw-r--r--src/sessions.cpp52
4 files changed, 31 insertions, 29 deletions
diff --git a/include/extern.h b/include/extern.h
index 9f2071a88..48336be5f 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -333,7 +333,7 @@ E std::vector<Exception *> exceptions;
E void get_session_stats(long &count, long &mem);
E void get_exception_stats(long &count, long &mem);
-E int add_session(const Anope::string &nick, const Anope::string &host, const Anope::string &hostip);
+E void add_session(const Anope::string &nick, const Anope::string &host, const Anope::string &hostip);
E void del_session(const Anope::string &host);
E void expire_exceptions();
diff --git a/include/services.h b/include/services.h
index 4702dcff1..f44425656 100644
--- a/include/services.h
+++ b/include/services.h
@@ -865,8 +865,8 @@ extern CoreExport session_map SessionList;
struct Session
{
Anope::string host;
- int count; /* Number of clients with this host */
- int hits; /* Number of subsequent kills for a host */
+ unsigned count; /* Number of clients with this host */
+ unsigned hits; /* Number of subsequent kills for a host */
};
/*************************************************************************/
diff --git a/modules/core/os_akill.cpp b/modules/core/os_akill.cpp
index f550938fb..abda0348a 100644
--- a/modules/core/os_akill.cpp
+++ b/modules/core/os_akill.cpp
@@ -219,7 +219,7 @@ class CommandOSAKill : public Command
CommandReturn DoDel(User *u, const std::vector<Anope::string> &params)
{
- Anope::string mask = params.size() > 1 ? params[0] : "";
+ Anope::string mask = params.size() > 1 ? params[1] : "";
if (mask.empty())
{
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)