vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- WriteFrom(u->fd,u,"%s",textbuffer);
+ // FIX: Stops a message going to the same person more than once
+ std::vector<int> already_sent;
for (int i = 0; i < MAXCHANS; i++)
{
{
char* o = (*ulist)[j];
userrec* otheruser = (userrec*)o;
- WriteFrom(otheruser->fd,u,"%s",textbuffer);
+ bool do_send = true;
+ for (int t = 0; t < already_sent.size(); t++)
+ {
+ if (already_sent[t] == otheruser->fd)
+ {
+ do_send = false;
+ break;
+ }
+ }
+ if (do_send)
+ {
+ already_sent.push_back(otheruser->fd);
+ WriteFrom(otheruser->fd,u,"%s",textbuffer);
+ }
}
}
}
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
+ std::vector<int> already_sent;
+
for (int i = 0; i < MAXCHANS; i++)
{
if (u->chans[i].channel)
char* o = (*ulist)[j];
userrec* otheruser = (userrec*)o;
if (u != otheruser)
- WriteFrom(otheruser->fd,u,"%s",textbuffer);
+ {
+ bool do_send = true;
+ for (int t = 0; t < already_sent.size(); t++)
+ {
+ if (already_sent[t] == otheruser->fd)
+ {
+ do_send = false;
+ break;
+ }
+ }
+ if (do_send)
+ {
+ already_sent.push_back(otheruser->fd);
+ WriteFrom(otheruser->fd,u,"%s",textbuffer);
+ }
+ }
}
}
}
AddWhoWas(user);
}
+ if (user->registered == 7) {
+ purge_empty_chans(user);
+ }
+
if (iter != clientlist.end())
{
log(DEBUG,"deleting user hash value %lu",(unsigned long)iter->second);
}
clientlist.erase(iter);
}
-
- if (user->registered == 7) {
- purge_empty_chans(user);
- }
- delete user;
- //user = NULL;
}
void kill_link_silent(userrec *user,const char* r)
shutdown(user->fd,2);
close(user->fd);
}
+
+ if (user->registered == 7) {
+ purge_empty_chans(user);
+ }
if (iter != clientlist.end())
{
}
clientlist.erase(iter);
}
-
- if (user->registered == 7) {
- purge_empty_chans(user);
- }
- delete user;
}
}
}
-void handle_version(char **parameters, int pcnt, userrec *user)
+std::string GetVersionString()
{
- char Revision[] = "$Revision$";
-
- char *s1 = Revision;
- char *savept;
- char *v2 = strtok_r(s1," ",&savept);
- s1 = savept;
- v2 = strtok_r(s1," ",&savept);
- s1 = savept;
+ char Revision[] = "$Revision$";
+ char versiondata[MAXBUF];
+ char *s1 = Revision;
+ char *savept;
+ char *v2 = strtok_r(s1," ",&savept);
+ s1 = savept;
+ v2 = strtok_r(s1," ",&savept);
+ s1 = savept;
+ snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s (O=%lu)",VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION);
- WriteServ(user->fd,"351 %s :%s Rev. %s %s :%s (O=%lu)",user->nick,VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION);
+}
+
+void handle_version(char **parameters, int pcnt, userrec *user)
+{
+ if (!pcnt)
+ {
+ WriteServ(user->fd,"351 %s :%s",user->nick,GetVersionString().c_str());
+ }
+ else
+ {
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int x = 0; x < me[j]->connectors.size(); x++)
+ {
+ if (match(me[j]->connectors[x].GetServerName().c_str(),parameters[0]))
+ {
+ WriteServ(user->fd,"351 %s :%s",user->nick,me[j]->connectors[x].GetVersionString().c_str());
+ return;
+ }
+ }
+ }
+ }
+ WriteServ(user->fd,"402 %s %s :No such server",user->nick,parameters[0]);
+ }
+ return;
}
{
if (strlen(command)>=(strlen(cmdlist[i].command))) if (!strncmp(command, cmdlist[i].command,MAXCOMMAND))
{
- log(DEBUG,"Found matching command");
-
if (parameters)
{
if (parameters[0])
if (user)
{
- log(DEBUG,"Processing command");
-
/* activity resets the ping pending timer */
user->nping = TIME + user->pingmax;
if ((items) < cmdlist[i].min_params)
}
if ((user->registered == 7) || (!strncmp(command,"USER",4)) || (!strncmp(command,"NICK",4)) || (!strncmp(command,"PASS",4)))
{
- log(DEBUG,"process_command: handler: %s %s %lu",user->nick,command,(unsigned long)items);
if (cmdlist[i].handler_function)
{
}
else
{
- log(DEBUG,"process_command: not registered: %s %s",user->nick,command);
WriteServ(user->fd,"451 %s :You have not registered",command);
return;
}
}
if ((!cmd_found) && (user))
{
- log(DEBUG,"process_command: not in table: %s %s",user->nick,command);
WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
}
}
{
return;
}
- log(DEBUG,"InspIRCd: processing: %s %s",user->nick,cmd);
+ log(DEBUG,"CMDIN: %s %s",user->nick,cmd);
tidystring(cmd);
if ((user) && (cmd))
{
snprintf(data,MAXBUF,"Y %lu",(unsigned long)TIME);
serv->SendPacket(data,tcp_host);
// send users and channels
+
+ NetSendMyRoutingTable();
+
+ // send all routing table and uline voodoo. The ordering of these commands is IMPORTANT!
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int k = 0; k < me[j]->connectors.size(); k++)
+ {
+ if (is_uline(me[j]->connectors[k].GetServerName().c_str()))
+ {
+ snprintf(data,MAXBUF,"H %s",me[j]->connectors[k].GetServerName().c_str());
+ serv->SendPacket(data,tcp_host);
+ }
+ }
+ }
+ }
+
+ // send our version for the remote side to cache
+ snprintf(data,MAXBUF,"v %s %s",ServerName,GetVersionString().c_str());
+ serv->SendPacket(data,tcp_host);
+
+ // sync the users and channels, give the modules a look-in.
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
snprintf(data,MAXBUF,"N %lu %s %s %s %s +%s %s %s :%s",(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,u->second->ip,u->second->server,u->second->fullname);
// sync global zlines, glines, etc
sync_xlines(serv,tcp_host);
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (int k = 0; k < me[j]->connectors.size(); k++)
- {
- if (is_uline(me[j]->connectors[k].GetServerName().c_str()))
- {
- snprintf(data,MAXBUF,"H %s",me[j]->connectors[k].GetServerName().c_str());
- serv->SendPacket(data,tcp_host);
- NetSendMyRoutingTable();
- }
- }
- }
- }
-
snprintf(data,MAXBUF,"F %lu",(unsigned long)TIME);
serv->SendPacket(data,tcp_host);
log(DEBUG,"Sent sync");
}
work[p--] = '\0';
}
- log(DEBUG,"Dir valid: %s",work);
char buffer[MAXBUF], otherdir[MAXBUF];
// Get the current working directory
if( getcwd( buffer, MAXBUF ) == NULL )
if( getcwd( otherdir, MAXBUF ) == NULL )
return false;
chdir(buffer);
- log(DEBUG,"Dir is really: %s",otherdir);
if (strlen(otherdir) >= strlen(work))
{
otherdir[strlen(work)] = '\0';
- log(DEBUG,"Compare: '%s' -> '%s'",otherdir,work);
if (!strcmp(otherdir,work))
{
- log(DEBUG,"Match ok");
return true;
}
- log(DEBUG,"No match");
return false;
}
else return false;
Exit(ERROR);
}
- log(DEBUG,"InspIRCd: startup: begin");
- log(DEBUG,"$Id$");
+ log(DEFAULT,"$Id$");
if (geteuid() == 0)
{
printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
printf("Loading module... \033[1;32m%s\033[0m\n",configToken);
if (!LoadModule(configToken))
{
- log(DEBUG,"Exiting due to a module loader error.");
+ log(DEFAULT,"Exiting due to a module loader error.");
printf("\nThere was an error loading a module: %s\n\nYou might want to do './inspircd start' instead of 'bin/inspircd'\n\n",ModuleError());
Exit(0);
}
}
- log(DEBUG,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1);
+ log(DEFAULT,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1);
startup_time = time(NULL);