}
+
+std::string GetServerDescription(char* servername)
+{
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int k = 0; k < me[j]->connectors.size(); k++)
+ {
+ if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),servername))
+ {
+ return me[j]->connectors[k].GetDescription();
+ }
+ }
+ }
+ return "";
+ }
+}
+
+
/* return 0 or 1 depending if users u and u2 share one or more common channels
* (used by QUIT, NICK etc which arent channel specific notices) */
{
WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, chlist(dest));
}
- WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerDesc);
+ WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server));
if (strcmp(dest->awaymsg,""))
{
WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg);
char* params = udp_msg + 2;
char finalparam[1024];
strcpy(finalparam," :xxxx");
- if (strstr(params," :")) {
- strncpy(finalparam,strstr(params," :"),1024);
+ if (strstr(udp_msg," :")) {
+ strncpy(finalparam,strstr(udp_msg," :"),1024);
}
if (token == '-') {
char* cookie = strtok(params," ");
if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),udp_host))
{
me[j]->connectors[k].SetServerName(servername);
+ me[j]->connectors[k].SetDescription(serverdesc);
+ me[j]->connectors[k].SetState(STATE_CONNECTED);
NetSendMyRoutingTable();
return;
}
if (!strcasecmp(serv->connectors[j].GetServerName().c_str(),udp_host))
{
serv->connectors[j].SetServerName(servername);
+ serv->connectors[j].SetDescription(serverdesc);
serv->connectors[j].SetServerPort(atoi(myport));
}
}
// send a 'diminutive' server message back...
snprintf(response,10240,"s %s %s :%s",ServerName,Link_SendPass,ServerDesc);
serv->SendPacket(response,servername);
+
+ for (int t = 0; t < serv->connectors.size(); t++)
+ {
+ if (!strcasecmp(serv->connectors[t].GetServerName().c_str(),servername))
+ {
+ serv->connectors[t].SetState(STATE_CONNECTED);
+ }
+ }
+
return;
}
}
// to an 'S' command. If we didn't recently send an 'S' to this server, theyre trying to spoof
// a connect, so put out an oper alert!
-
-
-
// for now, just accept all, we'll fix that later.
WriteOpers("%s accepted our link credentials ",servername);
// at this point we must begin key exchange and insert this
// server into our 'active' table.
for (int j = 0; j < 32; j++)
- {
+ {
if (me[j] != NULL)
{
for (int k = 0; k < me[j]->connectors.size(); k++)
if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),udp_host))
{
char buffer[MAXBUF];
+ me[j]->connectors[k].SetDescription(serverdesc);
+ me[j]->connectors[k].SetState(STATE_CONNECTED);
sprintf(buffer,"X 0");
serv->SendPacket(buffer,udp_host);
DoSync(me[j],udp_host);
log(DEBUG,"Servers are: '%s' '%s'",udp_host,me[j]->connectors[x].GetServerName().c_str());
if (!strcasecmp(me[j]->connectors[x].GetServerName().c_str(),udp_host))
{
- log(DEBUG,"match! process restricted stuff here");
- // found a valid ircd_connector.
- // TODO: Fix this so it only lets servers in that are in the
- // STATE_CONNECTED state!!!
- process_restricted_commands(token,params,me[j],serv,udp_host,me[j]->connectors[x].GetServerIP(),me[j]->connectors[x].GetServerPort());
- return;
+ if (me[j]->connectors[x].GetState() == STATE_CONNECTED)
+ {
+ // found a valid ircd_connector.
+ process_restricted_commands(token,params,me[j],serv,udp_host,me[j]->connectors[x].GetServerIP(),me[j]->connectors[x].GetServerPort());
+ return;
+ }
}
}
}
// *FIX* Instead of closing sockets in kill_link when they receive the ERROR :blah line, we should queue
// them in a list, then reap the list every second or so.
- if (reap_counter>2500)
+ if (reap_counter>300)
{
if (fd_reap.size() > 0)
{
if (result)
{
- log(DEBUG,"Read %d characters from socket",result);
+ if (result > 0)
+ log(DEBUG,"Read %d characters from socket",result);
userrec* current = count2a->second;
int currfd = current->fd;
char* l = strtok(data,"\n");