From 7ee9ca88a8a4aa0d671d331cee7ae132c7c1e1a3 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 10 Sep 2006 17:28:03 +0000 Subject: Fix the new g/k/e line stuff to match ips. NOTE: this makes g/k/e much slower than z. By factors of about 3. If you want to match tons of users, as always use zline (for this and many other reasons) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5202 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 2 -- src/xline.cpp | 26 ++++++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/users.cpp b/src/users.cpp index ee348fac4..56d578687 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1068,8 +1068,6 @@ void userrec::FullConnect(CullList* Goners) return; } - char match_against[MAXBUF]; - snprintf(match_against,MAXBUF,"%s@%s", this->ident, this->host); char* e = ServerInstance->XLines->matches_exception(this); if (!e) diff --git a/src/xline.cpp b/src/xline.cpp index 2430283ce..17dfa3f63 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -383,28 +383,38 @@ char* XLineManager::matches_qline(const char* nick) char* XLineManager::matches_gline(userrec* user) { + char match1[MAXBUF]; + char match2[MAXBUF]; + snprintf(match1, MAXBUF, "%s@%s", user->ident, user->GetIPString()); + snprintf(match2, MAXBUF, "%s@%s", user->ident, user->host); + if ((glines.empty()) && (pglines.empty())) return NULL; for (std::vector::iterator i = glines.begin(); i != glines.end(); i++) - if (match(user->host,i->hostmask, true) || (match(user->GetIPString(),i->hostmask, true))) + if (match(match1,i->hostmask, true) || (match(match2,i->hostmask, true))) return i->reason; for (std::vector::iterator i = pglines.begin(); i != pglines.end(); i++) - if (match(user->host,i->hostmask, true) || (match(user->GetIPString(),i->hostmask, true))) + if (match(match1,i->hostmask, true) || (match(match2,i->hostmask, true))) return i->reason; return NULL; } char* XLineManager::matches_exception(userrec* user) { + char match1[MAXBUF]; + char match2[MAXBUF]; + snprintf(match1, MAXBUF, "%s@%s", user->ident, user->GetIPString()); + snprintf(match2, MAXBUF, "%s@%s", user->ident, user->host); + if ((elines.empty()) && (pelines.empty())) return NULL; char host2[MAXBUF]; snprintf(host2,MAXBUF,"*@%s",user->host); for (std::vector::iterator i = elines.begin(); i != elines.end(); i++) - if ((match(user->host,i->hostmask)) || (match(host2,i->hostmask, true)) || (match(user->GetIPString(),i->hostmask, true))) + if ((match(match1,i->hostmask)) || (match(host2,i->hostmask, true)) || (match(match2,i->hostmask, true))) return i->reason; for (std::vector::iterator i = pelines.begin(); i != pelines.end(); i++) - if ((match(user->host,i->hostmask)) || (match(host2,i->hostmask, true)) || (match(user->GetIPString(),i->hostmask, true))) + if ((match(match1,i->hostmask)) || (match(host2,i->hostmask, true)) || (match(match2,i->hostmask, true))) return i->reason; return NULL; } @@ -513,13 +523,17 @@ char* XLineManager::matches_zline(const char* ipaddr) char* XLineManager::matches_kline(userrec* user) { + char match1[MAXBUF]; + char match2[MAXBUF]; + snprintf(match1, MAXBUF, "%s@%s", user->ident, user->GetIPString()); + snprintf(match2, MAXBUF, "%s@%s", user->ident, user->host); if ((klines.empty()) && (pklines.empty())) return NULL; for (std::vector::iterator i = klines.begin(); i != klines.end(); i++) - if ((match(user->host,i->hostmask, true)) || (match(user->GetIPString(),i->hostmask, true))) + if ((match(match1,i->hostmask, true)) || (match(match2,i->hostmask, true))) return i->reason; for (std::vector::iterator i = pklines.begin(); i != pklines.end(); i++) - if ((match(user->host,i->hostmask, true)) || (match(user->GetIPString(),i->hostmask, true))) + if ((match(match1,i->hostmask, true)) || (match(match2,i->hostmask, true))) return i->reason; return NULL; } -- cgit v1.2.3