From 483ec8439c6564f8e3783223a01c641326b6f2d8 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 29 Apr 2005 08:28:33 +0000 Subject: [PATCH] A few anti-flood features git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1260 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/users.h | 5 +++++ src/inspircd.cpp | 12 ++++++++++++ src/xline.cpp | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/users.h b/include/users.h index a897d8282..a607f12c5 100644 --- a/include/users.h +++ b/include/users.h @@ -179,6 +179,11 @@ class userrec : public connection */ std::string recvq; + /** Flood counters + */ + long lines_in; + time_t reset_due; + userrec(); virtual ~userrec() { } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c42306a30..2558f3efc 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -4101,6 +4101,18 @@ int InspIRCd(void) while (current->BufferIsReady()) { floodlines++; + if (TIME > current->reset_due) + { + current->reset_due = TIME+3; + current->lines_in = 0; + } + current->lines_in++; + if (current->lines_in > current->flood) + { + log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); + WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); + kill_link(current,"Excess flood"); + } if ((floodlines > current->flood) && (current->flood != 0)) { if (current->registered == 7) diff --git a/src/xline.cpp b/src/xline.cpp index 35ebc50f3..92f5ac3a4 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -663,7 +663,7 @@ void apply_lines() char* check = matches_gline(host); if (check) { - WriteOpers("*** User %s matches G-Line: %s",u->registered == 7 ? u->second->nick:"",check); + WriteOpers("*** User %s matches G-Line: %s",u->second->registered == 7 ? u->second->nick:"",check); snprintf(reason,MAXBUF,"G-Lined: %s",check); kill_link(u->second,reason); go_again = true; @@ -675,7 +675,7 @@ void apply_lines() char* check = matches_kline(host); if (check) { - WriteOpers("*** User %s matches K-Line: %s",u->registered == 7 ? u->second->nick:"",check); + WriteOpers("*** User %s matches K-Line: %s",u->second->registered == 7 ? u->second->nick:"",check); snprintf(reason,MAXBUF,"K-Lined: %s",check); kill_link(u->second,reason); go_again = true; @@ -688,7 +688,7 @@ void apply_lines() if (check) { snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check); - WriteOpers("*** Q-Lined nickname %s from %s: %s",u->registered == 7 ? u->second->nick:"",u->second->host,check); + WriteOpers("*** Q-Lined nickname %s from %s: %s",u->second->registered == 7 ? u->second->nick:"",u->second->host,check); kill_link(u->second,reason); go_again = true; break; @@ -700,7 +700,7 @@ void apply_lines() if (check) { snprintf(reason,MAXBUF,"Z-Lined: %s",check); - WriteOpers("*** User %s matches Z-Line: %s",u->registered == 7 ? u->second->nick:"",u->second->host,check); + WriteOpers("*** User %s matches Z-Line: %s",u->second->registered == 7 ? u->second->nick:"",u->second->host,check); kill_link(u->second,reason); go_again = true; break; -- 2.39.5