extern ServerConfig *Config;
extern user_hash clientlist;
extern whowas_hash whowas;
+extern Module* IOHookModule;
+std::vector<userrec*> local_users;
std::vector<userrec*> all_opers;
return;
if (sendq.length() + data.length() > (unsigned)this->sendqmax)
{
- WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
+ /* Fix by brain - Set the error text BEFORE calling writeopers, because
+ * if we dont it'll recursively call here over and over again trying
+ * to repeatedly add the text to the sendq!
+ */
this->SetWriteError("SendQ exceeded");
+ WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
return;
}
std::stringstream stream;
if (user->fd > -1)
{
- FOREACH_MOD OnRawSocketClose(user->fd);
+ if (IOHookModule)
+ {
+ IOHookModule->OnRawSocketClose(user->fd);
+ }
SE->DelFd(user->fd);
user->CloseSocket();
}
{
log(DEBUG,"deleting user hash value %lu",(unsigned long)user);
if (user->fd > -1)
+ {
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;
if (user->fd > -1)
{
- FOREACH_MOD OnRawSocketClose(user->fd);
+ if (IOHookModule)
+ {
+ IOHookModule->OnRawSocketClose(user->fd);
+ }
SE->DelFd(user->fd);
user->CloseSocket();
}
{
log(DEBUG,"deleting user hash value %lu",(unsigned long)user);
if (user->fd > -1)
+ {
fd_ref_table[user->fd] = NULL;
+ if (find(local_users.begin(),local_users.end(),user) != local_users.end())
+ {
+ log(DEBUG,"Delete local user");
+ local_users.erase(find(local_users.begin(),local_users.end(),user));
+ }
+ }
clientlist.erase(iter);
}
delete user;
}
}
fd_ref_table[socket] = clientlist[tempnick];
+ local_users.push_back(clientlist[tempnick]);
SE->AddFd(socket,true,X_ESTAB_CLIENT);
}
}
}
+/* re-allocates a nick in the user_hash after they change nicknames,
+ * returns a pointer to the new user as it may have moved */
+
+userrec* ReHashNick(char* Old, char* New)
+{
+ //user_hash::iterator newnick;
+ user_hash::iterator oldnick = clientlist.find(Old);
+
+ log(DEBUG,"ReHashNick: %s %s",Old,New);
+
+ if (!strcasecmp(Old,New))
+ {
+ log(DEBUG,"old nick is new nick, skipping");
+ return oldnick->second;
+ }
+
+ if (oldnick == clientlist.end()) return NULL; /* doesnt exist */
+
+ log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
+
+ userrec* olduser = oldnick->second;
+ clientlist[New] = olduser;
+ clientlist.erase(oldnick);
+
+ log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
+
+ return clientlist[New];
+}
+
+void force_nickchange(userrec* user,const char* newnick)
+{
+ char nick[MAXBUF];
+ int MOD_RESULT = 0;
+
+ strcpy(nick,"");
+
+ FOREACH_RESULT(OnUserPreNick(user,newnick));
+ if (MOD_RESULT) {
+ stats->statsCollisions++;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+ if (matches_qline(newnick))
+ {
+ stats->statsCollisions++;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+
+ if (user)
+ {
+ if (newnick)
+ {
+ strncpy(nick,newnick,MAXBUF);
+ }
+ if (user->registered == 7)
+ {
+ char* pars[1];
+ pars[0] = nick;
+ handle_nick(pars,1,user);
+ }
+ }
+}
+