m_antibottler.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015
00016
00017
00018 class ModuleAntiBottler : public Module
00019 {
00020 public:
00021 ModuleAntiBottler(InspIRCd* Me)
00022 : Module(Me)
00023 {
00024
00025 Implementation eventlist[] = { I_OnPreCommand };
00026 ServerInstance->Modules->Attach(eventlist, this, 1);
00027 }
00028
00029
00030
00031 virtual ~ModuleAntiBottler()
00032 {
00033 }
00034
00035 virtual Version GetVersion()
00036 {
00037 return Version("$Id: m_antibottler.cpp 10291 2008-08-25 20:35:51Z w00t $",VF_VENDOR,API_VERSION);
00038 }
00039
00040 virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
00041 {
00042 char data[MAXBUF];
00043 strlcpy(data,original_line.c_str(),MAXBUF);
00044 bool not_bottler = false;
00045 if (!strncmp(data,"user ",5))
00046 {
00047 for (char* j = data; *j; j++)
00048 {
00049 if (*j == ':')
00050 break;
00051
00052 if (*j == '"')
00053 {
00054 not_bottler = true;
00055 }
00056 }
00057
00058 if (!*data)
00059 return 0;
00060
00061 strtok(data," ");
00062 char *ident = strtok(NULL," ");
00063 char *local = strtok(NULL," ");
00064 char *remote = strtok(NULL," :");
00065 char *gecos = strtok(NULL,"\r\n");
00066
00067 if (!ident || !local || !remote || !gecos)
00068 return 0;
00069
00070 for (char* j = remote; *j; j++)
00071 {
00072 if (((*j < '0') || (*j > '9')) && (*j != '.'))
00073 {
00074 not_bottler = true;
00075 }
00076 }
00077
00078 if (!not_bottler)
00079 {
00080 std::string strgecos = std::string(gecos) + "[Possible bottler, ident: " + std::string(ident) + "]";
00081 std::vector<std::string> modified;
00082 modified.push_back("bottler");
00083 modified.push_back(local);
00084 modified.push_back(remote);
00085 modified.push_back(strgecos);
00086 ServerInstance->Parser->CallHandler("USER", modified, user);
00087 return 1;
00088 }
00089 }
00090 return 0;
00091 }
00092 };
00093
00094 MODULE_INIT(ModuleAntiBottler)