mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
kill_link() and Server::QuitUser() -> userrec::QuitUser() (static member) - this cant be a normal member as it causes the userrec to be deleted, and "delete this" is bad, mmm'k
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4789 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
6ab1d0dffb
commit
93876363f8
@ -1507,18 +1507,6 @@ class Server : public Extensible
|
||||
*/
|
||||
virtual void ChangeUserNick(userrec* user, const std::string &nickname);
|
||||
|
||||
/** Forces a user to quit with the specified reason.
|
||||
* To the user, it will appear as if they typed /QUIT themselves, except for the fact that this function
|
||||
* may bypass the quit prefix specified in the config file.
|
||||
*
|
||||
* WARNING!
|
||||
*
|
||||
* Once you call this function, userrec* user will immediately become INVALID. You MUST NOT write to, or
|
||||
* read from this pointer after calling the QuitUser method UNDER ANY CIRCUMSTANCES! The best course of
|
||||
* action after calling this method is to immediately bail from your handler.
|
||||
*/
|
||||
virtual void QuitUser(userrec* user, const std::string &reason);
|
||||
|
||||
/** Matches text against a glob pattern.
|
||||
* Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
|
||||
* Returns true if the literal successfully matches the pattern, false if otherwise.
|
||||
|
@ -435,6 +435,10 @@ class userrec : public connection
|
||||
*/
|
||||
void CloseSocket();
|
||||
|
||||
/** Disconnect a user gracefully
|
||||
*/
|
||||
static void QuitUser(userrec *user, const std::string &r);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~userrec();
|
||||
@ -461,8 +465,7 @@ typedef std::map<irc::string,whowas_set*> whowas_users;
|
||||
|
||||
void AddOper(userrec* user);
|
||||
void DeleteOper(userrec* user);
|
||||
void kill_link(userrec *user,const char* r);
|
||||
void kill_link_silent(userrec *user,const char* r);
|
||||
//void kill_link(userrec *user,const char* r);
|
||||
void AddWhoWas(userrec* u);
|
||||
void MaintainWhoWas(time_t TIME);
|
||||
void AddClient(int socket, int port, bool iscached, insp_inaddr ip4);
|
||||
|
@ -79,7 +79,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
|
||||
WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, Config->ServerName, user->dhost, user->nick, parameters[1]);
|
||||
WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
|
||||
snprintf(killreason,MAXQUIT,"Killed (%s (%s))", user->nick, parameters[1]);
|
||||
kill_link(u, killreason);
|
||||
userrec::QuitUser(u, killreason);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -133,7 +133,7 @@ int CullList::Apply()
|
||||
{
|
||||
std::vector<CullItem>::iterator a = list.begin();
|
||||
|
||||
kill_link(a->GetUser(), a->GetReason().c_str());
|
||||
userrec::QuitUser(a->GetUser(), a->GetReason().c_str());
|
||||
list.erase(list.begin());
|
||||
}
|
||||
return n;
|
||||
|
@ -414,11 +414,6 @@ void Server::ChangeUserNick(userrec* user, const std::string &nickname)
|
||||
force_nickchange(user,nickname.c_str());
|
||||
}
|
||||
|
||||
void Server::QuitUser(userrec* user, const std::string &reason)
|
||||
{
|
||||
kill_link(user,reason.c_str());
|
||||
}
|
||||
|
||||
bool Server::IsUlined(const std::string &server)
|
||||
{
|
||||
return is_uline(server.c_str());
|
||||
@ -633,7 +628,7 @@ bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &me
|
||||
std::string oldnick = alive->nick;
|
||||
std::string oldhost = alive->host;
|
||||
std::string oldident = alive->ident;
|
||||
kill_link(alive,message.c_str());
|
||||
userrec::QuitUser(alive,message.c_str());
|
||||
if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
|
||||
{
|
||||
local_users.erase(find(local_users.begin(),local_users.end(),alive));
|
||||
|
@ -144,7 +144,7 @@ class ModuleFilterPCRE : public Module
|
||||
|
||||
if (do_action == "kill")
|
||||
{
|
||||
Srv->QuitUser(user,reason);
|
||||
userrec::QuitUser(user,reason);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
|
||||
if (!CheckCredentials(user))
|
||||
{
|
||||
Srv->QuitUser(user,killreason);
|
||||
userrec::QuitUser(user,killreason);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ public:
|
||||
{
|
||||
if(user->GetExt("sqlauth_failed"))
|
||||
{
|
||||
Srv->QuitUser(user,killreason);
|
||||
userrec::QuitUser(user,killreason);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
|
||||
|
||||
if(action == IBLOCK_KILL || action == IBLOCK_KILLOPERS)
|
||||
Srv->QuitUser(user, "Global message (/amsg or /ame) detected");
|
||||
userrec::QuitUser(user, "Global message (/amsg or /ame) detected");
|
||||
else if(action == IBLOCK_NOTICE || action == IBLOCK_NOTICEOPERS)
|
||||
WriteServ(user->fd, "NOTICE %s :Global message (/amsg or /ame) detected", user->nick);
|
||||
|
||||
|
@ -94,7 +94,7 @@ class ModuleWaitPong : public Module
|
||||
else
|
||||
{
|
||||
if(killonbadreply)
|
||||
Srv->QuitUser(user, "Incorrect ping reply for registration");
|
||||
userrec::QuitUser(user, "Incorrect ping reply for registration");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
Srv->SendOpers("*** Connection throttle deactivated");
|
||||
return;
|
||||
}
|
||||
Srv->QuitUser(user, quitmsg);
|
||||
userrec::QuitUser(user, quitmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
{
|
||||
throttled = 1;
|
||||
Srv->SendOpers("*** Connection throttle activated");
|
||||
Srv->QuitUser(user, quitmsg);
|
||||
userrec::QuitUser(user, quitmsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class ModuleFilter : public Module
|
||||
|
||||
if (f->action == "kill")
|
||||
{
|
||||
Srv->QuitUser(user,f->reason);
|
||||
userrec::QuitUser(user,f->reason);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ class ModulePark : public Module
|
||||
// and then corrupt the pointer!
|
||||
pinfo.erase(j);
|
||||
if (thisnick)
|
||||
Srv->QuitUser(thisnick,"PARK timeout");
|
||||
userrec::QuitUser(thisnick,"PARK timeout");
|
||||
go_again = true;
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class cmd_saquit : public command_t
|
||||
line = line + std::string(parameters[pcnt-1]);
|
||||
|
||||
Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
|
||||
Srv->QuitUser(dest, line);
|
||||
userrec::QuitUser(dest, line);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -330,7 +330,7 @@ class TreeServer : public classbase
|
||||
userrec* a = (userrec*)*n;
|
||||
log(DEBUG,"Kill %s fd=%d",a->nick,a->fd);
|
||||
if (!IS_LOCAL(a))
|
||||
kill_link(a,reason_s);
|
||||
userrec::QuitUser(a,reason_s);
|
||||
}
|
||||
return time_to_die.size();
|
||||
}
|
||||
@ -2078,7 +2078,7 @@ class TreeSocket : public InspSocket
|
||||
params[1] = ":" + params[1];
|
||||
DoOneToAllButSender(prefix,"KILL",params,sourceserv);
|
||||
::Write(who->fd, ":%s KILL %s :%s (%s)", sourceserv.c_str(), who->nick, sourceserv.c_str(), reason.c_str());
|
||||
Srv->QuitUser(who,reason);
|
||||
userrec::QuitUser(who,reason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2965,11 +2965,11 @@ class TreeSocket : public InspSocket
|
||||
p.push_back(prefix);
|
||||
p.push_back("Nickname collision");
|
||||
DoOneToMany(Srv->GetServerName(),"KILL",p);
|
||||
Srv->QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")");
|
||||
userrec::QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")");
|
||||
userrec* y = Srv->FindNick(prefix);
|
||||
if (y)
|
||||
{
|
||||
Srv->QuitUser(y,"Nickname collision");
|
||||
userrec::QuitUser(y,"Nickname collision");
|
||||
}
|
||||
return DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void ProcessUser(userrec* cu)
|
||||
{
|
||||
log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
kill_link(current,"Excess flood");
|
||||
userrec::QuitUser(current,"Excess flood");
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -181,7 +181,7 @@ void ProcessUser(userrec* cu)
|
||||
{
|
||||
if (current->registered == REG_ALL)
|
||||
{
|
||||
kill_link(current,"RecvQ exceeded");
|
||||
userrec::QuitUser(current,"RecvQ exceeded");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -207,7 +207,7 @@ void ProcessUser(userrec* cu)
|
||||
{
|
||||
log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
kill_link(current,"Excess flood");
|
||||
userrec::QuitUser(current,"Excess flood");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ void ProcessUser(userrec* cu)
|
||||
{
|
||||
log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
|
||||
kill_link(current,"Excess flood");
|
||||
userrec::QuitUser(current,"Excess flood");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -262,7 +262,7 @@ void ProcessUser(userrec* cu)
|
||||
if ((result == -1) && (errno != EAGAIN) && (errno != EINTR))
|
||||
{
|
||||
log(DEBUG,"killing: %s",cu->nick);
|
||||
kill_link(cu,strerror(errno));
|
||||
userrec::QuitUser(cu,strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ void ProcessUser(userrec* cu)
|
||||
else if (result == 0)
|
||||
{
|
||||
log(DEBUG,"InspIRCd: Exited: %s",cu->nick);
|
||||
kill_link(cu,"Client exited");
|
||||
userrec::QuitUser(cu,"Client exited");
|
||||
log(DEBUG,"Bailing from client exit");
|
||||
return;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ void DeleteOper(userrec* user)
|
||||
}
|
||||
}
|
||||
|
||||
void kill_link(userrec *user,const char* r)
|
||||
void userrec::QuitUser(userrec *user,const std::string &quitreason)
|
||||
{
|
||||
user_hash::iterator iter = clientlist.find(user->nick);
|
||||
|
||||
@ -648,20 +648,19 @@ void kill_link(userrec *user,const char* r)
|
||||
* if (iter == clientlist.end())
|
||||
* return;
|
||||
*/
|
||||
std::string reason = quitreason;
|
||||
|
||||
char reason[MAXBUF];
|
||||
|
||||
strlcpy(reason,r,MAXQUIT-1);
|
||||
log(DEBUG,"kill_link: %s %d '%s'",user->nick,user->fd,reason);
|
||||
if (reason.length() > MAXQUIT - 1)
|
||||
reason.resize(MAXQUIT - 1);
|
||||
|
||||
if (IS_LOCAL(user))
|
||||
Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason);
|
||||
Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
|
||||
|
||||
if (user->registered == REG_ALL)
|
||||
{
|
||||
purge_empty_chans(user);
|
||||
FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,reason));
|
||||
WriteCommonExcept(user,"QUIT :%s",reason);
|
||||
WriteCommonExcept(user,"QUIT :%s",reason.c_str());
|
||||
}
|
||||
|
||||
if (IS_LOCAL(user))
|
||||
@ -698,7 +697,7 @@ void kill_link(userrec *user,const char* r)
|
||||
if (user->registered == REG_ALL)
|
||||
{
|
||||
if (IS_LOCAL(user))
|
||||
WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason);
|
||||
WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
|
||||
AddWhoWas(user);
|
||||
}
|
||||
|
||||
@ -709,10 +708,7 @@ void kill_link(userrec *user,const char* r)
|
||||
{
|
||||
fd_ref_table[user->fd] = NULL;
|
||||
if (find(local_users.begin(),local_users.end(),user) != local_users.end())
|
||||
{
|
||||
local_users.erase(find(local_users.begin(),local_users.end(),user));
|
||||
log(DEBUG,"Delete local user");
|
||||
}
|
||||
}
|
||||
clientlist.erase(iter);
|
||||
DELETE(user);
|
||||
@ -868,13 +864,13 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip)
|
||||
|
||||
if (local_users.size() > Config->SoftLimit)
|
||||
{
|
||||
kill_link(_new,"No more connections allowed");
|
||||
userrec::QuitUser(_new,"No more connections allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (local_users.size() >= MAXCLIENTS)
|
||||
{
|
||||
kill_link(_new,"No more connections allowed");
|
||||
userrec::QuitUser(_new,"No more connections allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -890,7 +886,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip)
|
||||
*/
|
||||
if ((unsigned)socket >= MAX_DESCRIPTORS)
|
||||
{
|
||||
kill_link(_new,"Server is full");
|
||||
userrec::QuitUser(_new,"Server is full");
|
||||
return;
|
||||
}
|
||||
char* e = matches_exception(ipaddr);
|
||||
@ -901,7 +897,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip)
|
||||
{
|
||||
char reason[MAXBUF];
|
||||
snprintf(reason,MAXBUF,"Z-Lined: %s",r);
|
||||
kill_link(_new,reason);
|
||||
userrec::QuitUser(_new,reason);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -910,7 +906,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip)
|
||||
{
|
||||
if (!ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT))
|
||||
{
|
||||
kill_link(_new, "Internal error handling connection");
|
||||
userrec::QuitUser(_new, "Internal error handling connection");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1099,14 +1095,14 @@ void force_nickchange(userrec* user,const char* newnick)
|
||||
if (MOD_RESULT)
|
||||
{
|
||||
ServerInstance->stats->statsCollisions++;
|
||||
kill_link(user,"Nickname collision");
|
||||
userrec::QuitUser(user,"Nickname collision");
|
||||
return;
|
||||
}
|
||||
|
||||
if (matches_qline(newnick))
|
||||
{
|
||||
ServerInstance->stats->statsCollisions++;
|
||||
kill_link(user,"Nickname collision");
|
||||
userrec::QuitUser(user,"Nickname collision");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user