diff options
-rw-r--r-- | src/modules/m_cloaking.cpp | 64 | ||||
-rw-r--r-- | src/modules/m_testcommand.cpp | 3 |
2 files changed, 53 insertions, 14 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index d355ec657..c9fe71766 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -16,6 +16,15 @@ class ModuleCloaking : public Module ModuleCloaking() { Srv = new Server; + + // doesn't require oper, client umode with no params + // (actually, you cant have params for a umode!) + if (!Srv->AddExtendedMode('x',MT_CLIENT,false,0,0)) + { + Srv->Log(DEFAULT,"*** m_cloaking: ERROR, failed to allocate user mode +x!"); + printf("Could not claim usermode +x for this module!"); + exit(0); + } } virtual ~ModuleCloaking() @@ -25,25 +34,56 @@ class ModuleCloaking : public Module virtual Version GetVersion() { - return Version(1,0,0,0); + return Version(1,0,0,1); } - virtual void OnUserConnect(userrec* user) + virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms) { - if (strstr(user->dhost,".")) + Srv->Log(DEBUG,"in mode handler"); + if ((modechar == 'x') && (type == MT_CLIENT)) + { + Srv->Log(DEBUG,"this is my mode!"); + if (mode_on) + { + Srv->Log(DEBUG,"mode being turned on"); + if (strstr(user->host,".")) + { + std::string a = strstr(user->host,"."); + char ra[64]; + long seed,s2; + memcpy(&seed,user->host,sizeof(long)); + memcpy(&s2,a.c_str(),sizeof(long)); + sprintf(ra,"%.8X",seed*s2*strlen(user->host)); + std::string b = Srv->GetNetworkName() + "-" + ra + a; + Srv->Log(DEBUG,"cloak: allocated "+b); + strcpy(user->dhost,b.c_str()); + } + } + else + { + Srv->Log(DEBUG,"cloak: de-allocated cloak"); + strcpy(user->dhost,user->host); + } + return 1; + } + else { - std::string a = strstr(user->dhost,"."); - char ra[64]; - long seed,s2; - memcpy(&seed,user->dhost,sizeof(long)); - memcpy(&s2,a.c_str(),sizeof(long)); - sprintf(ra,"%.8X",seed*s2*strlen(user->host)); - std::string b = Srv->GetNetworkName() + "-" + ra + a; - Srv->Log(DEBUG,"cloak: allocated "+b); - strcpy(user->dhost,b.c_str()); + // this mode isn't ours, we have to bail and return 0 to not handle it. + Srv->Log(DEBUG,"not my mode"); + return 0; } } + virtual void OnUserConnect(userrec* user) + { + Srv->Log(DEBUG,"Sending SAMODE +x for user"); + char* modes[2]; + modes[0] = user->nick; + modes[1] = "+x"; + Srv->SendMode(modes,2,user); + Srv->Log(DEBUG,"Sent SAMODE +x for user"); + } + }; diff --git a/src/modules/m_testcommand.cpp b/src/modules/m_testcommand.cpp index b65430c5a..8f49277cd 100644 --- a/src/modules/m_testcommand.cpp +++ b/src/modules/m_testcommand.cpp @@ -60,14 +60,13 @@ class ModuleTestCommand : public Module virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms) { - if (modechar != 'Z') { + if ((modechar != 'Z') || (type != MT_CHANNEL)) { // this mode isn't ours, we have to bail and return 0 to not handle it. Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!"); return 0; } - // TODO: Add checking here - should bail with 0 value if the mode is already on or off if (mode_on) { Srv->Log(DEBUG,"Custom mode is being added to channel"); } |