diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-03 00:25:28 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-03 00:25:28 +0000 |
commit | 38d7b5b0d9206e85dcf531036b863a0864c35f93 (patch) | |
tree | 076cb0083bfe6c2d58364c0a1c74f89e61fbfea3 /src | |
parent | c266d3e4b8201929a3b1c5c358fffb748b2b6c47 (diff) |
*EXPERIMENTAL* <options:hidesplits> ircu-style quit munging for netsplits
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3031 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/helperfuncs.cpp | 39 | ||||
-rw-r--r-- | src/inspircd.cpp | 10 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 5 |
3 files changed, 50 insertions, 4 deletions
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); |