diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-25 20:47:35 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-25 20:47:35 +0000 |
commit | e63acfd42200a41705bf4469c8507366592a7100 (patch) | |
tree | 143cd0863c1da242948b9bb76dfbb8a9a6d86cda | |
parent | 77b32677820dfa6ce92395d6d6c02c80f84485b0 (diff) |
Added MaxWhoReplies stuff (bahamut-style /WHO limiting)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@729 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | docs/inspircd.conf.example | 6 | ||||
-rw-r--r-- | src/InspIRCd.layout | 30 | ||||
-rw-r--r-- | src/commands.cpp | 12 | ||||
-rw-r--r-- | src/inspircd.cpp | 14 | ||||
-rw-r--r-- | src/xline.cpp | 3 |
5 files changed, 43 insertions, 22 deletions
diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index b0884a8f6..a3b92ecdc 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -263,10 +263,16 @@ # netbuffersize - size of the buffer used to receive data from # # clients. The ircd may only read() this amount # # of text in one go at any time. (OPTIONAL) # +# maxwho - The maximum number of results returned by a /WHO # +# query. This is to prevent /WHO being used as a # +# spam vector or means of flooding an ircd. The # +# default is 128, it is not recommended to raise it # +# above 1024. Values up to 65535 are permitted. # <options prefixquit="Quit: " loglevel="default" netbuffersize="10240" + maxwho="128" allowhalfop="yes" allowprotect="yes" allowfounder="yes"> diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 579edf005..e7f27450b 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=-1 +Focused=43 Order=2,4,6,3,7,25,5,24,39,42,43,-1,1,46,0 [Editor_0] @@ -14,8 +14,8 @@ LeftChar=1 Open=1 Top=0 CursorCol=1 -CursorRow=1 -TopLine=1 +CursorRow=2159 +TopLine=2134 LeftChar=1 [Editor_2] @@ -329,11 +329,11 @@ TopLine=618 LeftChar=1 [Editor_43] Open=1 -Top=0 -CursorCol=10 -CursorRow=2321 -TopLine=2290 -LeftChar=1 +Top=1 +CursorCol=75 +CursorRow=787 +TopLine=760 +LeftChar=39 [Editor_44] Open=1 Top=0 @@ -343,15 +343,15 @@ TopLine=16 LeftChar=1 [Editor_45] Open=1 -Top=1 -CursorCol=5 -CursorRow=92 -TopLine=41 +Top=0 +CursorCol=12 +CursorRow=122 +TopLine=77 LeftChar=1 [Editor_46] Open=1 Top=0 -CursorCol=57 -CursorRow=346 -TopLine=297 +CursorCol=1 +CursorRow=605 +TopLine=563 LeftChar=1 diff --git a/src/commands.cpp b/src/commands.cpp index d5ec4307c..6873e4e9c 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -68,6 +68,7 @@ extern int WHOWAS_MAX; extern int DieDelay; extern time_t startup_time; extern int NetBufferSize; +int MaxWhoResults; extern time_t nb_start; extern std::vector<int> fd_reap; @@ -778,12 +779,17 @@ void handle_who(char **parameters, int pcnt, userrec *user) { if (user->chans[0].channel) { - Ptr = user->chans[0].channel; + int n_list = 0; for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) { - if ((common_channels(user,i->second)) && (isnick(i->second->nick))) + Ptr = i->second->chans[0].channel; + // suggested by phidjit and FCS + if ((!common_channels(user,i->second)) && (isnick(i->second->nick))) { - WriteServ(user->fd,"352 %s %s %s %s %s %s Hr@ :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, i->second->fullname); + WriteServ(user->fd,"352 %s %s %s %s %s %s Hr@ :0 %s",user->nick, Ptr ? Ptr->name : "*", i->second->ident, i->second->dhost, i->second->server, i->second->nick, i->second->fullname); + n_list++; + if (n_list > MaxWhoResults) + break; } } } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index e7afdb5ff..064259c06 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -82,6 +82,7 @@ int WHOWAS_MAX = 100; // default 100 people maximum in the WHOWAS list int DieDelay = 5; time_t startup_time = time(NULL); int NetBufferSize = 10240; // NetBufferSize used as the buffer size for all read() ops +extern int MaxWhoResults; time_t nb_start = 0; extern vector<Module*> modules; @@ -299,7 +300,7 @@ void readfile(file_cache &F, const char* fname) void ReadConfig(void) { - char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF]; + char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF]; ConnectClass c; LoadConf(CONFIG_FILE,&config_f); @@ -319,12 +320,19 @@ void ReadConfig(void) ConfValue("die","value",0,DieValue,&config_f); ConfValue("options","loglevel",0,dbg,&config_f); ConfValue("options","netbuffersize",0,NB,&config_f); + ConfValue("options","maxwho",0,MW,&config_f); NetBufferSize = atoi(NB); + MaxWhoResults = atoi(MW); if ((!NetBufferSize) || (NetBufferSize > 65535) || (NetBufferSize < 1024)) { log(DEFAULT,"No NetBufferSize specified or size out of range, setting to default of 10240."); NetBufferSize = 10240; } + if ((!MaxWhoResults) || (MaxWhoResults > 65535) || (MaxWhoResults < 1)) + { + log(DEFAULT,"No MaxWhoResults specified or size out of range, setting to default of 128."); + MaxWhoResults = 128; + } if (!strcmp(dbg,"debug")) LogLevel = DEBUG; if (!strcmp(dbg,"verbose")) @@ -2096,7 +2104,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) clientlist[tempnick] = new userrec(); NonBlocking(socket); - log(DEBUG,"AddClient: %d %s %d",socket,host,port); + log(DEBUG,"AddClient: %d %s %d %s",socket,host,port,ip); clientlist[tempnick]->fd = socket; strncpy(clientlist[tempnick]->nick, tn2,NICKMAX); @@ -3545,7 +3553,7 @@ int InspIRCd(void) } else { - AddClient(incomingSockfd, resolved, ports[count], iscached, target); + AddClient(incomingSockfd, resolved, ports[count], iscached, inet_ntoa (client.sin_addr)); log(DEBUG,"InspIRCd: adding client on port %d fd=%d",ports[count],incomingSockfd); } goto label; diff --git a/src/xline.cpp b/src/xline.cpp index 64753674d..c8aa4872a 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -602,8 +602,9 @@ void apply_lines() char* check = matches_zline(u->second->ip); if (check) { + snprintf(reason,MAXBUF,"Z-Lined: %s",check); WriteOpers("*** User %s matches Z-Line: %s",u->second->nick,u->second->host,check); - WriteServ(u->second->fd,"432 %s %s :Invalid nickname: %s",u->second->nick,u->second->nick,check); + kill_link(u->second,reason); go_again = true; break; } |