summaryrefslogtreecommitdiff
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
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.
-rw-r--r--include/config.h15
-rw-r--r--include/modules/os_session.h2
-rw-r--r--include/sockets.h5
-rw-r--r--include/users.h3
-rw-r--r--include/xline.h13
-rw-r--r--modules/commands/os_defcon.cpp4
-rw-r--r--modules/commands/os_list.cpp2
-rw-r--r--modules/commands/os_session.cpp14
-rw-r--r--modules/extra/m_sql_authentication.cpp2
-rw-r--r--modules/extra/m_sql_oper.cpp2
-rw-r--r--modules/extra/stats/irc2sql/irc2sql.cpp2
-rw-r--r--modules/m_dnsbl.cpp19
-rw-r--r--modules/m_proxyscan.cpp6
-rw-r--r--modules/m_xmlrpc_main.cpp3
-rw-r--r--modules/pseudoclients/operserv.cpp9
-rw-r--r--src/messages.cpp2
-rw-r--r--src/modes.cpp2
-rw-r--r--src/sockets.cpp15
-rw-r--r--src/users.cpp5
-rw-r--r--src/xline.cpp102
20 files changed, 115 insertions, 112 deletions
diff --git a/include/config.h b/include/config.h
index 019564680..b132c5d2d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -51,14 +51,13 @@ namespace Configuration
template<typename T> T Get(const Anope::string &tag, const Anope::string &def) const
{
const Anope::string &value = this->Get<const Anope::string>(tag, def);
- try
- {
- return convertTo<T>(value);
- }
- catch (const ConvertException &)
- {
- return T();
- }
+ if (!value.empty())
+ try
+ {
+ return convertTo<T>(value);
+ }
+ catch (const ConvertException &) { }
+ return T();
}
bool Set(const Anope::string &tag, const Anope::string &value);
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index 65f1c6f75..957fe6043 100644
--- a/include/modules/os_session.h
+++ b/include/modules/os_session.h
@@ -7,7 +7,7 @@ struct Session
unsigned count; /* Number of clients with this host */
unsigned hits; /* Number of subsequent kills for a host */
- Session(const Anope::string &ip, int len) : addr(ip, len), count(1), hits(0) { }
+ Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { }
};
struct Exception : Serializable
diff --git a/include/sockets.h b/include/sockets.h
index 0dfa5d9d0..ca61f7efc 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -59,7 +59,7 @@ union CoreExport sockaddrs
/** Check if this sockaddr has data in it
*/
- bool operator()() const;
+ bool valid() const;
/** Compares with sockaddr with another. Compares address type, port, and address
* @return true if they are the same
@@ -82,8 +82,6 @@ union CoreExport sockaddrs
* @throws A socket exception if given an invalid structure
*/
void ntop(int type, const void *src);
-
- bool valid() const;
};
class CoreExport cidr
@@ -94,6 +92,7 @@ class CoreExport cidr
public:
cidr(const Anope::string &ip);
cidr(const Anope::string &ip, unsigned char len);
+ cidr(const sockaddrs &ip, unsigned char len);
Anope::string mask() const;
bool match(const sockaddrs &other);
bool valid() const;
diff --git a/include/users.h b/include/users.h
index 73c373938..04d1606a4 100644
--- a/include/users.h
+++ b/include/users.h
@@ -20,6 +20,7 @@
#include "serialize.h"
#include "commands.h"
#include "account.h"
+#include "sockets.h"
typedef Anope::hash_map<User *> user_map;
@@ -71,7 +72,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/* SSL Fingerprint */
Anope::string fingerprint;
/* User's IP */
- Anope::string ip;
+ sockaddrs ip;
/* Server user is connected to */
Server *server;
/* When the user signed on. Set on connect and never modified. */
diff --git a/include/xline.h b/include/xline.h
index fa3f5ba6c..2eae08dc8 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -12,12 +12,15 @@
#include "serialize.h"
#include "service.h"
+#include "sockets.h"
/* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
class CoreExport XLine : public Serializable
{
- void InitRegex();
+ void Init();
+ Anope::string nick, user, host, real;
public:
+ cidr *c;
Anope::string mask;
Regex *regex;
Anope::string by;
@@ -32,10 +35,10 @@ class CoreExport XLine : public Serializable
XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = "");
~XLine();
- Anope::string GetNick() const;
- Anope::string GetUser() const;
- Anope::string GetHost() const;
- Anope::string GetReal() const;
+ const Anope::string &GetNick() const;
+ const Anope::string &GetUser() const;
+ const Anope::string &GetHost() const;
+ const Anope::string &GetReal() const;
Anope::string GetReason() const;
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);
}
}
diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp
index 0710a6e20..c718f3c2b 100644
--- a/modules/extra/m_sql_authentication.cpp
+++ b/modules/extra/m_sql_authentication.cpp
@@ -122,7 +122,7 @@ class ModuleSQLAuthentication : public Module
if (u)
{
q.SetValue("n", u->nick);
- q.SetValue("i", u->ip);
+ q.SetValue("i", u->ip.addr());
}
else
{
diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp
index 68a6d9084..3203021bc 100644
--- a/modules/extra/m_sql_oper.cpp
+++ b/modules/extra/m_sql_oper.cpp
@@ -135,7 +135,7 @@ class ModuleSQLOper : public Module
SQL::Query q(this->query);
q.SetValue("a", u->Account()->display);
- q.SetValue("i", u->ip);
+ q.SetValue("i", u->ip.addr());
this->SQL->Run(new SQLOperResult(this, u), q);
diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp
index d20e1a420..fd0ca5890 100644
--- a/modules/extra/stats/irc2sql/irc2sql.cpp
+++ b/modules/extra/stats/irc2sql/irc2sql.cpp
@@ -95,7 +95,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt)
query.SetValue("vhost", u->vhost);
query.SetValue("chost", u->chost);
query.SetValue("realname", u->realname);
- query.SetValue("ip", u->ip);
+ query.SetValue("ip", u->ip.addr());
query.SetValue("ident", u->GetIdent());
query.SetValue("vident", u->GetVIdent());
query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp
index b19a66ea4..1c10b09d5 100644
--- a/modules/m_dnsbl.cpp
+++ b/modules/m_dnsbl.cpp
@@ -54,18 +54,18 @@ class DNSBLResolver : public Request
record_reason = this->blacklist.replies[result];
}
- Anope::string reason = this->blacklist.reason;
+ Anope::string reason = this->blacklist.reason, addr = user->ip.addr();
reason = reason.replace_all_cs("%n", user->nick);
reason = reason.replace_all_cs("%u", user->GetIdent());
reason = reason.replace_all_cs("%g", user->realname);
reason = reason.replace_all_cs("%h", user->host);
- reason = reason.replace_all_cs("%i", user->ip);
+ reason = reason.replace_all_cs("%i", addr);
reason = reason.replace_all_cs("%r", record_reason);
reason = reason.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
BotInfo *OperServ = Config->GetClient("OperServ");
- Log(creator, "dnsbl", OperServ) << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name;
- XLine *x = new XLine("*@" + user->ip, OperServ ? OperServ->nick : "m_dnsbl", Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID());
+ Log(creator, "dnsbl", OperServ) << user->GetMask() << " (" << addr << ") appears in " << this->blacklist.name;
+ XLine *x = new XLine("*@" + addr, OperServ ? OperServ->nick : "m_dnsbl", Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID());
if (this->add_to_akill && akills)
{
akills->AddXLine(x);
@@ -130,22 +130,21 @@ class ModuleDNSBL : public Module
return;
/* At this time we only support IPv4 */
- sockaddrs user_ip;
- user_ip.pton(AF_INET, user->ip);
- if (!user_ip.valid())
+ if (!user->ip.valid() || user->ip.sa.sa_family != AF_INET)
/* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */
return;
- const unsigned long &ip = user_ip.sa4.sin_addr.s_addr;
+ const unsigned long &ip = user->ip.sa4.sin_addr.s_addr;
unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24);
- user_ip.sa4.sin_addr.s_addr = reverse_ip;
+ sockaddrs reverse = user->ip;
+ reverse.sa4.sin_addr.s_addr = reverse_ip;
for (unsigned i = 0; i < this->blacklists.size(); ++i)
{
const Blacklist &b = this->blacklists[i];
- Anope::string dnsbl_host = user_ip.addr() + "." + b.name;
+ Anope::string dnsbl_host = reverse.addr() + "." + b.name;
DNSBLResolver *res = NULL;
try
{
diff --git a/modules/m_proxyscan.cpp b/modules/m_proxyscan.cpp
index 0fe4ade27..6df764166 100644
--- a/modules/m_proxyscan.cpp
+++ b/modules/m_proxyscan.cpp
@@ -334,9 +334,7 @@ class ModuleProxyScan : public Module
return;
/* At this time we only support IPv4 */
- sockaddrs user_ip;
- user_ip.pton(AF_INET, user->ip);
- if (!user_ip.valid())
+ if (!user->ip.valid() || user->ip.sa.sa_family != AF_INET)
/* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */
return;
@@ -364,7 +362,7 @@ class ModuleProxyScan : public Module
con = new SOCKS5ProxyConnect(p, p.ports[k]);
else
continue;
- con->Connect(user->ip, p.ports[k]);
+ con->Connect(user->ip.addr(), p.ports[k]);
}
catch (const SocketException &ex)
{
diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp
index 17dd8b96f..a66503f87 100644
--- a/modules/m_xmlrpc_main.cpp
+++ b/modules/m_xmlrpc_main.cpp
@@ -212,8 +212,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
request.reply("vhost", iface->Sanitize(u->vhost));
if (!u->chost.empty())
request.reply("chost", iface->Sanitize(u->chost));
- if (!u->ip.empty())
- request.reply("ip", u->ip);
+ request.reply("ip", u->ip.addr());
request.reply("timestamp", stringify(u->timestamp));
request.reply("signon", stringify(u->signon));
if (u->Account())
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index 1a07bb009..67eaecd45 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -53,13 +53,10 @@ class SGLineManager : public XLineManager
if (!x->GetReal().empty() && !Anope::Match(u->realname, x->GetReal()))
return false;
- if (x->GetHost().find('/') != Anope::string::npos)
- {
- if (cidr(x->GetHost()).match(sockaddrs(u->ip)))
- return true;
- }
+ if (x->c && x->c->match(u->ip))
+ return true;
- if (x->GetHost().empty() || Anope::Match(u->host, x->GetHost()) || Anope::Match(u->ip, x->GetHost()))
+ if (x->GetHost().empty() || Anope::Match(u->host, x->GetHost()) || Anope::Match(u->ip.addr(), x->GetHost()))
return true;
return false;
diff --git a/src/messages.cpp b/src/messages.cpp
index 97f0dd968..8e92d19c2 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -158,8 +158,6 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
if (c->CheckDelete())
delete c;
- else
- c->CheckModes();
}
}
}
diff --git a/src/modes.cpp b/src/modes.cpp
index 4138cfebe..dafe2ddca 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -867,7 +867,7 @@ bool Entry::Matches(User *u, bool full) const
}
}
else if (!this->host.empty() && !Anope::Match(u->GetDisplayedHost(), this->host) && !Anope::Match(u->GetCloakedHost(), this->host) &&
- (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->ip, this->host))))
+ (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->ip.addr(), this->host))))
ret = false;
if (!this->real.empty() && !Anope::Match(u->realname, this->real))
diff --git a/src/sockets.cpp b/src/sockets.cpp
index f047c5f44..9b88de4c6 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -96,9 +96,9 @@ bool sockaddrs::ipv6() const
return sa.sa_family == AF_INET6;
}
-bool sockaddrs::operator()() const
+bool sockaddrs::valid() const
{
- return valid();
+ return size() != 0;
}
bool sockaddrs::operator==(const sockaddrs &other) const
@@ -180,11 +180,6 @@ void sockaddrs::ntop(int type, const void *src)
this->clear();
}
-bool sockaddrs::valid() const
-{
- return size() != 0;
-}
-
cidr::cidr(const Anope::string &ip)
{
bool ipv6 = ip.find(':') != Anope::string::npos;
@@ -221,6 +216,12 @@ cidr::cidr(const Anope::string &ip, unsigned char len)
this->cidr_len = len;
}
+cidr::cidr(const sockaddrs &a, unsigned char len) : addr(a)
+{
+ this->cidr_ip = a.addr();
+ this->cidr_len = len;
+}
+
Anope::string cidr::mask() const
{
if ((this->addr.ipv6() && this->cidr_len == 128) || (!this->addr.ipv6() && this->cidr_len == 32))
diff --git a/src/users.cpp b/src/users.cpp
index 94ab75fb4..8a4246e2f 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -33,7 +33,7 @@ time_t MaxUserTime = 0;
std::list<User *> User::quitting_users;
-User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *account)
+User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *account) : ip(uip)
{
if (snick.empty() || sident.empty() || shost.empty())
throw CoreException("Bad args passed to User::User");
@@ -49,7 +49,6 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
this->host = shost;
this->vhost = svhost;
this->chost = svhost;
- this->ip = sip;
this->server = sserver;
this->realname = srealname;
this->timestamp = this->signon = ts;
@@ -72,7 +71,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
{
++sserver->users;
if (server->IsSynced())
- Log(this, "connect") << (!vhost.empty() && vhost != host ? "(" + vhost + ") " : "") << "(" << srealname << ") " << (!sip.empty() && sip != host ? "[" + sip + "] " : "") << "connected to the network (" << sserver->GetName() << ")";
+ Log(this, "connect") << (!vhost.empty() && vhost != host ? "(" + vhost + ") " : "") << "(" << srealname << ") " << (!uip.empty() && uip != host ? "[" + uip + "] " : "") << "connected to the network (" << sserver->GetName() << ")";
}
if (UserListByNick.size() > MaxUserCount)
diff --git a/src/xline.cpp b/src/xline.cpp
index 6b3ba90f4..8f02b930e 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -24,7 +24,7 @@
std::list<XLineManager *> XLineManager::XLineManagers;
Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLineManager::XLinesByUID("XLine");
-void XLine::InitRegex()
+void XLine::Init()
{
if (this->mask.length() >= 2 && this->mask[0] == '/' && this->mask[this->mask.length() - 1] == '/' && !Config->GetBlock("options")->Get<const Anope::string>("regexengine").empty())
{
@@ -43,82 +43,92 @@ void XLine::InitRegex()
}
}
}
+
+ size_t nick_t = this->mask.find('!');
+ if (nick_t != Anope::string::npos)
+ nick = this->mask.substr(0, nick_t);
+
+ size_t user_t = this->mask.find('!'), host_t = this->mask.find('@');
+ if (host_t != Anope::string::npos)
+ {
+ if (user_t != Anope::string::npos && host_t > user_t)
+ user = this->mask.substr(user_t + 1, host_t - user_t - 1);
+ else
+ user = this->mask.substr(0, host_t);
+ }
+
+ size_t real_t = this->mask.find('#');
+ if (host_t != Anope::string::npos)
+ {
+ if (real_t != Anope::string::npos && real_t > host_t)
+ host = this->mask.substr(host_t + 1, real_t - host_t - 1);
+ else
+ host = this->mask.substr(host_t + 1);
+ }
+ else
+ {
+ if (real_t != Anope::string::npos)
+ host = this->mask.substr(0, real_t);
+ else
+ host = this->mask;
+ }
+
+ if (real_t != Anope::string::npos)
+ real = this->mask.substr(real_t + 1);
+
+ if (host.find('/') != Anope::string::npos)
+ {
+ c = new cidr(host);
+ if (!c->valid())
+ {
+ delete c;
+ c = NULL;
+ }
+ }
}
XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(Me->GetName()), created(0), expires(0), reason(r), id(uid)
{
regex = NULL;
manager = NULL;
+ c = NULL;
- this->InitRegex();
+ this->Init();
}
XLine::XLine(const Anope::string &ma, const Anope::string &b, const time_t ex, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(b), created(Anope::CurTime), expires(ex), reason(r), id(uid)
{
regex = NULL;
manager = NULL;
+ c = NULL;
- this->InitRegex();
+ this->Init();
}
XLine::~XLine()
{
delete regex;
+ delete c;
}
-Anope::string XLine::GetNick() const
+const Anope::string &XLine::GetNick() const
{
- size_t nick_t = this->mask.find('!');
-
- if (nick_t == Anope::string::npos)
- return "";
-
- return this->mask.substr(0, nick_t);
+ return nick;
}
-Anope::string XLine::GetUser() const
+const Anope::string &XLine::GetUser() const
{
- size_t user_t = this->mask.find('!'), host_t = this->mask.find('@');
-
- if (host_t != Anope::string::npos)
- {
- if (user_t != Anope::string::npos && host_t > user_t)
- return this->mask.substr(user_t + 1, host_t - user_t - 1);
- else
- return this->mask.substr(0, host_t);
- }
- else
- return "";
+ return user;
}
-Anope::string XLine::GetHost() const
+const Anope::string &XLine::GetHost() const
{
- size_t host_t = this->mask.find('@'), real_t = this->mask.find('#');
-
- if (host_t != Anope::string::npos)
- {
- if (real_t != Anope::string::npos && real_t > host_t)
- return this->mask.substr(host_t + 1, real_t - host_t - 1);
- else
- return this->mask.substr(host_t + 1);
- }
- else
- {
- if (real_t != Anope::string::npos)
- return this->mask.substr(0, real_t);
- else
- return this->mask;
- }
+ return host;
}
-Anope::string XLine::GetReal() const
+const Anope::string &XLine::GetReal() const
{
- size_t real_t = this->mask.find('#');
-
- if (real_t != Anope::string::npos)
- return this->mask.substr(real_t + 1);
- else
- return "";
+ return real;
}
Anope::string XLine::GetReason() const