if (client_sa.sa.sa_family != AF_UNSPEC)
ServerInstance->Users->RemoveCloneCounts(this);
- ServerInstance->Users->uuidlist->erase(uuid);
return Extensible::cull();
}
{
// Fake users don't quit, they just get culled.
quitting = true;
+ ServerInstance->Users->clientlist->erase(nick);
+ ServerInstance->Users->uuidlist->erase(uuid);
return User::cull();
}
l->ChangeDisplayedHost(vhost.c_str());
std::string opClass = oper->getConfig("class");
if (!opClass.empty())
- {
l->SetClass(opClass);
- l->CheckClass();
- }
}
ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",
return;
}
}
+ CheckClass();
+ CheckLines();
- if (this->CheckLines())
+ if (quitting)
return;
this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network.c_str());
ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");
}
-/** User::UpdateNick()
- * re-allocates a nick in the user_hash after they change nicknames,
- * returns a pointer to the new user as it may have moved
- */
-User* User::UpdateNickHash(const char* New)
-{
- //user_hash::iterator newnick;
- user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick);
-
- if (!irc::string(this->nick.c_str()).compare(New))
- return oldnick->second;
-
- if (oldnick == ServerInstance->Users->clientlist->end())
- return NULL; /* doesnt exist */
-
- User* olduser = oldnick->second;
- ServerInstance->Users->clientlist->erase(oldnick);
- (*(ServerInstance->Users->clientlist))[New] = olduser;
- return olduser;
-}
-
void User::InvalidateCache()
{
/* Invalidate cache */
cached_fullrealhost.clear();
}
-bool User::ForceNickChange(const char* newnick)
+bool User::ChangeNick(const std::string& newnick, bool force)
{
ModResult MOD_RESULT;
- this->InvalidateCache();
-
- ServerInstance->NICKForced.set(this, 1);
+ if (force)
+ ServerInstance->NICKForced.set(this, 1);
FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (this, newnick));
ServerInstance->NICKForced.set(this, 0);
return false;
}
- std::deque<classbase*> dummy;
- Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
- if (nickhandler) // wtfbbq, when would this not be here
+ if (assign(newnick) == assign(nick))
{
- std::vector<std::string> parameters;
- parameters.push_back(newnick);
- ServerInstance->NICKForced.set(this, 1);
- bool result = (ServerInstance->Parser->CallHandler("NICK", parameters, this) == CMD_SUCCESS);
- ServerInstance->NICKForced.set(this, 0);
- return result;
+ // case change, don't need to check Q:lines and such
+ // and, if it's identical including case, we can leave right now
+ if (newnick == nick)
+ return true;
}
+ else
+ {
+ /*
+ * Don't check Q:Lines if it's a server-enforced change, just on the off-chance some fucking *moron*
+ * tries to Q:Line SIDs, also, this means we just get our way period, as it really should be.
+ * Thanks Kein for finding this. -- w00t
+ *
+ * Also don't check Q:Lines for remote nickchanges, they should have our Q:Lines anyway to enforce themselves.
+ * -- w00t
+ */
+ if (!IS_LOCAL(this))
+ {
+ XLine* mq = ServerInstance->XLines->MatchesLine("Q",newnick);
+ if (mq)
+ {
+ if (this->registered == REG_ALL)
+ {
+ ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s!%s@%s: %s",
+ newnick.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), mq->reason.c_str());
+ }
+ this->WriteNumeric(432, "%s %s :Invalid nickname: %s",this->nick.c_str(), newnick.c_str(), mq->reason.c_str());
+ return false;
+ }
- // Unreachable, we hope
- return false;
+ if (ServerInstance->Config->RestrictBannedUsers)
+ {
+ for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
+ {
+ Channel *chan = *i;
+ if (chan->GetPrefixValue(this) < VOICE_VALUE && chan->IsBanned(this))
+ {
+ this->WriteNumeric(404, "%s %s :Cannot send to channel (you're banned)", this->nick.c_str(), chan->name.c_str());
+ return false;
+ }
+ }
+ }
+ }
+
+ /*
+ * Uh oh.. if the nickname is in use, and it's not in use by the person using it (doh) --
+ * then we have a potential collide. Check whether someone else is camping on the nick
+ * (i.e. connect -> send NICK, don't send USER.) If they are camping, force-change the
+ * camper to their UID, and allow the incoming nick change.
+ *
+ * If the guy using the nick is already using it, tell the incoming nick change to gtfo,
+ * because the nick is already (rightfully) in use. -- w00t
+ */
+ User* InUse = ServerInstance->FindNickOnly(newnick);
+ if (InUse && (InUse != this))
+ {
+ if (InUse->registered != REG_ALL)
+ {
+ /* force the camper to their UUID, and ask them to re-send a NICK. */
+ InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str());
+ InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str());
+
+ ServerInstance->Users->clientlist->erase(InUse->nick);
+ (*(ServerInstance->Users->clientlist))[InUse->uuid] = InUse;
+
+ InUse->nick = InUse->uuid;
+ InUse->InvalidateCache();
+ InUse->registered &= ~REG_NICK;
+ }
+ else
+ {
+ /* No camping, tell the incoming user to stop trying to change nick ;p */
+ this->WriteNumeric(433, "%s %s :Nickname is already in use.", this->registered >= REG_NICK ? this->nick.c_str() : "*", newnick.c_str());
+ return false;
+ }
+ }
+ }
+
+ if (this->registered == REG_ALL)
+ this->WriteCommon("NICK %s",newnick.c_str());
+ std::string oldnick = nick;
+ nick = newnick;
+
+ InvalidateCache();
+ ServerInstance->Users->clientlist->erase(oldnick);
+ (*(ServerInstance->Users->clientlist))[newnick] = this;
+
+ FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(this,oldnick));
+ return true;
}
int LocalUser::GetServerPort()
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "ALLOW %s %d %s", c->host.c_str(), c->GetPort(), c->GetName().c_str());
}
- else
+ else if (c->type == CC_DENY)
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "DENY %s %d %s", c->GetHost().c_str(), c->GetPort(), c->GetName().c_str());
}
+ else
+ {
+ continue;
+ }
/* check if host matches.. */
if (c->GetHost().length() && !InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&