+ if (!item.empty())
+ {
+ /* Send the Hash module a different hex table for each octet group's Hash sum */
+ HashHexRequest(Sender, HashProvider, xtab[(key1+rounds) % 4]).Send();
+ hashies.push_back(std::string(HashSumRequest(Sender, HashProvider, item).Send()).substr(0,8));
+ item.clear();
+ }
+ /* Stick them all together */
+ return irc::stringjoiner(":", hashies, 0, hashies.size() - 1).GetJoined();
+ }
+
+ void DoRehash()
+ {
+ ConfigReader Conf(ServerInstance);
+ key1 = key2 = key3 = key4 = 0;
+ key1 = Conf.ReadInteger("cloak","key1",0,true);
+ key2 = Conf.ReadInteger("cloak","key2",0,true);
+ key3 = Conf.ReadInteger("cloak","key3",0,true);
+ key4 = Conf.ReadInteger("cloak","key4",0,true);
+ prefix = Conf.ReadValue("cloak","prefix",0);
+
+ if (prefix.empty())
+ prefix = ServerInstance->Config->Network;
+
+ if (!key1 && !key2 && !key3 && !key4)
+ throw ModuleException("You have not defined cloak keys for m_cloaking!!! THIS IS INSECURE AND SHOULD BE CHECKED!");
+ }
+};
+
+
+class ModuleCloaking : public Module
+{
+ private:
+
+ CloakUser* cu;
+ Module* HashModule;
+
+ public:
+ ModuleCloaking(InspIRCd* Me)
+ : Module(Me)
+ {
+ ServerInstance->UseInterface("HashRequest");
+
+ /* Attempt to locate the md5 service provider, bail if we can't find it */
+ HashModule = ServerInstance->FindModule("m_md5.so");
+ if (!HashModule)
+ throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_cloaking.so.");
+
+ /* Create new mode handler object */
+ cu = new CloakUser(ServerInstance, this, HashModule);
+
+ /* Register it with the core */
+ if (!ServerInstance->AddMode(cu, 'x'))
+ throw ModuleException("Could not add new modes!");
+
+ OnRehash(NULL,"");
+ }
+
+ virtual ~ModuleCloaking()
+ {
+ ServerInstance->Modes->DelMode(cu);
+ DELETE(cu);
+ ServerInstance->DoneWithInterface("HashRequest");
+ }
+
+ virtual Version GetVersion()
+ {
+ // returns the version number of the module to be
+ // listed in /MODULES
+ return Version(1,1,0,2,VF_COMMON|VF_VENDOR,API_VERSION);