Revert r2016

That revision added CAP support to fixfreenode, blocking the identify-msg
capability. This is no longer necessary thanks to the previous commit.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2023 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-06-13 07:37:47 +00:00
parent 99ea9c6ff7
commit 6c405e7239
+1 -69
View File
@@ -7,87 +7,19 @@
*/
#include "Modules.h"
#include "User.h"
class CPreventIdMsgMod : public CModule {
public:
MODCONSTRUCTOR(CPreventIdMsgMod) {}
/* Old style:
* -> CAPAB :identify-msg
* We just block this request from the client.
*
* New style:
* -> CAP LS
* <- :farmer.freenode.net CAP <nick> LS :identify-msg <other stuff>
* -> CAP REQ :identify-msg
* <- :farmer.freenode.net CAP a ACK :identify-msg
* We block the identify-msg token from CAP LS and CAP REQ,
* just to be sure.
*/
// Returns true if an "identify-msg" was skipped
static bool MakeCleanCapList(CString& sList) {
bool bRet = false;
VCString vsList;
sList.Split(" ", vsList);
sList = "";
// Append each token to the output list
for (VCString::const_iterator it = vsList.begin();
it != vsList.end(); ++it) {
if (!it->Equals("identify-msg")) {
sList += *it + " ";
} else {
bRet = true;
}
}
// Remove the last space we added
sList.RightChomp();
return bRet;
}
virtual EModRet OnUserRaw(CString& sLine) {
if (sLine.Token(0).Equals("CAPAB")) {
if (sLine.Token(0).AsLower() == "capab") {
if (sLine.AsLower().find("identify-msg") != CString::npos
|| sLine.AsLower().find("identify-ctcp") != CString::npos)
return HALTCORE;
} else if (sLine.Token(0).Equals("CAP")) {
if (sLine.Token(1).Equals("REQ")) {
CString sList = sLine.Token(2, true).TrimPrefix_n(":");
if (MakeCleanCapList(sList)) {
// There was an identify-msg requested,
// block the whole list
PutUser(":irc.znc.in CAP " + m_pUser->GetIRCNick().GetNick()
+ " NAK " + sLine.Token(2, true));
return HALTCORE;
}
}
}
return CONTINUE;
}
virtual EModRet OnRaw(CString& sLine) {
if (!sLine.Token(1).Equals("CAP"))
return CONTINUE;
if (!sLine.Token(3).Equals("LS"))
return CONTINUE;
// It's CAP LS, strip identify-msg
// First, copy over the "prefix" from the old line
CString sNewLine = sLine.Token(0) + " " + sLine.Token(1) + " ";
sNewLine += sLine.Token(2) + " " + sLine.Token(3) + " :";
// Grab the list of CAP tokens and clean them up
CString sTokens = sLine.Token(4, true).TrimPrefix_n(":");
MakeCleanCapList(sTokens);
sLine = sNewLine + sTokens;
return CONTINUE;
}
};
MODULEDEFS(CPreventIdMsgMod, "Prevent client from sending IDENTIFY-MSG to server")