summaryrefslogtreecommitdiff
path: root/src/modules/m_cloaking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_cloaking.cpp')
-rw-r--r--src/modules/m_cloaking.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
new file mode 100644
index 000000000..91ab49054
--- /dev/null
+++ b/src/modules/m_cloaking.cpp
@@ -0,0 +1,73 @@
+#include <stdio.h>
+
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+
+/* $ModDesc: Provides masking of user hostnames */
+
+class ModuleCloaking : public Module
+{
+ private:
+
+ Server *Srv;
+
+ public:
+ ModuleCloaking()
+ {
+ Srv = new Server;
+ }
+
+ virtual ~ModuleCloaking()
+ {
+ delete Srv;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,0,0,0);
+ }
+
+ virtual void OnUserConnect(userrec* user)
+ {
+ if (strstr(user->dhost,"."))
+ {
+ 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));
+ string b = Srv->GetNetworkName() + "-" + ra + a;
+ Srv->Debug("cloak: allocated "+b);
+ strcpy(user->dhost,b.c_str());
+ }
+ }
+
+};
+
+
+class ModuleCloakingFactory : public ModuleFactory
+{
+ public:
+ ModuleCloakingFactory()
+ {
+ }
+
+ ~ModuleCloakingFactory()
+ {
+ }
+
+ virtual Module * CreateModule()
+ {
+ return new ModuleCloaking;
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleCloakingFactory;
+}
+