X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_ident.cpp;h=dc59adcead13a766a2cb569211724650806b69ca;hb=2e52ff280dca14d1598b84fab7a8c2e93fa30910;hp=a7ffe60529f1119fd30e6faf8c03738a09922fc4;hpb=e381b06561228aaea752deda20a62c6dc99a560e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index a7ffe6052..dc59adcea 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -27,6 +27,8 @@ using namespace std; // Version 1.5.0.0 - Updated to use InspSocket, faster and neater. +/** Handles RFC1413 ident connections to users + */ class RFC1413 : public InspSocket { protected: @@ -41,8 +43,9 @@ class RFC1413 : public InspSocket userrec* u; // user record that the lookup is associated with int ufd; - RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user), ufd(user->GetFd()) + RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user) { + ufd = user->GetFd(); } virtual void OnTimeout() @@ -51,8 +54,12 @@ 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."); + 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); } } @@ -137,6 +144,7 @@ class RFC1413 : public InspSocket virtual bool OnConnected() { + Instance->Log(DEBUG,"Ident: connected"); if (u && (Instance->SE->GetRef(ufd) == u)) { uslen = sizeof(sock_us); @@ -200,7 +208,7 @@ class ModuleIdent : public Module ReadSettings(); } - virtual void OnUserRegister(userrec* user) + virtual int OnUserRegister(userrec* user) { /* * when the new user connects, before they authenticate with USER/NICK/PASS, we do @@ -210,16 +218,20 @@ class ModuleIdent : public Module */ user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident..."); RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout); - if (ident->GetState() != I_ERROR) + if ((ident->GetState() == I_CONNECTING) || (ident->GetState() == I_CONNECTED)) { user->Extend("ident_data", (char*)ident); - ServerInstance->AddSocket(ident); } else { - user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using "+std::string(user->ident)+" instead."); - DELETE(ident); + 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); + delete ident; } + return 0; } virtual bool OnCheckReady(userrec* user) @@ -246,7 +258,8 @@ class ModuleIdent : public Module // a user which has now vanished! To prevent this, set ident::u // to NULL and check it so that we dont write users who have gone away. ident->u = NULL; - ServerInstance->RemoveSocket(ident); + ServerInstance->SE->DelFd(ident); + delete ident; } } } @@ -265,7 +278,8 @@ class ModuleIdent : public Module if (user->GetExt("ident_data", ident)) { ident->u = NULL; - ServerInstance->RemoveSocket(ident); + ServerInstance->SE->DelFd(ident); + delete ident; } } @@ -275,7 +289,7 @@ class ModuleIdent : public Module virtual Version GetVersion() { - return Version(1,5,0,0,VF_VENDOR); + return Version(1,1,0,0,VF_VENDOR,API_VERSION); } };