summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-05-20 21:10:49 -0400
committerAdam <Adam@anope.org>2014-05-20 21:16:00 -0400
commit866f3f32ab3713e9867747f150df3698e456744e (patch)
tree20aabb18d88ee72a4fd412e17ebe30585496bd97 /modules/commands
parent20ce170024779aebbc1462146905c976836a552f (diff)
Speed up akill xline checks
Cache xline nick, user, host, etc instead of rebuilding it everytime its requested. Store users ip in sockaddr form and not string form to prevent having to rebuild sockaddrs when checking xlines. Also do not try to convert empty config values in Config::Get as this can be rather common if a non string configuration value is not set, and the cost of the ConvertException is great.
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/os_defcon.cpp4
-rw-r--r--modules/commands/os_list.cpp2
-rw-r--r--modules/commands/os_session.cpp14
3 files changed, 10 insertions, 10 deletions
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index afd5dc7d6..c5074fd44 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -502,7 +502,7 @@ class OSDefcon : public Module
if (DConfig.sessionlimit <= 0 || !session_service)
return;
- Session *session = session_service->FindSession(u->ip);
+ Session *session = session_service->FindSession(u->ip.addr());
Exception *exception = session_service->FindException(u);
if (DConfig.Check(DEFCON_REDUCE_SESSION) && !exception)
@@ -511,7 +511,7 @@ class OSDefcon : public Module
{
if (!DConfig.sle_reason.empty())
{
- Anope::string message = DConfig.sle_reason.replace_all_cs("%IP%", u->ip);
+ Anope::string message = DConfig.sle_reason.replace_all_cs("%IP%", u->ip.addr());
u->SendMessage(OperServ, message);
}
if (!DConfig.sle_detailsloc.empty())
diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp
index 7bafd8b4d..b0c5fb339 100644
--- a/modules/commands/os_list.cpp
+++ b/modules/commands/os_list.cpp
@@ -180,7 +180,7 @@ class CommandOSUserList : public Command
if (!pattern.empty())
{
- Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + (!u2->ip.empty() ? u2->ip : u2->host);
+ Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + u2->ip.addr();
if (!Anope::Match(mask, pattern) && !Anope::Match(mask2, pattern) && !Anope::Match(mask3, pattern))
continue;
if (!modes.empty())
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index edf9458f8..40412494e 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -64,10 +64,10 @@ class MySessionService : public SessionService
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) || Anope::Match(u->ip, e->mask))
+ if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip.addr(), e->mask))
return e;
- if (cidr(e->mask).match(sockaddrs(u->ip)))
+ if (cidr(e->mask).match(u->ip))
return e;
}
return NULL;
@@ -109,9 +109,9 @@ class MySessionService : public SessionService
return NULL;
}
- SessionMap::iterator FindSessionIterator(const Anope::string &ip)
+ SessionMap::iterator FindSessionIterator(const sockaddrs &ip)
{
- cidr c(ip, ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr);
+ cidr c(ip, ip.ipv6() ? ipv6_cidr : ipv4_cidr);
if (!c.valid())
return this->Sessions.end();
return this->Sessions.find(c);
@@ -668,7 +668,7 @@ class OSSession : public Module
if (u->Quitting() || !session_limit || exempt || !u->server || u->server->IsULined())
return;
- cidr u_ip(u->ip, u->ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr);
+ cidr u_ip(u->ip, u->ip.ipv6() ? ipv6_cidr : ipv4_cidr);
if (!u_ip.valid())
return;
@@ -705,7 +705,7 @@ class OSSession : public Module
{
if (!sle_reason.empty())
{
- Anope::string message = sle_reason.replace_all_cs("%IP%", u->ip);
+ Anope::string message = sle_reason.replace_all_cs("%IP%", u->ip.addr());
u->SendMessage(OperServ, message);
}
if (!sle_detailsloc.empty())
@@ -729,7 +729,7 @@ class OSSession : public Module
}
else
{
- session = new Session(u->ip, u->ip.find(':') != Anope::string::npos ? ipv6_cidr : ipv4_cidr);
+ session = new Session(u->ip, u->ip.ipv6() ? ipv6_cidr : ipv4_cidr);
}
}