mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Added MaxWhoReplies stuff (bahamut-style /WHO limiting)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@729 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
77b3267782
commit
e63acfd422
@ -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">
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user