From b70de5aa7840e8b43c9c5bdbeb0146ec1d5ea1a0 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 14 Dec 2005 09:43:31 +0000 Subject: Added parameter to apply_lines to indicate what we want to apply git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2391 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/xline.h | 7 ++++++- src/commands.cpp | 8 ++++---- src/message.cpp | 2 +- src/userprocess.cpp | 6 +++--- src/xline.cpp | 20 ++++++++++---------- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/xline.h b/include/xline.h index 9ba1358aa..dad0ed238 100644 --- a/include/xline.h +++ b/include/xline.h @@ -28,6 +28,11 @@ #include "users.h" #include "channels.h" +const int APPLY_GLINES = 1; +const int APPLY_KLINES = 2; +const int APPLY_QLINES = 4; +const int APPLY_ZLINES = 8; +const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES; /** XLine is the base class for ban lines such as G lines and K lines. */ @@ -139,7 +144,7 @@ char* matches_kline(const char* host); char* matches_exception(const char* host); void expire_lines(); -void apply_lines(); +void apply_lines(const int What); void stats_k(userrec* user); void stats_g(userrec* user); diff --git a/src/commands.cpp b/src/commands.cpp index 2c351868c..df02b67c9 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1950,6 +1950,7 @@ void handle_kline(char **parameters, int pcnt, userrec *user) { WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); } + apply_lines(APPLY_KLINES); } else { @@ -1963,7 +1964,6 @@ void handle_kline(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,parameters[0]); } } - apply_lines(); } void handle_eline(char **parameters, int pcnt, userrec *user) @@ -2014,6 +2014,7 @@ void handle_gline(char **parameters, int pcnt, userrec *user) { WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); } + apply_lines(APPLY_GLINES); } else { @@ -2027,7 +2028,6 @@ void handle_gline(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"NOTICE %s :*** G-Line %s not found in list, try /stats g.",user->nick,parameters[0]); } } - apply_lines(); } void handle_zline(char **parameters, int pcnt, userrec *user) @@ -2051,6 +2051,7 @@ void handle_zline(char **parameters, int pcnt, userrec *user) { WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); } + apply_lines(APPLY_ZLINES); } else { @@ -2064,7 +2065,6 @@ void handle_zline(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]); } } - apply_lines(); } void handle_qline(char **parameters, int pcnt, userrec *user) @@ -2083,6 +2083,7 @@ void handle_qline(char **parameters, int pcnt, userrec *user) { WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); } + apply_lines(APPLY_QLINES); } else { @@ -2096,7 +2097,6 @@ void handle_qline(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"NOTICE %s :*** Q-Line %s not found in list, try /stats k.",user->nick,parameters[0]); } } - apply_lines(); } diff --git a/src/message.cpp b/src/message.cpp index 8adf50793..ce51f8c87 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -104,7 +104,7 @@ void tidystring(char* str) while (go_again) { bool noparse = false; - unsigned int t = 0, a = 0; + int t = 0, a = 0; go_again = false; const int lenofstr = strlen(str); diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 551573fed..d82e3ddd5 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -175,7 +175,7 @@ void ProcessUser(userrec* cu) WriteOpers("*** Excess flood from %s",current->ip); log(DEFAULT,"Excess flood from: %s",current->ip); add_zline(120,ServerName,"Flood from unregistered connection",current->ip); - apply_lines(); + apply_lines(APPLY_ZLINES); } return; } @@ -190,7 +190,7 @@ void ProcessUser(userrec* cu) WriteOpers("*** Excess flood from %s",current->ip); log(DEFAULT,"Excess flood from: %s",current->ip); add_zline(120,ServerName,"Flood from unregistered connection",current->ip); - apply_lines(); + apply_lines(APPLY_ZLINES); } return; } @@ -222,7 +222,7 @@ void ProcessUser(userrec* cu) else { add_zline(120,ServerName,"Flood from unregistered connection",current->ip); - apply_lines(); + apply_lines(APPLY_ZLINES); } return; } diff --git a/src/xline.cpp b/src/xline.cpp index c06d977fa..0815f3c61 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -457,7 +457,7 @@ bool del_kline(const char* hostmask) char* matches_qline(const char* nick) { - if (qlines.empty()) + if ((qlines.empty()) && (pqlines.empty())) return NULL; for (std::vector::iterator i = qlines.begin(); i != qlines.end(); i++) if (match(nick,i->nick)) @@ -472,7 +472,7 @@ char* matches_qline(const char* nick) char* matches_gline(const char* host) { - if (glines.empty()) + if ((glines.empty()) && (pglines.empty())) return NULL; for (std::vector::iterator i = glines.begin(); i != glines.end(); i++) if (match(host,i->hostmask)) @@ -485,7 +485,7 @@ char* matches_gline(const char* host) char* matches_exception(const char* host) { - if (elines.empty()) + if ((elines.empty()) && (pelines.empty())) return NULL; char host2[MAXBUF]; snprintf(host2,MAXBUF,"*@%s",host); @@ -587,7 +587,7 @@ void zline_set_creation_time(char* ip, time_t create_time) char* matches_zline(const char* ipaddr) { - if (zlines.empty()) + if ((zlines.empty()) && (pzlines.empty())) return NULL; for (std::vector::iterator i = zlines.begin(); i != zlines.end(); i++) if (match(ipaddr,i->ipaddr)) @@ -602,7 +602,7 @@ char* matches_zline(const char* ipaddr) char* matches_kline(const char* host) { - if (klines.empty()) + if ((klines.empty()) && (pklines.empty())) return NULL; for (std::vector::iterator i = klines.begin(); i != klines.end(); i++) if (match(host,i->hostmask)) @@ -688,7 +688,7 @@ void expire_lines() // applies lines, removing clients and changing nicks etc as applicable -void apply_lines() +void apply_lines(const int What) { bool go_again = true; char reason[MAXBUF]; @@ -711,7 +711,7 @@ void apply_lines() if (matches_exception(host)) continue; } - if (glines.size() || pglines.size()) + if ((What & APPLY_GLINES) && (glines.size() || pglines.size())) { char* check = matches_gline(host); if (check) @@ -723,7 +723,7 @@ void apply_lines() break; } } - if (klines.size() || pklines.size()) + if ((What & APPLY_KLINES) && (klines.size() || pklines.size())) { char* check = matches_kline(host); if (check) @@ -735,7 +735,7 @@ void apply_lines() break; } } - if (qlines.size() || pqlines.size()) + if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size())) { char* check = matches_qline(u->second->nick); if (check) @@ -747,7 +747,7 @@ void apply_lines() break; } } - if (zlines.size() || pzlines.size()) + if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size())) { char* check = matches_zline(u->second->ip); if (check) -- cgit v1.2.3