* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
- *
- * Written by Craig Edwards, Craig McLure, and others.
+ * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/
-using namespace std;
-
#include <stdio.h>
#include <string>
#include "users.h"
// Version 1.5.0.0 - Updated to use InspSocket, faster and neater.
+/** Handles RFC1413 ident connections to users
+ */
class RFC1413 : public InspSocket
{
protected:
// 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);
}
}
if (this->Instance->IsIdent(section))
{
strlcpy(u->ident,section,IDENTMAX);
- Instance->Log(DEBUG,"IDENT SET: "+std::string(u->ident));
u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident));
}
}
virtual bool OnConnected()
{
- Instance->Log(DEBUG,"Ident: connected");
if (u && (Instance->SE->GetRef(ufd) == u))
{
uslen = sizeof(sock_us);
themlen = sizeof(sock_them);
if ((getsockname(this->u->GetFd(),(sockaddr*)&sock_us,&uslen) || getpeername(this->u->GetFd(), (sockaddr*)&sock_them, &themlen)))
{
- Instance->Log(DEBUG,"Ident: failed to get socket names, bailing");
+ Instance->Log(DEBUG,"BUG: Ident: failed to get socket names");
return false;
}
else
snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin_port),ntohs(sock_us.sin_port));
#endif
this->Write(ident_request);
- Instance->Log(DEBUG,"Sent ident request, waiting for reply");
return true;
}
}
List[I_OnCleanup] = List[I_OnRehash] = List[I_OnUserRegister] = List[I_OnCheckReady] = List[I_OnUserDisconnect] = 1;
}
- virtual void OnRehash(const std::string ¶meter)
+ virtual void OnRehash(userrec* user, const std::string ¶meter)
{
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
*/
user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident...");
RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout);
- user->Extend("ident_data", (char*)ident);
+ if ((ident->GetState() == I_CONNECTING) || (ident->GetState() == I_CONNECTED))
+ {
+ user->Extend("ident_data", (char*)ident);
+ }
+ 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);
+ delete ident;
+ }
+ return 0;
}
virtual bool OnCheckReady(userrec* user)
// 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->SE->DelFd(ident);
+ delete ident;
}
}
}
if (user->GetExt("ident_data", ident))
{
ident->u = NULL;
+ ServerInstance->SE->DelFd(ident);
+ delete ident;
}
}
virtual Version GetVersion()
{
- return Version(1,5,0,0,VF_VENDOR);
+ return Version(1,1,0,0,VF_VENDOR,API_VERSION);
}
};