#include "bancache.h"
/* add a client connection to the sockets list */
-void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscached, sockaddr* ip, const std::string &targetip)
+void UserManager::AddUser(InspIRCd* Instance, int socket, ClientListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
{
/* NOTE: Calling this one parameter constructor for User automatically
* allocates a new UUID and places it in the hash_map.
return;
}
- char ipaddr[MAXBUF];
-#ifdef IPV6
- if (ip->sa_family == AF_INET6)
- inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, ipaddr, sizeof(ipaddr));
- else
-#endif
- inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
-
New->SetFd(socket);
- New->SetSockAddr(ip->sa_family, ipaddr, port);
+ memcpy(&New->client_sa, client, sizeof(irc::sockets::sockaddrs));
+ memcpy(&New->server_sa, server, sizeof(irc::sockets::sockaddrs));
/* Give each of the modules an attempt to hook the user for I/O */
- FOREACH_MOD_I(Instance, I_OnHookUserIO, OnHookUserIO(New, targetip));
+ FOREACH_MOD_I(Instance, I_OnHookIO, OnHookIO(New, via));
if (New->GetIOHook())
{
try
{
- New->GetIOHook()->OnRawSocketAccept(socket, ipaddr, port);
+ New->GetIOHook()->OnStreamSocketAccept(New, client, server);
}
catch (CoreException& modexcept)
{
return;
}
+ if (IS_FAKE(user))
+ {
+ ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a fake user (%s)", user->nick.c_str());
+ return;
+ }
+
user->quitting = true;
- ServerInstance->Logs->Log("USERS", DEBUG, "QuitUser: %s '%s'", user->nick.c_str(), quitreason.c_str());
+ ServerInstance->Logs->Log("USERS", DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->host.c_str(), *operreason ? operreason : quitreason.c_str());
- user->quietquit = false;
- user->quitmsg = quitreason;
-
std::string reason;
std::string oper_reason;
reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit);
- if (!*operreason)
- {
- user->operquitmsg = quitreason;
- oper_reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit);
- }
- else
- {
- user->operquitmsg = operreason;
+ if (operreason && *operreason)
oper_reason.assign(operreason, 0, ServerInstance->Config->Limits.MaxQuit);
- }
+ else
+ oper_reason = quitreason;
ServerInstance->GlobalCulls.AddItem(user);
FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(user));
- // Move the user onto their UID, to allow nick to be reused immediately
- user->UpdateNickHash(user->uuid.c_str());
+ if (user->registered != REG_ALL)
+ if (ServerInstance->Users->unregistered_count)
+ ServerInstance->Users->unregistered_count--;
+
+ if (IS_LOCAL(user))
+ {
+ user->DoWrite();
+ if (user->GetIOHook())
+ {
+ try
+ {
+ user->GetIOHook()->OnStreamSocketClose(user);
+ }
+ catch (CoreException& modexcept)
+ {
+ ServerInstance->Logs->Log("USERS",DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
+ }
+ }
+
+ ServerInstance->SE->DelFd(user);
+ user->Close();
+ // user->Close() will set fd to -1; this breaks IS_LOCAL. Fix
+ user->SetFd(INT_MAX);
+ }
+
+ /*
+ * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
+ * if they were an oper with +sn +qQ.
+ */
+ if (user->registered == REG_ALL)
+ {
+ if (IS_LOCAL(user))
+ {
+ if (!user->quietquit)
+ {
+ ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",
+ user->nick.c_str(), user->ident.c_str(), user->host.c_str(), oper_reason.c_str());
+ }
+ }
+ else
+ {
+ if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit))
+ {
+ ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",
+ user->server, user->nick.c_str(), user->ident.c_str(), user->host.c_str(), oper_reason.c_str());
+ }
+ }
+ user->AddToWhoWas();
+ }
+
+ user_hash::iterator iter = this->clientlist->find(user->nick);
+
+ if (iter != this->clientlist->end())
+ this->clientlist->erase(iter);
+ else
+ ServerInstance->Logs->Log("USERS", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic..");
}
{
int range = 32;
clonemap::iterator x;
- switch (user->GetProtocolFamily())
+ switch (user->client_sa.sa.sa_family)
{
case AF_INET6:
range = ServerInstance->Config->c_ipv6_range;
{
int range = 32;
clonemap::iterator x;
- switch (user->GetProtocolFamily())
+ switch (user->client_sa.sa.sa_family)
{
case AF_INET6:
range = ServerInstance->Config->c_ipv6_range;
void UserManager::RemoveCloneCounts(User *user)
{
int range = 32;
- switch (user->GetProtocolFamily())
+ switch (user->client_sa.sa.sa_family)
{
case AF_INET6:
range = ServerInstance->Config->c_ipv6_range;
unsigned long UserManager::GlobalCloneCount(User *user)
{
int range = 32;
- switch (user->GetProtocolFamily())
+ switch (user->client_sa.sa.sa_family)
{
case AF_INET6:
range = ServerInstance->Config->c_ipv6_range;
unsigned long UserManager::LocalCloneCount(User *user)
{
int range = 32;
- switch (user->GetProtocolFamily())
+ switch (user->client_sa.sa.sa_family)
{
case AF_INET6:
range = ServerInstance->Config->c_ipv6_range;