diff options
author | Adam <Adam@anope.org> | 2012-09-07 12:04:25 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-09-07 12:04:25 -0400 |
commit | 9d6626f70ce866e2e98ce7ce607695b14a8375b7 (patch) | |
tree | f9cf4e1bb295d4707be097898c4544101fcd7340 /modules/commands/os_session.cpp | |
parent | 5c07863ad503edfc8deb1dee38e6222602db54fd (diff) |
Made session tracking ip based, not host based, and allow using CIDR to group multiple ips from one subnet to one session
Diffstat (limited to 'modules/commands/os_session.cpp')
-rw-r--r-- | modules/commands/os_session.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 0de82d05a..91db78da2 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -63,17 +63,18 @@ class MySessionService : public SessionService void AddSession(Session *s) anope_override { - this->Sessions[s->host] = s; + this->Sessions[s->addr] = s; } void DelSession(Session *s) anope_override { - this->Sessions.erase(s->host); + this->Sessions.erase(s->addr); } - Session *FindSession(const Anope::string &mask) anope_override + Session *FindSession(const Anope::string &ip) anope_override { - SessionMap::iterator it = this->Sessions.find(mask); + cidr c(ip, ip.find(':') != Anope::string::npos ? Config->SessionIPv6CIDR : Config->SessionIPv4CIDR); + SessionMap::iterator it = this->Sessions.find(c); if (it != this->Sessions.end()) return it->second; return NULL; @@ -176,7 +177,7 @@ class CommandOSSession : public Command { ListFormatter::ListEntry entry; entry["Session"] = stringify(session->count); - entry["Host"] = session->host; + entry["Host"] = session->addr.mask(); list.addEntry(entry); } } @@ -204,7 +205,7 @@ class CommandOSSession : public Command else { Exception *exception = session_service->FindException(param); - source.Reply(_("The host \002%s\002 currently has \002%d\002 sessions with a limit of \002%d\002."), param.c_str(), session->count, exception && exception->limit > Config->DefSessionLimit ? exception->limit : Config->DefSessionLimit); + source.Reply(_("The host \002%s\002 currently has \002%d\002 sessions with a limit of \002%d\002."), session->addr.mask().c_str(), session->count, exception && exception->limit > Config->DefSessionLimit ? exception->limit : Config->DefSessionLimit); } return; @@ -606,7 +607,7 @@ class OSSession : public Module void AddSession(User *u, bool exempt) { - Session *session = this->ss.FindSession(u->host); + Session *session = this->ss.FindSession(u->ip); if (session) { @@ -661,11 +662,7 @@ class OSSession : public Module } else { - session = new Session(); - session->host = u->host; - session->count = 1; - session->hits = 0; - + session = new Session(u->ip, u->ip.find(':') != Anope::string::npos ? Config->SessionIPv6CIDR : Config->SessionIPv4CIDR); this->ss.AddSession(session); } } |