X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_ident.cpp;h=3f3399d3c604682b7eacda235b828706701b5b08;hb=cd7657bddc7a6dc2e7326077d173a874bf71f6bd;hp=3fb61e345fae6c467a838999fd518bd48bc04dc4;hpb=4a519ed2014d4f05cfc4710f125e32ad6230cbc4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 3fb61e345..3f3399d3c 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -11,12 +11,10 @@ * --------------------------------------------------- */ -#include -#include +#include "inspircd.h" #include "users.h" #include "channels.h" #include "modules.h" -#include "inspircd.h" /* $ModDesc: Provides support for RFC 1413 ident lookups */ @@ -46,12 +44,7 @@ class RFC1413 : public InspSocket // so we just display a notice, and tidy off the ident_data. if (u && (Instance->SE->GetRef(ufd) == u)) { - char newident[MAXBUF]; u->Shrink("ident_data"); - u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using ~"+std::string(u->ident)+" instead."); - strcpy(newident,"~"); - strlcat(newident,u->ident,IDENTMAX); - strlcpy(u->ident,newident,IDENTMAX); Instance->next_call = Instance->Time(); } } @@ -84,6 +77,7 @@ class RFC1413 : public InspSocket { if (this->Instance->IsIdent(section)) { + u->Extend("IDENT", new std::string(std::string(section) + "," + std::string(u->ident))); strlcpy(u->ident,section,IDENTMAX); u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); } @@ -131,6 +125,9 @@ class RFC1413 : public InspSocket { if (u && (Instance->SE->GetRef(ufd) == u)) { + if (*u->ident == '~') + u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead."); + Instance->next_call = Instance->Time(); u->Shrink("ident_data"); } @@ -140,8 +137,8 @@ class RFC1413 : public InspSocket { if (u && (Instance->SE->GetRef(ufd) == u)) { - sockaddr* sock_us = new sockaddr; - sockaddr* sock_them = new sockaddr; + sockaddr* sock_us = new sockaddr[2]; + sockaddr* sock_them = new sockaddr[2]; bool success = false; uslen = sizeof(sockaddr_in); themlen = sizeof(sockaddr_in); @@ -159,9 +156,8 @@ class RFC1413 : public InspSocket #endif if (success) { - Instance->Log(DEBUG,"BUG: Ident: failed to get socket names"); - delete sock_us; - delete sock_them; + delete[] sock_us; + delete[] sock_them; return false; } else @@ -176,8 +172,8 @@ class RFC1413 : public InspSocket snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); #endif this->Write(ident_request); - delete sock_us; - delete sock_them; + delete[] sock_us; + delete[] sock_them; return true; } } @@ -207,7 +203,7 @@ class ModuleIdent : public Module } ModuleIdent(InspIRCd* Me) - : Module::Module(Me) + : Module(Me) { ReadSettings(); @@ -218,6 +214,17 @@ class ModuleIdent : public Module List[I_OnCleanup] = List[I_OnRehash] = List[I_OnUserRegister] = List[I_OnCheckReady] = List[I_OnUserDisconnect] = 1; } + void OnSyncUserMetaData(userrec* user, Module* proto,void* opaque, const std::string &extname, bool displayable) + { + if ((displayable) && (extname == "IDENT")) + { + std::string* ident; + if (GetExt("IDENT", ident)) + proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, *ident); + } + } + + virtual void OnRehash(userrec* user, const std::string ¶meter) { ReadSettings(); @@ -231,6 +238,12 @@ class ModuleIdent : public Module * is derived from InspSocket, and inserting it into the socket engine using the * Server::AddSocket() call. */ + char newident[MAXBUF]; + strcpy(newident,"~"); + strlcat(newident,user->ident,IDENTMAX); + strlcpy(user->ident,newident,IDENTMAX); + + user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident..."); RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout); if ((ident->GetState() == I_CONNECTING) || (ident->GetState() == I_CONNECTED)) @@ -239,11 +252,7 @@ class ModuleIdent : public Module } else { - char newident[MAXBUF]; - user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using ~"+std::string(user->ident)+" instead."); - strcpy(newident,"~"); - strlcat(newident,user->ident,IDENTMAX); - strlcpy(user->ident,newident,IDENTMAX); + user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using "+std::string(user->ident)+" instead."); ServerInstance->next_call = ServerInstance->Time(); } return 0; @@ -266,6 +275,7 @@ class ModuleIdent : public Module { userrec* user = (userrec*)item; RFC1413* ident; + std::string* identstr; if (user->GetExt("ident_data", ident)) { // FIX: If the user record is deleted, the socket wont be removed @@ -276,6 +286,10 @@ class ModuleIdent : public Module ServerInstance->SE->DelFd(ident); //delete ident; } + if (user->GetExt("IDENT", identstr)) + { + delete identstr; + } } } @@ -290,11 +304,16 @@ class ModuleIdent : public Module * and this would leave at least one of the invalid ;) */ RFC1413* ident; + std::string* identstr; if (user->GetExt("ident_data", ident)) { ident->u = NULL; ServerInstance->SE->DelFd(ident); } + if (user->GetExt("IDENT", identstr)) + { + delete identstr; + } } virtual ~ModuleIdent() @@ -328,7 +347,7 @@ class ModuleIdentFactory : public ModuleFactory }; -extern "C" void * init_module( void ) +extern "C" DllExport void * init_module( void ) { return new ModuleIdentFactory; }