-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2006-2009 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2006-2007, 2009 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2008 John Brooks <john.brooks@dereferenced.net>
+ * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
+ * Copyright (C) 2008 Oliver Lupton <oliverlupton@gmail.com>
+ * Copyright (C) 2003-2008 Craig Edwards <craigedwards@brainbox.cc>
*
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
*
- * This program is free but copyrighted software; see
- * the file COPYING for details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
*
- * ---------------------------------------------------
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "inspircd.h"
#include <stdarg.h>
#include "socketengine.h"
{
lastping = 0;
eh.SetFd(myfd);
- memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
+
+ SetClientIP(client);
memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
}
bool LocalUser::IsInvited(const irc::string &channel)
{
- time_t now = ServerInstance->Time();
- InvitedList::iterator safei;
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
- {
- if (channel == i->first)
- {
- if (i->second != 0 && now > i->second)
- {
- /* Expired invite, remove it. */
- safei = i;
- --i;
- invites.erase(safei);
- continue;
- }
- return true;
- }
- }
- return false;
+ Channel* chan = ServerInstance->FindChan(channel.c_str());
+ if (!chan)
+ return false;
+
+ return (Invitation::Find(chan, this) != NULL);
}
-InvitedList* LocalUser::GetInviteList()
+InviteList& LocalUser::GetInviteList()
{
- time_t now = ServerInstance->Time();
- /* Weed out expired invites here. */
- InvitedList::iterator safei;
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
- {
- if (i->second != 0 && now > i->second)
- {
- /* Expired invite, remove it. */
- safei = i;
- --i;
- invites.erase(safei);
- }
- }
- return &invites;
+ RemoveExpiredInvites();
+ return invites;
}
void LocalUser::InviteTo(const irc::string &channel, time_t invtimeout)
{
- time_t now = ServerInstance->Time();
- if (invtimeout != 0 && now > invtimeout) return; /* Don't add invites that are expired from the get-go. */
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
- {
- if (channel == i->first)
- {
- if (i->second != 0 && invtimeout > i->second)
- {
- i->second = invtimeout;
- }
-
- return;
- }
- }
- invites.push_back(std::make_pair(channel, invtimeout));
+ Channel* chan = ServerInstance->FindChan(channel.c_str());
+ if (chan)
+ Invitation::Create(chan, this, invtimeout);
}
void LocalUser::RemoveInvite(const irc::string &channel)
{
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
+ Channel* chan = ServerInstance->FindChan(channel.c_str());
+ if (chan)
{
- if (channel == i->first)
+ Invitation* inv = Invitation::Find(chan, this);
+ if (inv)
{
- invites.erase(i);
- return;
- }
+ inv->cull();
+ delete inv;
+ }
}
}
+void LocalUser::RemoveExpiredInvites()
+{
+ Invitation::Find(NULL, this);
+}
+
bool User::HasModePermission(unsigned char, ModeType)
{
return true;
ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
PurgeEmptyChannels();
- this->InvalidateCache();
-
if (client_sa.sa.sa_family != AF_UNSPEC)
ServerInstance->Users->RemoveCloneCounts(this);
else
ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
+ ClearInvites();
eh.cull();
return User::cull();
}
FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
- ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s [%s] [%s]",
+ ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s (%s) [%s]",
this->GetServerPort(), this->MyClass->name.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), this->GetIPString(), this->fullname.c_str());
ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString());
ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");
return irc::sockets::cidr_mask(client_sa, range);
}
+bool User::SetClientIP(irc::sockets::sockaddrs *sa)
+{
+ memcpy(&client_sa, sa, sizeof(irc::sockets::sockaddrs));
+
+ FOREACH_MOD(I_OnSetClientIP, OnSetClientIP(this));
+
+ return true;
+}
+
bool User::SetClientIP(const char* sip)
{
+ irc::sockets::sockaddrs sa;
+
this->cachedip = "";
- return irc::sockets::aptosa(sip, 0, client_sa);
+ if (!irc::sockets::aptosa(sip, 0, sa))
+ return false;
+
+ return SetClientIP(&sa);
}
static std::string wide_newline("\r\n");
}
}
- if (line.length())
+ if (line.length() != prefix.str().length())
{
ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
}