7 /* $ModDesc: Provides masking of user hostnames */
9 class ModuleCloaking : public Module
20 // doesn't require oper, client umode with no params
21 // (actually, you cant have params for a umode!)
22 if (!Srv->AddExtendedMode('x',MT_CLIENT,false,0,0))
24 Srv->Log(DEFAULT,"*** m_cloaking: ERROR, failed to allocate user mode +x!");
25 printf("Could not claim usermode +x for this module!");
30 virtual ~ModuleCloaking()
35 virtual Version GetVersion()
37 return Version(1,0,0,1);
40 virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms)
42 Srv->Log(DEBUG,"in mode handler");
43 if ((modechar == 'x') && (type == MT_CLIENT))
45 Srv->Log(DEBUG,"this is my mode!");
48 Srv->Log(DEBUG,"mode being turned on");
49 if (strstr(user->host,"."))
51 std::string a = strstr(user->host,".");
54 memcpy(&seed,user->host,sizeof(long));
55 memcpy(&s2,a.c_str(),sizeof(long));
56 sprintf(ra,"%.8X",seed*s2*strlen(user->host));
57 std::string b = Srv->GetNetworkName() + "-" + ra + a;
58 Srv->Log(DEBUG,"cloak: allocated "+b);
59 strcpy(user->dhost,b.c_str());
64 Srv->Log(DEBUG,"cloak: de-allocated cloak");
65 strcpy(user->dhost,user->host);
71 // this mode isn't ours, we have to bail and return 0 to not handle it.
72 Srv->Log(DEBUG,"not my mode");
77 virtual void OnUserConnect(userrec* user)
79 Srv->Log(DEBUG,"Sending SAMODE +x for user");
81 modes[0] = user->nick;
83 Srv->SendMode(modes,2,user);
84 Srv->Log(DEBUG,"Sent SAMODE +x for user");
90 class ModuleCloakingFactory : public ModuleFactory
93 ModuleCloakingFactory()
97 ~ModuleCloakingFactory()
101 virtual Module * CreateModule()
103 return new ModuleCloaking;
109 extern "C" void * init_module( void )
111 return new ModuleCloakingFactory;