summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp21
-rw-r--r--src/inspircd.cpp62
-rw-r--r--src/users.cpp12
-rw-r--r--src/xline.cpp6
4 files changed, 90 insertions, 11 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index c098bbb10..610b694bc 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1863,18 +1863,25 @@ void handle_V(char token,char* params,serverrec* source,serverrec* reply, char*
userrec* user = Find(src);
if (user)
{
- userrec* dst = Find(dest);
-
- if (dst)
+ // notice all - only issuable by a server
+ if (strcmp(dest,"*"))
{
- WriteTo(user, dst, "NOTICE %s :%s", dst->nick, text);
+ NoticeAll(user,true,"%s",text);
}
else
{
- chanrec* d = FindChan(dest);
- if (d)
+ userrec* dst = Find(dest);
+ if (dst)
{
- ChanExceptSender(d, user, "NOTICE %s :%s", d->name, text);
+ WriteTo(user, dst, "NOTICE %s :%s", dst->nick, text);
+ }
+ else
+ {
+ chanrec* d = FindChan(dest);
+ if (d)
+ {
+ ChanExceptSender(d, user, "NOTICE %s :%s", d->name, text);
+ }
}
}
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 3c2ab09a8..59256f8c0 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -341,7 +341,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];
+ char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF],thold[MAXBUF];
ConnectClass c;
std::stringstream errstr;
@@ -446,6 +446,7 @@ void ReadConfig(bool bail, userrec* user)
ConfValue("connect","timeout",i,timeout,&config_f);
ConfValue("connect","flood",i,flood,&config_f);
ConfValue("connect","pingfreq",i,pfreq,&config_f);
+ ConfValue("connect","threshold",i,thold,&config_f);
if (Value[0])
{
strlcpy(c.host,Value,MAXBUF);
@@ -456,6 +457,11 @@ void ReadConfig(bool bail, userrec* user)
c.registration_timeout = 90; // default is 2 minutes
c.pingtime = 120;
c.flood = atoi(flood);
+ c.threshold = 5;
+ if (atoi(thold)>0)
+ {
+ c.threshold = atoi(thold);
+ }
if (atoi(timeout)>0)
{
c.registration_timeout = atoi(timeout);
@@ -1171,6 +1177,37 @@ void WriteMode(const char* modes, int flags, const char* text, ...)
}
+void NoticeAll(userrec *source, bool local_only, char* text, ...)
+{
+ if ((!text) || (!source))
+ {
+ log(DEFAULT,"*** BUG *** WriteOpers was given an invalid parameter");
+ return;
+ }
+
+ char textbuffer[MAXBUF];
+ va_list argsPtr;
+ va_start (argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ if ((i->second) && (i->second->fd != FD_MAGIC_NUMBER))
+ {
+ WriteFrom(i->second->fd,source,"NOTICE $* :%s",textbuffer);
+ }
+ }
+
+ if (!local_only)
+ {
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF,"V %s * :%s",source->nick,textbuffer);
+ NetSendToAll(buffer);
+ }
+
+}
+
void WriteWallOps(userrec *source, bool local_only, char* text, ...)
{
if ((!text) || (!source))
@@ -2414,6 +2451,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
// set the registration timeout for this user
unsigned long class_regtimeout = 90;
int class_flood = 0;
+ long class_threshold = 5;
for (ClassVector::iterator i = Classes.begin(); i != Classes.end(); i++)
{
@@ -2422,6 +2460,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
class_regtimeout = (unsigned long)i->registration_timeout;
class_flood = i->flood;
clientlist[tempnick]->pingmax = i->pingtime;
+ class_threshold = i->threshold;
break;
}
}
@@ -2429,6 +2468,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax+dns_timeout;
clientlist[tempnick]->timeout = TIME+class_regtimeout;
clientlist[tempnick]->flood = class_flood;
+ clientlist[tempnick]->threshold = class_threshold;
for (int i = 0; i < MAXCHANS; i++)
{
@@ -4081,7 +4121,23 @@ int InspIRCd(void)
userrec* current = count2a->second;
int currfd = current->fd;
int floodlines = 0;
- current->AddBuffer(data);
+ // add the data to the users buffer
+ if (!current->AddBuffer(data))
+ {
+ // AddBuffer returned false, theres too much data in the user's buffer and theyre up to no good.
+ if (current->registered == 7)
+ {
+ kill_link(current,"RecvQ exceeded");
+ }
+ else
+ {
+ 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();
+ }
+ goto label;
+ }
if (current->recvq.length() > NetBufferSize)
{
if (current->registered == 7)
@@ -4103,7 +4159,7 @@ int InspIRCd(void)
floodlines++;
if (TIME > current->reset_due)
{
- current->reset_due = TIME+3;
+ current->reset_due = TIME + current->threshold;
current->lines_in = 0;
}
current->lines_in++;
diff --git a/src/users.cpp b/src/users.cpp
index 0ece63bc9..0d305a3b7 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -166,7 +166,7 @@ bool userrec::HasPermission(char* command)
}
-void userrec::AddBuffer(std::string a)
+bool userrec::AddBuffer(std::string a)
{
std::string b = "";
for (int i = 0; i < a.length(); i++)
@@ -175,6 +175,16 @@ void userrec::AddBuffer(std::string a)
std::stringstream stream(recvq);
stream << b;
recvq = stream.str();
+ int i = 0;
+ // count the size of the first line in the buffer.
+ while (i < recvq.length())
+ {
+ if (recvq[i++] == '\n')
+ break;
+ }
+ // return false if we've had more than 600 characters WITHOUT
+ // a carriage return (this is BAD, drop the socket)
+ return (i < 600);
}
bool userrec::BufferIsReady()
diff --git a/src/xline.cpp b/src/xline.cpp
index 92f5ac3a4..7452d81f0 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -288,6 +288,12 @@ void add_zline(long duration, const char* source, const char* reason, const char
del_zline(ipaddr);
ZLine item;
item.duration = duration;
+ if (strchr(ipaddr,'@'))
+ {
+ while (*ipaddr != '@')
+ ipaddr++;
+ ipaddr++;
+ }
strlcpy(item.ipaddr,ipaddr,MAXBUF);
strlcpy(item.reason,reason,MAXBUF);
strlcpy(item.source,source,MAXBUF);