X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fxline.cpp;h=accb5ce9f7f8b084ff018d4711b5448cd3b565ad;hb=59b1a8955142935b02af6446005ab47fc7c3fc8c;hp=93732fa2ad0adafef5754e02f8d99df19844e6d7;hpb=8ed28d1f98d4d4c653201f0c4273e74dd8a122e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/xline.cpp b/src/xline.cpp index 93732fa2a..accb5ce9f 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2005 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -19,7 +19,6 @@ using namespace std; #include "inspircd_config.h" #include "inspircd.h" #include "inspircd_io.h" -#include "inspircd_util.h" #include #include #include @@ -56,6 +55,7 @@ extern std::vector modules; extern std::vector factory; extern ServerConfig* Config; extern user_hash clientlist; +extern std::vector local_users; /* Version two, now with optimized expiry! * @@ -148,9 +148,9 @@ void read_xline_defaults() // adds a g:line -void add_gline(long duration, const char* source,const char* reason,const char* hostmask) +bool add_gline(long duration, const char* source,const char* reason,const char* hostmask) { - del_gline(hostmask); + bool ret = del_gline(hostmask); GLine item; item.duration = duration; strlcpy(item.hostmask,hostmask,199); @@ -167,13 +167,14 @@ void add_gline(long duration, const char* source,const char* reason,const char* { pglines.push_back(item); } + return !ret; } // adds an e:line (exception to bans) -void add_eline(long duration, const char* source, const char* reason, const char* hostmask) +bool add_eline(long duration, const char* source, const char* reason, const char* hostmask) { - del_eline(hostmask); + bool ret = del_eline(hostmask); ELine item; item.duration = duration; strlcpy(item.hostmask,hostmask,199); @@ -190,13 +191,14 @@ void add_eline(long duration, const char* source, const char* reason, const char { pelines.push_back(item); } + return !ret; } // adds a q:line -void add_qline(long duration, const char* source, const char* reason, const char* nickname) +bool add_qline(long duration, const char* source, const char* reason, const char* nickname) { - del_qline(nickname); + bool ret = del_qline(nickname); QLine item; item.duration = duration; strlcpy(item.nick,nickname,63); @@ -214,13 +216,14 @@ void add_qline(long duration, const char* source, const char* reason, const char { pqlines.push_back(item); } + return !ret; } // adds a z:line -void add_zline(long duration, const char* source, const char* reason, const char* ipaddr) +bool add_zline(long duration, const char* source, const char* reason, const char* ipaddr) { - del_zline(ipaddr); + bool ret = del_zline(ipaddr); ZLine item; item.duration = duration; if (strchr(ipaddr,'@')) @@ -244,13 +247,14 @@ void add_zline(long duration, const char* source, const char* reason, const char { pzlines.push_back(item); } + return !ret; } // adds a k:line -void add_kline(long duration, const char* source, const char* reason, const char* hostmask) +bool add_kline(long duration, const char* source, const char* reason, const char* hostmask) { - del_kline(hostmask); + bool ret = del_kline(hostmask); KLine item; item.duration = duration; strlcpy(item.hostmask,hostmask,200); @@ -267,6 +271,7 @@ void add_kline(long duration, const char* source, const char* reason, const char { pklines.push_back(item); } + return !ret; } // deletes a g:line, returns true if the line existed and was removed @@ -649,58 +654,53 @@ void apply_lines(const int What) { char reason[MAXBUF]; char host[MAXBUF]; - - if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size())) + + if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) && + (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size())) return; CullList* Goners = new CullList(); - - for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++) + char* check = NULL; + for (std::vector::const_iterator u2 = local_users.begin(); u2 != local_users.end(); u2++) { - if (u->second->fd > -1) + userrec* u = (userrec*)(*u2); + u->MakeHost(host); + if (elines.size() || pelines.size()) { - snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host); - if (elines.size()) - { - // ignore people matching exempts - if (matches_exception(host)) - continue; - } - if ((What & APPLY_GLINES) && (glines.size() || pglines.size())) + // ignore people matching exempts + if (matches_exception(host)) + continue; + } + if ((What & APPLY_GLINES) && (glines.size() || pglines.size())) + { + if ((check = matches_gline(host))) { - char* check = matches_gline(host); - if (check) - { - snprintf(reason,MAXBUF,"G-Lined: %s",check); - Goners->AddItem(u->second,reason); - } + snprintf(reason,MAXBUF,"G-Lined: %s",check); + Goners->AddItem(u,reason); } - if ((What & APPLY_KLINES) && (klines.size() || pklines.size())) + } + if ((What & APPLY_KLINES) && (klines.size() || pklines.size())) + { + if ((check = matches_kline(host))) { - char* check = matches_kline(host); - if (check) - { - snprintf(reason,MAXBUF,"K-Lined: %s",check); - Goners->AddItem(u->second,reason); - } + snprintf(reason,MAXBUF,"K-Lined: %s",check); + Goners->AddItem(u,reason); } - if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size())) + } + if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size())) + { + if ((check = matches_qline(u->nick))) { - char* check = matches_qline(u->second->nick); - if (check) - { - snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check); - Goners->AddItem(u->second,reason); - } + snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check); + Goners->AddItem(u,reason); } - if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size())) + } + if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size())) + { + if ((check = matches_zline((char*)inet_ntoa(u->ip4)))) { - char* check = matches_zline(u->second->ip); - if (check) - { - snprintf(reason,MAXBUF,"Z-Lined: %s",check); - Goners->AddItem(u->second,reason); - } + snprintf(reason,MAXBUF,"Z-Lined: %s",check); + Goners->AddItem(u,reason); } } } @@ -748,3 +748,4 @@ void stats_e(userrec* user) for (std::vector::iterator i = pelines.begin(); i != pelines.end(); i++) WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason); } +