diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-04 21:31:02 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-04 21:31:02 +0000 |
commit | 9127c14d3452d0b3f8820f696e0bf35656622262 (patch) | |
tree | 4cba42e3a3ec89c84643b74f74d1828f27a2a731 /src/modules/m_cloaking.cpp | |
parent | dae8024a466a0a90f03222d31e34555b9b612509 (diff) |
Completed support for module-handled umodes
Updated m_cloaking to auto-set mode +x, and update cloaking status as its added/removed from users
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@378 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_cloaking.cpp')
-rw-r--r-- | src/modules/m_cloaking.cpp | 64 |
1 files changed, 52 insertions, 12 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"); + } + }; |