From b2c011a23adfb2472f51a4c18bf8f29e6e37bb04 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 12 May 2005 00:36:20 +0000 Subject: Customizable by-byte-size recvq stuff git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1365 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/inspircd.conf.example | 17 +++++++++++++++-- include/users.h | 11 ++++++++++- src/inspircd.cpp | 11 ++++++++++- src/users.cpp | 5 +++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index 6b4c03f8f..089079bd1 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -108,7 +108,7 @@ # # # # # # -# # +# # # # # # # You may optionally include timeout="x" on any allow line, which # @@ -133,9 +133,22 @@ # dynamically allocated and can grow as needed up to the maximum # # size specified. # # # +# The optional recvq value is the maximum size which users in this # +# group may grow their receive queue to. This is recommended to be # +# kept pretty low compared to the sendq, as users will always # +# recieve more than they send in normal circumstances. The default # +# if not specified is 4096. # +# # +# IMPORTANT NOTE, CALL THE CONFUSION POLICE! # +# The sendq is the data waiting to be sent TO THE USER. # +# The recvq is the data being received FROM THE USER. # +# The names sendq and recvq are from the SERVER'S PERSPECTIVE not # +# that of the user... Just to clear up any confusion or complaints # +# that these are backwards :p # +# # - + diff --git a/include/users.h b/include/users.h index 3e4afe88f..44005bb92 100644 --- a/include/users.h +++ b/include/users.h @@ -68,9 +68,13 @@ class ConnectClass : public classbase */ long threshold; - /** Maximum size of sendq for users in this class + /** Maximum size of sendq for users in this class (bytes) */ long sendqmax; + + /** Maximum size of recvq for users in this class (bytes) + */ + long recvqmax; ConnectClass() { @@ -79,6 +83,7 @@ class ConnectClass : public classbase pingtime = 0; threshold = 0; sendqmax = 0; + recvqmax = 0; strlcpy(host,"",MAXBUF); strlcpy(pass,"",MAXBUF); } @@ -208,6 +213,10 @@ class userrec : public connection */ long sendqmax; + /** Maximum size this user's recvq can become + */ + long recvqmax; + userrec(); virtual ~userrec() { } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a4e9b1934..cf68705cb 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -357,7 +357,7 @@ void readfile(file_cache &F, const char* fname) void ReadConfig(bool bail, userrec* user) { char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF]; - char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF],thold[MAXBUF],sqmax[MAXBUF]; + char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF],thold[MAXBUF],sqmax[MAXBUF],rqmax[MAXBUF]; ConnectClass c; std::stringstream errstr; @@ -464,6 +464,7 @@ void ReadConfig(bool bail, userrec* user) ConfValue("connect","pingfreq",i,pfreq,&config_f); ConfValue("connect","threshold",i,thold,&config_f); ConfValue("connect","sendq",i,sqmax,&config_f); + ConfValue("connect","recvq",i,rqmax,&config_f); if (Value[0]) { strlcpy(c.host,Value,MAXBUF); @@ -476,6 +477,7 @@ void ReadConfig(bool bail, userrec* user) c.flood = atoi(flood); c.threshold = 5; c.sendqmax = 262144; // 256k + c.recvqmax = 4096; // 4k if (atoi(thold)>0) { c.threshold = atoi(thold); @@ -484,6 +486,10 @@ void ReadConfig(bool bail, userrec* user) { c.sendqmax = atoi(sqmax); } + if (atoi(rqmax)>0) + { + c.recvqmax = atoi(rqmax); + } if (atoi(timeout)>0) { c.registration_timeout = atoi(timeout); @@ -2540,6 +2546,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) int class_flood = 0; long class_threshold = 5; long class_sqmax = 262144; // 256kb + long class_rqmax = 4096; // 4k for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++) { @@ -2550,6 +2557,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) clientlist[tempnick]->pingmax = i->pingtime; class_threshold = i->threshold; class_sqmax = i->sendqmax; + class_rqmax = i->recvqmax; break; } } @@ -2559,6 +2567,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) clientlist[tempnick]->flood = class_flood; clientlist[tempnick]->threshold = class_threshold; clientlist[tempnick]->sendqmax = class_sqmax; + clientlist[tempnick]->recvqmax = class_rqmax; for (int i = 0; i < MAXCHANS; i++) { diff --git a/src/users.cpp b/src/users.cpp index 9d0367a9a..0060b45ee 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -183,6 +183,11 @@ bool userrec::AddBuffer(std::string a) if (recvq[i++] == '\n') break; } + if (recvq.length() > this->recvqmax) + { + this->SetWriteError("RecvQ exceeded"); + WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax); + } // return false if we've had more than 600 characters WITHOUT // a carriage return (this is BAD, drop the socket) return (i < 600); -- cgit v1.2.3