From 9ed4641ba3aaac8e133a73ec1c3d42965ee59241 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 12 Apr 2004 16:05:08 +0000 Subject: Added preliminary support for a bottler-detection module Fixed broken rewrite in OnServerRaw git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@566 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/InspIRCd.dev | 4 +- src/InspIRCd.layout | 28 +++++------ src/inspircd.cpp | 19 +++++-- src/modules/m_antibottler.cpp | 94 +++++++++++++++++++++++++++++++++++ src/modules/m_foobar.cpp | 113 ------------------------------------------ 5 files changed, 125 insertions(+), 133 deletions(-) create mode 100644 src/modules/m_antibottler.cpp (limited to 'src') diff --git a/src/InspIRCd.dev b/src/InspIRCd.dev index 310e88ccb..39cb30741 100644 --- a/src/InspIRCd.dev +++ b/src/InspIRCd.dev @@ -1,7 +1,7 @@ [Project] FileName=InspIRCd.dev Name=InspIRCd - The Inspire Internet Relay Chat Daemon -UnitCount=38 +UnitCount=39 Type=1 Ver=1 ObjFiles= @@ -406,7 +406,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit39] -FileName=modules\m_saquit.cpp +FileName=modules\m_antibottler.cpp CompileCpp=1 Folder=Modules Compile=1 diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 13c04b3b9..bb37d690d 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=-1 +Focused=1 Order=1,2,-1,4,6,3,7,25,5,24 [Editor_0] @@ -12,10 +12,10 @@ LeftChar=1 [Editor_1] Open=1 -Top=0 -CursorCol=12 -CursorRow=6593 -TopLine=6550 +Top=1 +CursorCol=4 +CursorRow=979 +TopLine=944 LeftChar=1 [Editor_2] @@ -165,9 +165,9 @@ LeftChar=1 [Editor_20] Open=1 Top=0 -CursorCol=6 -CursorRow=486 -TopLine=434 +CursorCol=60 +CursorRow=163 +TopLine=129 LeftChar=1 [Editor_21] @@ -238,7 +238,7 @@ TopLine=1 LeftChar=1 [Editor_30] Open=1 -Top=1 +Top=0 CursorCol=87 CursorRow=21 TopLine=1 @@ -260,7 +260,7 @@ LeftChar=1 [Editor_33] Open=1 Top=0 -CursorCol=39 +CursorCol=23 CursorRow=36 TopLine=1 LeftChar=1 @@ -293,11 +293,11 @@ CursorRow=103 TopLine=70 LeftChar=1 [Editor_38] -Open=0 +Open=1 Top=0 -CursorCol=49 -CursorRow=31 -TopLine=1 +CursorCol=61 +CursorRow=65 +TopLine=29 LeftChar=1 [Editor_39] Open=0 diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 3929138d6..823372460 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -5796,10 +5796,21 @@ void process_command(userrec *user, char* cmd) strcpy(temp,cmd); - string tmp = cmd; - FOREACH_MOD OnServerRaw(tmp,true); - const char* cmd2 = tmp.c_str(); - snprintf(cmd,512,"%s",cmd2); + std::string tmp = cmd; + for (int i = 0; i <= MODCOUNT; i++) + { + std::string oldtmp = tmp; + modules[i]->OnServerRaw(tmp,true); + if (oldtmp != tmp) + { + log(DEBUG,"A Module changed the input string!"); + log(DEBUG,"New string: %s",tmp.c_str()); + log(DEBUG,"Old string: %s",oldtmp.c_str()); + break; + } + } + strncpy(cmd,tmp.c_str(),MAXBUF); + strcpy(temp,cmd); if (!strchr(cmd,' ')) { diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp new file mode 100644 index 000000000..d6a47fa90 --- /dev/null +++ b/src/modules/m_antibottler.cpp @@ -0,0 +1,94 @@ +#include "users.h" +#include "channels.h" +#include "modules.h" + +/* $ModDesc: Changes the ident of connecting bottler clients to 'bottler' */ + +class ModuleAntiBottler : public Module +{ + private: + + Server *Srv; + public: + ModuleAntiBottler() + { + Srv = new Server; + } + + virtual ~ModuleAntiBottler() + { + delete Srv; + } + + virtual Version GetVersion() + { + return Version(1,0,0,0); + } + + + virtual void OnServerRaw(std::string &raw, bool inbound) + { + if (inbound) + { + char data[MAXBUF]; + strncpy(data,raw.c_str(),MAXBUF); + bool not_bottler = false; + if (!strncmp(data,"user ",5)) + { + for (int j = 0; j < strlen(data); j++) + { + if (data[j] = ':') + break; + + if (data[j] = '"') + { + not_bottler = true; + } + } + char *user = strtok(data," "); + char *ident = strtok(NULL," "); + char *local = strtok(NULL," "); + char *remote = strtok(NULL," :"); + char *gecos = strtok(NULL,"\r\n"); + for (int j = 0; j < strlen(remote); j++) + { + if (((remote[j] < '0') || (remote[j] > '9')) && (remote[j] != '.')) + { + not_bottler = true; + } + } + + if (!not_bottler) + { + raw = "USER bottler "+std::string(local)+" "+std::string(remote)+" "+std::string(gecos)+" [Possible bottler, ident: "+std::string(ident)+"]"; + } + } + } + } +}; + + +class ModuleAntiBottlerFactory : public ModuleFactory +{ + public: + ModuleAntiBottlerFactory() + { + } + + ~ModuleAntiBottlerFactory() + { + } + + virtual Module * CreateModule() + { + return new ModuleAntiBottler; + } + +}; + + +extern "C" void * init_module( void ) +{ + return new ModuleAntiBottlerFactory; +} + diff --git a/src/modules/m_foobar.cpp b/src/modules/m_foobar.cpp index ab3fa759b..e69de29bb 100644 --- a/src/modules/m_foobar.cpp +++ b/src/modules/m_foobar.cpp @@ -1,113 +0,0 @@ -#include "users.h" -#include "channels.h" -#include "modules.h" - -/* $ModDesc: A dummy module for testing */ - -// Class ModuleFoobar inherits from Module -// It just outputs simple debug strings to show its methods are working. - -class ModuleFoobar : public Module -{ - private: - - // It is recommended that your class makes use of one or more Server - // objects. A server object is a class which contains methods which - // encapsulate the exports from the core of the ircd. - // such methods include Debug, SendChannel, etc. - - Server *Srv; - public: - ModuleFoobar() - { - // The constructor just creates an instance of the server class - - Srv = new Server; - } - - virtual ~ModuleFoobar() - { - // destructor deletes the instance of the server class - - delete Srv; - } - - virtual Version GetVersion() - { - // this method instantiates a class of type Version, and returns - // the modules version information using it. - - return Version(1,0,0,0); - } - - virtual void OnUserConnect(userrec* user) - { - // method called when a user connects - - std::string b = user->nick; - Srv->Log(DEBUG,"Foobar: User connecting: " + b); - } - - virtual void OnUserQuit(userrec* user) - { - // method called when a user disconnects - - std::string b = user->nick; - Srv->Log(DEBUG,"Foobar: User quitting: " + b); - } - - virtual void OnUserJoin(userrec* user, chanrec* channel) - { - // method called when a user joins a channel - - std::string c = channel->name; - std::string b = user->nick; - Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c); - } - - virtual void OnUserPart(userrec* user, chanrec* channel) - { - // method called when a user parts a channel - - std::string c = channel->name; - std::string b = user->nick; - Srv->Log(DEBUG,"Foobar: User " + b + " parted " + c); - } - -}; - - -// -// The ModuleFoobarFactory class inherits from ModuleFactory -// and creates a ModuleFoobar object when requested. -// - -class ModuleFoobarFactory : public ModuleFactory -{ - public: - ModuleFoobarFactory() - { - } - - ~ModuleFoobarFactory() - { - } - - virtual Module * CreateModule() - { - return new ModuleFoobar; - } - -}; - - -// -// The "C" linkage factory0() function creates the ModuleFoobarFactory -// class for this library -// - -extern "C" void * init_module( void ) -{ - return new ModuleFoobarFactory; -} - -- cgit v1.2.3