summaryrefslogtreecommitdiff
path: root/src/modules/m_cloaking.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-05 01:03:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-05 01:03:26 +0000
commit1e1e59d32934ee61562804cd86321ffe849c1ecb (patch)
treedbb153dbf5c827f1a43bd2d2f306c268a8bec9ed /src/modules/m_cloaking.cpp
parentc5ad0a19cbf86510fc0b75ac96ea9d57598da91f (diff)
Modified the Module::OnExtendedMode() method to use a void* as its target which the coder must cast into a chanrec or userrec.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@383 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_cloaking.cpp')
-rw-r--r--src/modules/m_cloaking.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index aae182036..8fd4e43e5 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -59,7 +59,7 @@ class ModuleCloaking : public Module
return Version(1,0,0,1);
}
- virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params)
+ virtual bool OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
{
// this method is called for any extended mode character.
// all module modes for all modules pass through here
@@ -69,6 +69,11 @@ class ModuleCloaking : public Module
// modules to 'spy' on extended mode activity if they so wish.
if ((modechar == 'x') && (type == MT_CLIENT))
{
+ // OnExtendedMode gives us a void* as the target, we must cast
+ // it into a userrec* or a chanrec* depending on the value of
+ // the 'type' parameter (MT_CLIENT or MT_CHANNEL)
+ userrec* dest = (userrec*)target;
+
// we've now determined that this is our mode character...
// is the user adding the mode to their list or removing it?
if (mode_on)
@@ -80,28 +85,28 @@ class ModuleCloaking : public Module
// will not work if the user has only one level of domain
// naming in their hostname (e.g. if they are on a lan or
// are connecting via localhost) -- this doesnt matter much.
- if (strstr(user->host,"."))
+ if (strstr(dest->host,"."))
{
// in inspircd users have two hostnames. A displayed
// hostname which can be modified by modules (e.g.
// to create vhosts, implement chghost, etc) and a
// 'real' hostname which you shouldnt write to.
- std::string a = strstr(user->host,".");
+ std::string a = strstr(dest->host,".");
char ra[64];
long seed,s2;
- memcpy(&seed,user->host,sizeof(long));
+ memcpy(&seed,dest->host,sizeof(long));
memcpy(&s2,a.c_str(),sizeof(long));
- sprintf(ra,"%.8X",seed*s2*strlen(user->host));
+ sprintf(ra,"%.8X",seed*s2*strlen(dest->host));
std::string b = Srv->GetNetworkName() + "-" + ra + a;
Srv->Log(DEBUG,"cloak: allocated "+b);
- strcpy(user->dhost,b.c_str());
+ strcpy(dest->dhost,b.c_str());
}
}
else
{
// user is removing the mode, so just restore their real host
// and make it match the displayed one.
- strcpy(user->dhost,user->host);
+ strcpy(dest->dhost,dest->host);
}
// this mode IS ours, and we have handled it. If we chose not to handle it,
// for example the user cannot cloak as they have a vhost or such, then