summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h1
-rw-r--r--include/inspircd_io.h4
-rw-r--r--src/helperfuncs.cpp39
-rw-r--r--src/inspircd.cpp10
-rw-r--r--src/inspircd_io.cpp5
5 files changed, 55 insertions, 4 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 68289d5ee..346287462 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -131,5 +131,6 @@ class InspIRCd
/* userrec optimization stuff */
void AddServerName(std::string servername);
const char* FindServerNamePtr(std::string servername);
+bool FindServerName(std::string servername);
#endif
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index da592d6c4..a3190cd6a 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -220,6 +220,10 @@ class ServerConfig : public classbase
*/
int DieDelay;
+ /** True if we're going to hide netsplits as *.net *.split for non-opers
+ */
+ bool HideSplits;
+
/** A list of IP addresses the server is listening
* on.
*/
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 922d2b7f6..c6396705c 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -637,7 +637,6 @@ void WriteCommon_NoFormat(userrec *u, const char* text)
}
-
/* write a formatted string to all users who share at least one common
* channel, NOT including the source user e.g. for use in QUIT */
@@ -655,11 +654,34 @@ void WriteCommonExcept(userrec *u, char* text, ...)
}
char textbuffer[MAXBUF];
+ char oper_quit[MAXBUF];
+ bool quit_munge = false;
+
va_list argsPtr;
va_start (argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ int total = vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
+ if ((Config->HideSplits) && (total > 6))
+ {
+ /* Yeah yeah, this is ugly. But its fast, live with it. */
+ char* check = textbuffer;
+ if ((*check++ == 'Q') && (*check++ == 'U') && (*check++ == 'I') && (*check++ == 'T') && (*check++ == ' ') && (*check++ == ':'))
+ {
+ std::stringstream split(check);
+ std::string server_one;
+ std::string server_two;
+ split >> server_one;
+ split >> server_two;
+ if ((FindServerName(server_one)) && (FindServerName(server_two)))
+ {
+ strlcpy(oper_quit,textbuffer,MAXBUF);
+ strlcpy(check,"*.net *.split",MAXQUIT);
+ quit_munge = true;
+ }
+ }
+ }
+
memset(&already_sent,0,MAX_DESCRIPTORS);
unsigned int y = u->chans.size();
@@ -677,7 +699,18 @@ void WriteCommonExcept(userrec *u, char* text, ...)
if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
{
already_sent[otheruser->fd] = 1;
- WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
+ if (quit_munge)
+ {
+ if (*otheruser->oper)
+ {
+ WriteFrom_NoFormat(otheruser->fd,u,oper_quit);
+ }
+ else
+ {
+ WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
+ }
+ }
+ else WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
}
}
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 6f61fbb31..4ce203a94 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -114,6 +114,16 @@ const char* FindServerNamePtr(std::string servername)
return FindServerNamePtr(servername);
}
+bool FindServerName(std::string servername)
+{
+ for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
+ {
+ if (*a == servername)
+ return true;
+ }
+ return false;
+}
+
std::string InspIRCd::GetRevision()
{
/* w00t got me to replace a bunch of strtok_r
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 8534af18e..88cb1438f 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -52,6 +52,7 @@ ServerConfig::ServerConfig()
nofork = false;
unlimitcore = false;
AllowHalfop = true;
+ HideSplits = false;
dns_timeout = 5;
MaxTargets = 20;
NetBufferSize = 10240;
@@ -149,7 +150,7 @@ void ServerConfig::Read(bool bail, userrec* user)
{
char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF],MCON[MAXBUF],MT[MAXBUF];
char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF],thold[MAXBUF],sqmax[MAXBUF],rqmax[MAXBUF],SLIMT[MAXBUF];
- char localmax[MAXBUF],globalmax[MAXBUF];
+ char localmax[MAXBUF],globalmax[MAXBUF],HS[MAXBUF];
ConnectClass c;
std::stringstream errstr;
include_stack.clear();
@@ -225,7 +226,9 @@ void ServerConfig::Read(bool bail, userrec* user)
ConfValue("options","operonlystats",0,Config->OperOnlyStats,&Config->config_f);
ConfValue("options","customversion",0,Config->CustomVersion,&Config->config_f);
ConfValue("options","maxtargets",0,MT,&Config->config_f);
+ ConfValue("options","hidesplits",0,HS,&Config->config_f);
+ Config->HideSplits = ((*HS == 'y') || (*HS == 'Y') || (*HS == '1') || (*HS == 't') || (*HS == 'T'));
Config->SoftLimit = atoi(SLIMT);
if (*MT)
Config->MaxTargets = atoi(MT);