log(DEBUG,"kill: %s %s",parameters[0],parameters[1]);
if (u)
{
- WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerName,user->dhost,user->nick,parameters[1]);
- // :Brain!brain@NetAdmin.chatspike.net KILL [Brain] :homer!NetAdmin.chatspike.net!Brain (test kill)
- WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
- sprintf(killreason,"Killed (%s (%s))",user->nick,parameters[1]);
- kill_link(u,killreason);
+ if (strcmp(ServerName,u->server))
+ {
+ // remote kill
+ WriteOpers("*** Remote kill: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
+ sprintf(killreason,"[%s] Killed (%s (%s))",u->server,user->nick,parameters[1]);
+ WriteCommonExcept(u,"QUIT :%s",killreason);
+ // K token must go to ALL servers!!!
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF,"K %s %s :%s",user->nick,u->nick,killreason);
+ for (int j = 0; j < 255; j++)
+ {
+ if (servers[j] != NULL)
+ {
+ if (strcmp(servers[j]->name,ServerName))
+ {
+ me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+ log(DEBUG,"Sent K token");
+ }
+ }
+ }
+ user_hash::iterator iter = clientlist.find(u->nick);
+ if (iter != clientlist.end())
+ {
+ log(DEBUG,"deleting user hash value %d",iter->second);
+ if ((iter->second) && (user->registered == 7)) {
+ delete iter->second;
+ }
+ clientlist.erase(iter);
+ }
+ purge_empty_chans();
+ }
+ else
+ {
+ // local kill
+ WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, 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]);
+ sprintf(killreason,"Killed (%s (%s))",user->nick,parameters[1]);
+ kill_link(u,killreason);
+ }
}
else
{
for (int i = 0; i < ConfValueEnum("link",&config_f); i++)
{
- ConfValue("link","name",i,Link_ServerName,&config_f);
- ConfValue("link","ipaddr",i,Link_IPAddr,&config_f);
- ConfValue("link","port",i,Link_Port,&config_f);
- ConfValue("link","sendpass",i,Link_Pass,&config_f);
- log(DEBUG,"(%d) Comparing against name='%s', ipaddr='%s', port='%s', recvpass='%s'",i,Link_ServerName,Link_IPAddr,Link_Port,Link_Pass);
- LinkPort = atoi(Link_Port);
- if (match(Link_ServerName,parameters[0])) {
- found = true;
+ if (!found)
+ {
+ ConfValue("link","name",i,Link_ServerName,&config_f);
+ ConfValue("link","ipaddr",i,Link_IPAddr,&config_f);
+ ConfValue("link","port",i,Link_Port,&config_f);
+ ConfValue("link","sendpass",i,Link_Pass,&config_f);
+ log(DEBUG,"(%d) Comparing against name='%s', ipaddr='%s', port='%s', recvpass='%s'",i,Link_ServerName,Link_IPAddr,Link_Port,Link_Pass);
+ LinkPort = atoi(Link_Port);
+ if (match(Link_ServerName,parameters[0])) {
+ found = true;
+ break;
+ }
}
}
}
}
+void handle_K(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port)
+{
+ char* src = strtok(params," ");
+ char* nick = strtok(NULL," :");
+ char* reason = strtok(NULL,"\r\n");
+ reason++;
+
+ userrec* u = Find(nick);
+ userrec* user = Find(src);
+
+ if ((user) && (u))
+ {
+ WriteTo(user, u, "KILL %s :%s!%s!%s!%s (%s)", u->nick, source->name,ServerName,user->dhost,user->nick,reason);
+ WriteOpers("*** Remote kill from %s by %s: %s!%s@%s (%s)",source->name,user->nick,u->nick,u->ident,u->host,reason);
+ snprintf(reason,MAXQUIT,"[%s] Killed (%s (%s))",source->name,user->nick,reason);
+ kill_link(u,reason);
+ }
+}
+
void handle_Q(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port)
{
char* nick = strtok(params," :");
case 'Q':
handle_Q(token,params,source,reply,udp_host,udp_port);
break;
+ // K <SOURCE> :<REASON>
+ // remote kill
+ case 'K':
+ handle_K(token,params,source,reply,udp_host,udp_port);
+ break;
// F <TS>
// end netburst
case 'F':
WriteOpers("Server %s has completed netburst. (%d secs)",source->name,time(NULL)-nb_start);
handle_F(token,params,source,reply,udp_host,udp_port);
-
- WriteOpers("Sending my burst now.");
- nb_start = time(NULL);
- //if (!source->initiator)
- //{
- // DoSync(reply,udp_host,udp_port,MyKey);
- //}
- WriteOpers("Completed burst to %s (%d secs)",source->name,time(NULL)-nb_start);
break;
// anything else
default:
strcpy(servers[j]->description,serverdesc);
servers[j]->internal_port = udp_port;
// create a server record for this server
+ WriteOpers("Server %s authenticated, exchanging server keys...",servername);
snprintf(response,10240,"O %d",MyKey);
serv->SendPacket(response,udp_host,udp_port,0);
return;
if (!strcasecmp(servers[i]->internal_addr,udp_host)) {
servers[i]->key = atoi(params);
log(DEBUG,"Key for this server is now %d",servers[i]->key);
- //if (servers[i]->initiator)
- //{
- DoSync(serv,udp_host,udp_port,MyKey);
- //}
+ DoSync(serv,udp_host,udp_port,MyKey);
return;
}
}