diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/messages.cpp | 2 | ||||
-rw-r--r-- | src/modes.cpp | 2 | ||||
-rw-r--r-- | src/sockets.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 5 | ||||
-rw-r--r-- | src/xline.cpp | 102 |
5 files changed, 67 insertions, 59 deletions
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 |