summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 14:38:24 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 14:38:24 +0000
commit93876363f89ea7a451ba1e18407e08a539854208 (patch)
tree25b70293d4358ce4af60e355a4b3a8483d666699 /src
parent6ab1d0dffb8084bf6a2ad8a446a3836fa3760c8a (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/cmd_kill.cpp2
-rw-r--r--src/cull_list.cpp2
-rw-r--r--src/modules.cpp7
-rw-r--r--src/modules/extra/m_filter_pcre.cpp2
-rw-r--r--src/modules/extra/m_sqlauth.cpp4
-rw-r--r--src/modules/m_blockamsg.cpp2
-rw-r--r--src/modules/m_conn_waitpong.cpp2
-rw-r--r--src/modules/m_connflood.cpp4
-rw-r--r--src/modules/m_filter.cpp2
-rw-r--r--src/modules/m_park.cpp2
-rw-r--r--src/modules/m_saquit.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp8
-rw-r--r--src/userprocess.cpp12
-rw-r--r--src/users.cpp32
14 files changed, 37 insertions, 46 deletions
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index 0084da9dc..ad602c097 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -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
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index 1acdd4517..e6b105925 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -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;
diff --git a/src/modules.cpp b/src/modules.cpp
index 1b00f3510..71dee1a59 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -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));
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp
index 58ca77333..a658a60b6 100644
--- a/src/modules/extra/m_filter_pcre.cpp
+++ b/src/modules/extra/m_filter_pcre.cpp
@@ -144,7 +144,7 @@ class ModuleFilterPCRE : public Module
if (do_action == "kill")
{
- Srv->QuitUser(user,reason);
+ userrec::QuitUser(user,reason);
}
return 1;
}
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index a1b58151d..e6878777d 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -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;
}
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index fdbc33839..b46da5527 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -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);
diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp
index a97fe8d3f..d89030ff9 100644
--- a/src/modules/m_conn_waitpong.cpp
+++ b/src/modules/m_conn_waitpong.cpp
@@ -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;
}
}
diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp
index 8df8ecefc..e5d3fd2ad 100644
--- a/src/modules/m_connflood.cpp
+++ b/src/modules/m_connflood.cpp
@@ -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;
}
}
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 1fd3bde92..8dd862ee7 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -116,7 +116,7 @@ class ModuleFilter : public Module
if (f->action == "kill")
{
- Srv->QuitUser(user,f->reason);
+ userrec::QuitUser(user,f->reason);
}
return 1;
}
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 31da8f033..2a9aad5f0 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -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;
}
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index 0069e3486..5ede08b67 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -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);
}
}
};
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 93e501e6f..491c3c471 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -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);
}
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 7468d0890..ba05032ca 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -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;
}
diff --git a/src/users.cpp b/src/users.cpp
index 34c347cb9..8a48a641c 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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;
}