summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/commands.h33
-rw-r--r--include/inspircd.h1
-rw-r--r--src/InspIRCd.dev22
-rw-r--r--src/InspIRCd.layout48
-rw-r--r--src/commands.cpp957
-rw-r--r--src/inspircd.cpp982
6 files changed, 1056 insertions, 987 deletions
diff --git a/include/commands.h b/include/commands.h
index 4840424c9..f092423ab 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -12,6 +12,9 @@
#include "users.h"
#include "channels.h"
+
+/** These are the handlers for user commands
+ */
void handle_join(char **parameters, int pcnt, userrec *user);
void handle_part(char **parameters, int pcnt, userrec *user);
void handle_kick(char **parameters, int pcnt, userrec *user);
@@ -55,5 +58,35 @@ void handle_map(char **parameters, int pcnt, userrec *user);
void handle_oper(char **parameters, int pcnt, userrec *user);
void handle_nick(char **parameters, int pcnt, userrec *user);
+/** Special functions for processing server to server traffic
+ */
+void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv);
+void process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host,char* ipaddr,int port);
+
+/** These are the handlers for server commands (tokens)
+ */
+void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_dollar(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_J(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_R(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_plus(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_b(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_a(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_F(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_AT(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_k(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_n(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_Q(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_K(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_L(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_m(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_M(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_T(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_t(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_i(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_P(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+void handle_V(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host);
+
#endif
diff --git a/include/inspircd.h b/include/inspircd.h
index 31bcad10f..3011d286f 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -154,5 +154,6 @@ void NetSendToAllExcept(const char* target,char* s);
void NetSendMyRoutingTable();
void DoSplit(const char* params);
void RemoveServer(const char* name);
+void DoSync(serverrec* serv, char* tcp_host);
diff --git a/src/InspIRCd.dev b/src/InspIRCd.dev
index 128a84bcf..5012e26ff 100644
--- a/src/InspIRCd.dev
+++ b/src/InspIRCd.dev
@@ -1,7 +1,7 @@
[Project]
FileName=InspIRCd.dev
Name=InspIRCd - The Inspire Internet Relay Chat Daemon
-UnitCount=43
+UnitCount=45
Type=1
Ver=1
ObjFiles=
@@ -475,3 +475,23 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
+[Unit44]
+FileName=commands.cpp
+CompileCpp=1
+Folder=Source
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit45]
+FileName=..\include\commands.h
+CompileCpp=1
+Folder=Headers
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index bb91d8747..12286c6d4 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -1,6 +1,6 @@
[Editors]
Focused=1
-Order=1,2,4,6,3,7,25,5,24,-1,39,42
+Order=1,2,4,6,3,7,25,5,24,-1,39,42,43
[Editor_0]
Open=0
@@ -13,9 +13,9 @@ LeftChar=1
[Editor_1]
Open=1
Top=1
-CursorCol=1
-CursorRow=2762
-TopLine=2726
+CursorCol=42
+CursorRow=3192
+TopLine=3148
LeftChar=1
[Editor_2]
@@ -99,7 +99,7 @@ TopLine=1
LeftChar=1
[Editor_12]
-Open=0
+Open=1
Top=0
CursorCol=12
CursorRow=104
@@ -141,9 +141,9 @@ LeftChar=1
[Editor_17]
Open=1
Top=0
-CursorCol=32
-CursorRow=98
-TopLine=74
+CursorCol=44
+CursorRow=157
+TopLine=103
LeftChar=1
[Editor_18]
@@ -187,7 +187,7 @@ TopLine=83
LeftChar=1
[Editor_23]
-Open=0
+Open=1
Top=0
CursorCol=1
CursorRow=1
@@ -197,9 +197,9 @@ LeftChar=1
[Editor_24]
Open=1
Top=0
-CursorCol=50
-CursorRow=348
-TopLine=320
+CursorCol=1
+CursorRow=15
+TopLine=1
LeftChar=1
[Editor_25]
Open=1
@@ -316,14 +316,28 @@ LeftChar=1
[Editor_41]
Open=1
Top=0
-CursorCol=62
-CursorRow=30
+CursorCol=22
+CursorRow=13
TopLine=1
LeftChar=1
[Editor_42]
Open=1
Top=0
-CursorCol=1
-CursorRow=37
-TopLine=1
+CursorCol=21
+CursorRow=36
+TopLine=16
+LeftChar=1
+[Editor_43]
+Open=1
+Top=0
+CursorCol=90
+CursorRow=2342
+TopLine=2291
+LeftChar=1
+[Editor_44]
+Open=1
+Top=0
+CursorCol=89
+CursorRow=89
+TopLine=38
LeftChar=1
diff --git a/src/commands.cpp b/src/commands.cpp
index b7baa9b9f..c84edf2ea 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -32,6 +32,7 @@
#include "dynamic.h"
#include "wildcard.h"
#include "message.h"
+#include "mode.h"
#ifdef GCC3
#define nspace __gnu_cxx
@@ -1385,4 +1386,960 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
+void handle_V(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* src = strtok(params," ");
+ char* dest = strtok(NULL," :");
+ char* text = strtok(NULL,"\r\n");
+ text++;
+
+ userrec* user = Find(src);
+ if (user)
+ {
+ userrec* dst = Find(dest);
+
+ if (dst)
+ {
+ WriteTo(user, dst, "NOTICE %s :%s", dst->nick, text);
+ }
+ else
+ {
+ chanrec* d = FindChan(dest);
+ if (d)
+ {
+ ChanExceptSender(d, user, "NOTICE %s :%s", d->name, text);
+ }
+ }
+ }
+
+}
+
+
+void handle_P(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* src = strtok(params," ");
+ char* dest = strtok(NULL," :");
+ char* text = strtok(NULL,"\r\n");
+ text++;
+
+ userrec* user = Find(src);
+ if (user)
+ {
+ userrec* dst = Find(dest);
+
+ if (dst)
+ {
+ WriteTo(user, dst, "PRIVMSG %s :%s", dst->nick, text);
+ }
+ else
+ {
+ chanrec* d = FindChan(dest);
+ if (d)
+ {
+ ChanExceptSender(d, user, "PRIVMSG %s :%s", d->name, text);
+ }
+ }
+ }
+
+}
+
+void handle_i(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* nick = strtok(params," ");
+ char* from = strtok(NULL," ");
+ char* channel = strtok(NULL," ");
+ userrec* u = Find(nick);
+ userrec* user = Find(from);
+ chanrec* c = FindChan(channel);
+ if ((c) && (u) && (user))
+ {
+ u->InviteTo(c->name);
+ WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
+ }
+}
+
+void handle_t(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* setby = strtok(params," ");
+ char* channel = strtok(NULL," :");
+ char* topic = strtok(NULL,"\r\n");
+ topic++;
+ userrec* u = Find(setby);
+ chanrec* c = FindChan(channel);
+ if ((c) && (u))
+ {
+ WriteChannelLocal(c,u,"TOPIC %s :%s",c->name,topic);
+ strncpy(c->topic,topic,MAXTOPIC);
+ strncpy(c->setby,u->nick,NICKMAX);
+ }
+}
+
+
+void handle_T(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* tm = strtok(params," ");
+ char* setby = strtok(NULL," ");
+ char* channel = strtok(NULL," :");
+ char* topic = strtok(NULL,"\r\n");
+ topic++;
+ time_t TS = atoi(tm);
+ chanrec* c = FindChan(channel);
+ if (c)
+ {
+ // in the case of topics and TS, the *NEWER*
+ if (TS <= c->topicset)
+ {
+ WriteChannelLocal(c,NULL,"TOPIC %s :%s",c->name,topic);
+ strncpy(c->topic,topic,MAXTOPIC);
+ strncpy(c->setby,setby,NICKMAX);
+ }
+ }
+}
+
+void handle_M(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* pars[128];
+ char original[MAXBUF],target[MAXBUF];
+ strncpy(original,params,MAXBUF);
+ int index = 0;
+ char* parameter = strtok(params," ");
+ strncpy(target,parameter,MAXBUF);
+ while (parameter)
+ {
+ pars[index++] = parameter;
+ parameter = strtok(NULL," ");
+ }
+ merge_mode(pars,index);
+ if (FindChan(target))
+ {
+ WriteChannelLocal(FindChan(target), NULL, "MODE %s",original);
+ }
+ if (Find(target))
+ {
+ WriteTo(NULL,Find(target),"MODE %s",original);
+ }
+}
+
+// m is modes set by users only (not servers) valid targets are channels or users.
+
+void handle_m(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ // m blah #chatspike +b *!test@*4
+ char* pars[128];
+ char original[MAXBUF];
+ strncpy(original,params,MAXBUF);
+
+ if (!strchr(params,' '))
+ {
+ WriteOpers("WARNING! 'm' token in data stream without any parameters! Something fishy is going on!");
+ return;
+ }
+
+ int index = 0;
+
+ char* src = strtok(params," ");
+ userrec* user = Find(src);
+
+ if (user)
+ {
+ log(DEBUG,"Found user: %s",user->nick);
+ char* parameter = strtok(NULL," ");
+ while (parameter)
+ {
+ pars[index++] = parameter;
+ parameter = strtok(NULL," ");
+ }
+
+ log(DEBUG,"Calling merge_mode2");
+ merge_mode2(pars,index,user);
+ }
+}
+
+
+void handle_L(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* nick = strtok(params," ");
+ char* channel = strtok(NULL," :");
+ char* reason = strtok(NULL,"\r\n");
+ userrec* user = Find(nick);
+ reason++;
+ if (user)
+ {
+ if (strcmp(reason,""))
+ {
+ del_channel(user,channel,reason,true);
+ }
+ else
+ {
+ del_channel(user,channel,NULL,true);
+ }
+ }
+}
+
+void handle_K(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* src = strtok(params," ");
+ char* nick = strtok(NULL," :");
+ char* reason = strtok(NULL,"\r\n");
+ char kreason[MAXBUF];
+ 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(kreason,MAXBUF,"[%s] Killed (%s (%s))",source->name,user->nick,reason);
+ kill_link(u,kreason);
+ }
+}
+
+void handle_Q(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* nick = strtok(params," :");
+ char* reason = strtok(NULL,"\r\n");
+ reason++;
+
+ userrec* user = Find(nick);
+
+ if (user)
+ {
+ if (strlen(reason)>MAXQUIT)
+ {
+ reason[MAXQUIT-1] = '\0';
+ }
+
+
+ WriteCommonExcept(user,"QUIT :%s",reason);
+
+ user_hash::iterator iter = clientlist.find(user->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();
+ }
+}
+
+void handle_n(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* oldnick = strtok(params," ");
+ char* newnick = strtok(NULL," ");
+
+ userrec* user = Find(oldnick);
+
+ if (user)
+ {
+ WriteCommon(user,"NICK %s",newnick);
+ user = ReHashNick(user->nick, newnick);
+ if (!user) return;
+ if (!user->nick) return;
+ strncpy(user->nick, newnick,NICKMAX);
+ log(DEBUG,"new nick set: %s",user->nick);
+ }
+}
+
+// k <SOURCE> <DEST> <CHANNEL> :<REASON>
+void handle_k(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* src = strtok(params," ");
+ char* dest = strtok(NULL," ");
+ char* channel = strtok(NULL," :");
+ char* reason = strtok(NULL,"\r\n");
+ reason++;
+ userrec* s = Find(src);
+ userrec* d = Find(dest);
+ chanrec* c = FindChan(channel);
+ if ((s) && (d) && (c))
+ {
+ kick_channel(s,d,c,reason);
+ }
+}
+
+void handle_AT(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* who = strtok(params," :");
+ char* text = strtok(NULL,"\r\n");
+ text++;
+ userrec* s = Find(who);
+ if (s)
+ {
+ WriteWallOps(s,true,text);
+ }
+}
+
+
+void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* tm = strtok(params," ");
+ char* nick = strtok(NULL," ");
+ char* host = strtok(NULL," ");
+ char* dhost = strtok(NULL," ");
+ char* ident = strtok(NULL," ");
+ char* modes = strtok(NULL," ");
+ char* server = strtok(NULL," :");
+ char* gecos = strtok(NULL,"\r\n");
+ gecos++;
+ modes++;
+ time_t TS = atoi(tm);
+ user_hash::iterator iter = clientlist.find(nick);
+ if (iter != clientlist.end())
+ {
+ // nick collision
+ WriteOpers("Nickname collision: %s@%s != %s@%s",nick,server,iter->second->nick,iter->second->server);
+ char str[MAXBUF];
+ snprintf(str,MAXBUF,"Killed (Nick Collision (%s@%s < %s@%s))",nick,server,iter->second->nick,iter->second->server);
+ WriteServ(iter->second->fd, "KILL %s :%s",iter->second->nick,str);
+ kill_link(iter->second,str);
+ }
+ clientlist[nick] = new userrec();
+ // remote users have an fd of -1. This is so that our Write abstraction
+ // routines know to route any messages to this record away to whatever server
+ // theyre on.
+ clientlist[nick]->fd = -1;
+ strncpy(clientlist[nick]->nick, nick,NICKMAX);
+ strncpy(clientlist[nick]->host, host,160);
+ strncpy(clientlist[nick]->dhost, dhost,160);
+ strncpy(clientlist[nick]->server, server,256);
+ strncpy(clientlist[nick]->ident, ident,10); // +1 char to compensate for tilde
+ strncpy(clientlist[nick]->fullname, gecos,128);
+ clientlist[nick]->signon = TS;
+ clientlist[nick]->nping = 0; // this is ignored for a remote user anyway.
+ clientlist[nick]->lastping = 1;
+ clientlist[nick]->port = 0; // so is this...
+ clientlist[nick]->registered = 7; // this however we need to set for them to receive messages and appear online
+ clientlist[nick]->idle_lastmsg = time(NULL); // this is unrealiable and wont actually be used locally
+ for (int i = 0; i < MAXCHANS; i++)
+ {
+ clientlist[nick]->chans[i].channel = NULL;
+ clientlist[nick]->chans[i].uc_modes = 0;
+ }
+}
+
+void handle_F(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ long tdiff = time(NULL) - atoi(params);
+ if (tdiff)
+ WriteOpers("TS split for %s -> %s: %d",source->name,reply->name,tdiff);
+}
+
+void handle_a(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* nick = strtok(params," :");
+ char* gecos = strtok(NULL,"\r\n");
+
+ userrec* user = Find(nick);
+
+ if (user)
+ strncpy(user->fullname,gecos,MAXBUF);
+}
+
+void handle_b(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* nick = strtok(params," ");
+ char* host = strtok(NULL," ");
+
+ userrec* user = Find(nick);
+
+ if (user)
+ strncpy(user->dhost,host,160);
+}
+
+void handle_plus(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ // %s %s %d %d
+ // + test3.chatspike.net 7010 -2016508415
+ char* servername = strtok(params," ");
+ char* ipaddr = strtok(NULL," ");
+ char* ipport = strtok(NULL," ");
+ char* cookie = strtok(NULL," ");
+ log(DEBUG,"*** Connecting back to %s:%d",ipaddr,atoi(ipport));
+
+
+ bool conn_already = false;
+ for (int i = 0; i < 32; i++)
+ {
+ if (me[i] != NULL)
+ {
+ for (int j = 0; j < me[i]->connectors.size(); j++)
+ {
+ if (!strcasecmp(me[i]->connectors[j].GetServerName().c_str(),servername))
+ {
+ if (me[i]->connectors[j].GetServerPort() == atoi(ipport))
+ {
+ log(DEBUG,"Already got a connection to %s:%d, ignoring +",ipaddr,atoi(ipport));
+ conn_already = true;
+ }
+ }
+ }
+ }
+ }
+ if (!conn_already)
+ me[defaultRoute]->MeshCookie(ipaddr,atoi(ipport),atoi(cookie),servername);
+}
+
+void handle_R(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* server = strtok(params," ");
+ char* data = strtok(NULL,"\r\n");
+ log(DEBUG,"Forwarded packet '%s' to '%s'",data,server);
+ NetSendToOne(server,data);
+}
+
+void handle_J(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ // IMPORTANT NOTE
+ // The J token currently has no timestamp - this needs looking at
+ // because it will allow splitriding.
+ char* nick = strtok(params," ");
+ char* channel = strtok(NULL," ");
+ userrec* user = Find(nick);
+ while (channel)
+ {
+ if ((user != NULL) && (strcmp(channel,"")))
+ {
+ char privilage = '\0';
+ if (channel[0] != '#')
+ {
+ privilage = channel[0];
+ channel++;
+ }
+ add_channel(user,channel,"",true);
+
+ // now work out the privilages they should have on each channel
+ // and send the appropriate servermodes.
+ for (int i = 0; i != MAXCHANS; i++)
+ {
+ if (user->chans[i].channel)
+ {
+ if (!strcasecmp(user->chans[i].channel->name,channel))
+ {
+ if (privilage == '@')
+ {
+ user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_OP;
+ WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +o %s",channel,user->nick);
+ }
+ if (privilage == '%')
+ {
+ user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_HOP;
+ WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +h %s",channel,user->nick);
+ }
+ if (privilage == '+')
+ {
+ user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_VOICE;
+ WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +v %s",channel,user->nick);
+ }
+ }
+ }
+ }
+
+ }
+ channel = strtok(NULL," ");
+ }
+}
+
+void handle_dollar(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ log(DEBUG,"Storing routing table...");
+ char* sourceserver = strtok(params," ");
+ char* server = strtok(NULL," ");
+ for (int i = 0; i < 32; i++)
+ {
+ if (me[i] != NULL)
+ {
+ for (int j = 0; j < me[i]->connectors.size(); j++)
+ {
+ if (!strcasecmp(me[i]->connectors[j].GetServerName().c_str(),sourceserver))
+ {
+ me[i]->connectors[j].routes.clear();
+ log(DEBUG,"Found entry for source server.");
+ while (server)
+ {
+ // store each route
+ me[i]->connectors[j].routes.push_back(server);
+ log(DEBUG,"*** Stored route: %s -> %s -> %s",ServerName,sourceserver,server);
+ server = strtok(NULL," ");
+ }
+ return;
+ }
+ }
+ }
+ }
+ log(DEBUG,"Warning! routing table received from nonexistent server!");
+}
+
+void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ log(DEBUG,"Netsplit! %s split from mesh, removing!",params);
+ bool go_again = true;
+ while (go_again)
+ {
+ go_again = false;
+ for (int i = 0; i < 32; i++)
+ {
+ if (me[i] != NULL)
+ {
+ for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
+ {
+ if (!strcasecmp(j->GetServerName().c_str(),params))
+ {
+ j->routes.clear();
+ j->CloseConnection();
+ me[i]->connectors.erase(j);
+ go_again = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ log(DEBUG,"Removed server. Will remove clients...");
+ // iterate through the userlist and remove all users on this server.
+ // because we're dealing with a mesh, we dont have to deal with anything
+ // "down-route" from this server (nice huh)
+ go_again = true;
+ char reason[MAXBUF];
+ snprintf(reason,MAXBUF,"%s %s",ServerName,params);
+ while (go_again)
+ {
+ go_again = false;
+ for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+ {
+ if (!strcasecmp(u->second->server,params))
+ {
+ kill_link(u->second,reason);
+ go_again = true;
+ break;
+ }
+ }
+ }
+}
+
+long authcookie;
+
+
+void process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host,char* ipaddr,int port)
+{
+ char buffer[MAXBUF];
+
+ switch(token)
+ {
+ // Y <TS>
+ // start netburst
+ case 'Y':
+ nb_start = time(NULL);
+ WriteOpers("Server %s is starting netburst.",tcp_host);
+ // now broadcast this new servers address out to all servers that are linked to us,
+ // except the newcomer. They'll all attempt to connect back to it.
+ authcookie = rand()*rand();
+ snprintf(buffer,MAXBUF,"~ %d",authcookie);
+ NetSendToAll(buffer);
+ break;
+ // ~
+ // Store authcookie
+ // once stored, this authcookie permits other servers to log in
+ // without user or password, using it.
+ case '~':
+ auth_cookies.push_back(atoi(params));
+ log(DEBUG,"*** Stored auth cookie, will permit servers with auth-cookie %d",atoi(params));
+ break;
+ // connect back to a server using an authcookie
+ case '+':
+ handle_plus(token,params,source,reply,tcp_host);
+ break;
+ // routing table
+ case '$':
+ handle_dollar(token,params,source,reply,tcp_host);
+ break;
+ // node unreachable - we cant route to a server, sooooo we slit it off.
+ // servers can generate these for themselves for an squit.
+ case '&':
+ handle_amp(token,params,source,reply,tcp_host);
+ break;
+ // R <server> <data>
+ // redirect token, send all of <data> along to the given
+ // server as this server has been found to still have a route to it
+ case 'R':
+ handle_R(token,params,source,reply,tcp_host);
+ break;
+ // ?
+ // ping
+ case '?':
+ reply->SendPacket("!",tcp_host);
+ break;
+ // ?
+ // pong
+ case '!':
+ break;
+ // *
+ // no operation
+ case '*':
+ break;
+ // N <TS> <NICK> <HOST> <DHOST> <IDENT> <MODES> <SERVER> :<GECOS>
+ // introduce remote client
+ case 'N':
+ handle_N(token,params,source,reply,tcp_host);
+ break;
+ // a <NICK> :<GECOS>
+ // change GECOS (SETNAME)
+ case 'a':
+ handle_a(token,params,source,reply,tcp_host);
+ break;
+ // b <NICK> :<HOST>
+ // change displayed host (SETHOST)
+ case 'b':
+ handle_b(token,params,source,reply,tcp_host);
+ break;
+ // t <NICK> <CHANNEL> :<TOPIC>
+ // change a channel topic
+ case 't':
+ handle_t(token,params,source,reply,tcp_host);
+ break;
+ // i <NICK> <CHANNEL>
+ // invite a user to a channel
+ case 'i':
+ handle_i(token,params,source,reply,tcp_host);
+ break;
+ // k <SOURCE> <DEST> <CHANNEL> :<REASON>
+ // kick a user from a channel
+ case 'k':
+ handle_k(token,params,source,reply,tcp_host);
+ break;
+ // n <NICK> <NEWNICK>
+ // change nickname of client -- a server should only be able to
+ // change the nicknames of clients that reside on it unless
+ // they are ulined.
+ case 'n':
+ handle_n(token,params,source,reply,tcp_host);
+ break;
+ // J <NICK> <CHANLIST>
+ // Join user to channel list, merge channel permissions
+ case 'J':
+ handle_J(token,params,source,reply,tcp_host);
+ break;
+ // T <TS> <CHANNEL> <TOPICSETTER> :<TOPIC>
+ // change channel topic (netburst only)
+ case 'T':
+ handle_T(token,params,source,reply,tcp_host);
+ break;
+ // M <TARGET> <MODES> [MODE-PARAMETERS]
+ // Server setting modes on an object
+ case 'M':
+ handle_M(token,params,source,reply,tcp_host);
+ break;
+ // m <SOURCE> <TARGET> <MODES> [MODE-PARAMETERS]
+ // User setting modes on an object
+ case 'm':
+ handle_m(token,params,source,reply,tcp_host);
+ break;
+ // P <SOURCE> <TARGET> :<TEXT>
+ // Send a private/channel message
+ case 'P':
+ handle_P(token,params,source,reply,tcp_host);
+ break;
+ // V <SOURCE> <TARGET> :<TEXT>
+ // Send a private/channel notice
+ case 'V':
+ handle_V(token,params,source,reply,tcp_host);
+ break;
+ // L <SOURCE> <CHANNEL> :<REASON>
+ // User parting a channel
+ case 'L':
+ handle_L(token,params,source,reply,tcp_host);
+ break;
+ // Q <SOURCE> :<REASON>
+ // user quitting
+ case 'Q':
+ handle_Q(token,params,source,reply,tcp_host);
+ break;
+ // K <SOURCE> <DEST> :<REASON>
+ // remote kill
+ case 'K':
+ handle_K(token,params,source,reply,tcp_host);
+ break;
+ // @ <SOURCE> :<TEXT>
+ // wallops
+ case '@':
+ handle_AT(token,params,source,reply,tcp_host);
+ break;
+ // F <TS>
+ // end netburst
+ case 'F':
+ WriteOpers("Server %s has completed netburst. (%d secs)",tcp_host,time(NULL)-nb_start);
+ handle_F(token,params,source,reply,tcp_host);
+ nb_start = 0;
+ // tell all the other servers to use this authcookie to connect back again
+ // got '+ test3.chatspike.net 7010 -2016508415' from test.chatspike.net
+ snprintf(buffer,MAXBUF,"+ %s %s %d %d",tcp_host,ipaddr,port,authcookie);
+ NetSendToAllExcept(tcp_host,buffer);
+ break;
+ // X <reserved>
+ // Send netburst now
+ case 'X':
+ WriteOpers("Sending my netburst to %s",tcp_host);
+ DoSync(source,tcp_host);
+ WriteOpers("Send of netburst to %s completed",tcp_host);
+ NetSendMyRoutingTable();
+ break;
+ // anything else
+ default:
+ WriteOpers("WARNING! Unknown datagram type '%c'",token);
+ break;
+ }
+}
+
+
+void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv)
+{
+ char response[10240];
+ char token = udp_msg[0];
+ char* params = udp_msg + 2;
+ char finalparam[1024];
+ strcpy(finalparam," :xxxx");
+ if (strstr(udp_msg," :")) {
+ strncpy(finalparam,strstr(udp_msg," :"),1024);
+ }
+ if (token == '-') {
+ char* cookie = strtok(params," ");
+ char* servername = strtok(NULL," ");
+ char* serverdesc = finalparam+2;
+
+ WriteOpers("AuthCookie CONNECT from %s (%s)",servername,tcp_host);
+
+ for (int u = 0; u < auth_cookies.size(); u++)
+ {
+ if (auth_cookies[u] == atoi(cookie))
+ {
+ WriteOpers("Allowed cookie from %s, is now part of the mesh",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(),tcp_host))
+ {
+ me[j]->connectors[k].SetServerName(servername);
+ me[j]->connectors[k].SetDescription(serverdesc);
+ me[j]->connectors[k].SetState(STATE_CONNECTED);
+ NetSendMyRoutingTable();
+ return;
+ }
+ }
+ }
+ WriteOpers("\2WARNING!\2 %s sent us an authentication packet but we are not authenticating with this server right now! Possible intrusion attempt!",tcp_host);
+ return;
+ }
+
+
+ return;
+ }
+ }
+ // bad cookie, bad bad! go sit in the corner!
+ WriteOpers("Bad cookie from %s!",servername);
+ return;
+ }
+ else
+ if (token == 'S') {
+ // S test.chatspike.net password portn :ChatSpike InspIRCd test server
+ char* servername = strtok(params," ");
+ char* password = strtok(NULL," ");
+ char* myport = strtok(NULL," ");
+ char* revision = strtok(NULL," ");
+ char* serverdesc = finalparam+2;
+
+ WriteOpers("CONNECT from %s (%s) (their port: %d)",servername,tcp_host,atoi(myport));
+
+ ircd_connector* cn = serv->FindHost(servername);
+
+ if (cn)
+ {
+ WriteOpers("CONNECT aborted: Server %s already exists from %s",servername,ServerName);
+ char buffer[MAXBUF];
+ sprintf(buffer,"E :Server %s already exists!",servername);
+ serv->SendPacket(buffer,tcp_host);
+ RemoveServer(tcp_host);
+ return;
+ }
+
+ if (atoi(revision) != GetRevision())
+ {
+ WriteOpers("CONNECT aborted: Could not link to %s, is an incompatible version %s, our version is %d",servername,revision,GetRevision());
+ char buffer[MAXBUF];
+ sprintf(buffer,"E :Version number mismatch");
+ serv->SendPacket(buffer,tcp_host);
+ RemoveServer(tcp_host);
+ RemoveServer(servername);
+ return;
+ }
+
+ for (int j = 0; j < serv->connectors.size(); j++)
+ {
+ if (!strcasecmp(serv->connectors[j].GetServerName().c_str(),tcp_host))
+ {
+ serv->connectors[j].SetServerName(servername);
+ serv->connectors[j].SetDescription(serverdesc);
+ serv->connectors[j].SetServerPort(atoi(myport));
+ }
+ }
+
+
+ char Link_ServerName[1024];
+ char Link_IPAddr[1024];
+ char Link_Port[1024];
+ char Link_Pass[1024];
+ char Link_SendPass[1024];
+ int LinkPort = 0;
+
+ // search for a corresponding <link> block in the config files
+ 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","recvpass",i,Link_Pass,&config_f);
+ ConfValue("link","sendpass",i,Link_SendPass,&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 (!strcasecmp(Link_ServerName,servername))
+ {
+ // we have a matching link line -
+ // 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;
+ }
+ }
+ char buffer[MAXBUF];
+ sprintf(buffer,"E :Access is denied (no matching link block)");
+ serv->SendPacket(buffer,tcp_host);
+ WriteOpers("CONNECT from %s denied, no matching link block",servername);
+ RemoveServer(tcp_host);
+ RemoveServer(servername);
+ return;
+ }
+ else
+ if (token == 's') {
+ // S test.chatspike.net password :ChatSpike InspIRCd test server
+ char* servername = strtok(params," ");
+ char* password = strtok(NULL," ");
+ char* serverdesc = finalparam+2;
+
+ // TODO: we should do a check here to ensure that this server is one we recently initiated a
+ // link with, and didnt hear an 's' or 'E' back from yet (these are the only two valid responses
+ // 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);
+
+ char Link_ServerName[1024];
+ char Link_IPAddr[1024];
+ char Link_Port[1024];
+ char Link_Pass[1024];
+ char Link_SendPass[1024];
+ int LinkPort = 0;
+
+ // search for a corresponding <link> block in the config files
+ 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","recvpass",i,Link_Pass,&config_f);
+ ConfValue("link","sendpass",i,Link_SendPass,&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 (!strcasecmp(Link_ServerName,servername))
+ {
+ // matching link at this end too, we're all done!
+ // 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(),tcp_host))
+ {
+ char buffer[MAXBUF];
+ me[j]->connectors[k].SetDescription(serverdesc);
+ me[j]->connectors[k].SetState(STATE_CONNECTED);
+ sprintf(buffer,"X 0");
+ serv->SendPacket(buffer,tcp_host);
+ DoSync(me[j],tcp_host);
+ NetSendMyRoutingTable();
+ return;
+ }
+ }
+ }
+ WriteOpers("\2WARNING!\2 %s sent us an authentication packet but we are not authenticating with this server right noe! Possible intrusion attempt!",tcp_host);
+ return;
+ }
+ }
+ else {
+ log(DEBUG,"Server names '%s' and '%s' don't match",Link_ServerName,servername);
+ }
+ }
+ char buffer[MAXBUF];
+ sprintf(buffer,"E :Access is denied (no matching link block)");
+ serv->SendPacket(buffer,tcp_host);
+ WriteOpers("CONNECT from %s denied, no matching link block",servername);
+ RemoveServer(tcp_host);
+ RemoveServer(servername);
+ return;
+ }
+ else
+ if (token == 'E') {
+ char* error_message = finalparam+2;
+ WriteOpers("ERROR from %s: %s",tcp_host,error_message);
+ return;
+ }
+ else {
+
+ serverrec* source_server = NULL;
+
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int x = 0; x < me[j]->connectors.size(); x++)
+ {
+ log(DEBUG,"Servers are: '%s' '%s'",tcp_host,me[j]->connectors[x].GetServerName().c_str());
+ if (!strcasecmp(me[j]->connectors[x].GetServerName().c_str(),tcp_host))
+ {
+ if (me[j]->connectors[x].GetState() == STATE_CONNECTED)
+ {
+ // found a valid ircd_connector.
+ process_restricted_commands(token,params,me[j],serv,tcp_host,me[j]->connectors[x].GetServerIP(),me[j]->connectors[x].GetServerPort());
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ log(DEBUG,"Unrecognised token or unauthenticated host in datagram from %s: %c",tcp_host,token);
+ }
+}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index fe0b65e59..001f7e2d5 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2774,510 +2774,50 @@ void process_buffer(const char* cmdbuf,userrec *user)
}
}
-void DoSync(serverrec* serv, char* udp_host)
+void DoSync(serverrec* serv, char* tcp_host)
{
char data[MAXBUF];
// send start of sync marker: Y <timestamp>
// at this point the ircd receiving it starts broadcasting this netburst to all ircds
// except the ones its receiving it from.
snprintf(data,MAXBUF,"Y %d",time(NULL));
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
// send users and channels
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
snprintf(data,MAXBUF,"N %d %s %s %s %s +%s %s :%s",u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,u->second->server,u->second->fullname);
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
if (strcmp(chlist(u->second),""))
{
snprintf(data,MAXBUF,"J %s %s",u->second->nick,chlist(u->second));
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
}
}
// send channel modes, topics etc...
for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
{
snprintf(data,MAXBUF,"M %s +%s",c->second->name,chanmodes(c->second));
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
if (strcmp(c->second->topic,""))
{
snprintf(data,MAXBUF,"T %d %s %s :%s",c->second->topicset,c->second->setby,c->second->name,c->second->topic);
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
}
// send current banlist
for (BanList::iterator b = c->second->bans.begin(); b != c->second->bans.end(); b++)
{
snprintf(data,MAXBUF,"M %s +b %s",b->set_time,c->second->name,b->data);
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
}
}
// send end of sync marker: E <timestamp>
snprintf(data,MAXBUF,"F %d",time(NULL));
- serv->SendPacket(data,udp_host);
+ serv->SendPacket(data,tcp_host);
// ircd sends its serverlist after the end of sync here
}
-void handle_V(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* src = strtok(params," ");
- char* dest = strtok(NULL," :");
- char* text = strtok(NULL,"\r\n");
- text++;
-
- userrec* user = Find(src);
- if (user)
- {
- userrec* dst = Find(dest);
-
- if (dst)
- {
- WriteTo(user, dst, "NOTICE %s :%s", dst->nick, text);
- }
- else
- {
- chanrec* d = FindChan(dest);
- if (d)
- {
- ChanExceptSender(d, user, "NOTICE %s :%s", d->name, text);
- }
- }
- }
-
-}
-
-
-void handle_P(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* src = strtok(params," ");
- char* dest = strtok(NULL," :");
- char* text = strtok(NULL,"\r\n");
- text++;
-
- userrec* user = Find(src);
- if (user)
- {
- userrec* dst = Find(dest);
-
- if (dst)
- {
- WriteTo(user, dst, "PRIVMSG %s :%s", dst->nick, text);
- }
- else
- {
- chanrec* d = FindChan(dest);
- if (d)
- {
- ChanExceptSender(d, user, "PRIVMSG %s :%s", d->name, text);
- }
- }
- }
-
-}
-
-void handle_i(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* nick = strtok(params," ");
- char* from = strtok(NULL," ");
- char* channel = strtok(NULL," ");
- userrec* u = Find(nick);
- userrec* user = Find(from);
- chanrec* c = FindChan(channel);
- if ((c) && (u) && (user))
- {
- u->InviteTo(c->name);
- WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
- }
-}
-
-void handle_t(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* setby = strtok(params," ");
- char* channel = strtok(NULL," :");
- char* topic = strtok(NULL,"\r\n");
- topic++;
- userrec* u = Find(setby);
- chanrec* c = FindChan(channel);
- if ((c) && (u))
- {
- WriteChannelLocal(c,u,"TOPIC %s :%s",c->name,topic);
- strncpy(c->topic,topic,MAXTOPIC);
- strncpy(c->setby,u->nick,NICKMAX);
- }
-}
-
-
-void handle_T(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* tm = strtok(params," ");
- char* setby = strtok(NULL," ");
- char* channel = strtok(NULL," :");
- char* topic = strtok(NULL,"\r\n");
- topic++;
- time_t TS = atoi(tm);
- chanrec* c = FindChan(channel);
- if (c)
- {
- // in the case of topics and TS, the *NEWER*
- if (TS <= c->topicset)
- {
- WriteChannelLocal(c,NULL,"TOPIC %s :%s",c->name,topic);
- strncpy(c->topic,topic,MAXTOPIC);
- strncpy(c->setby,setby,NICKMAX);
- }
- }
-}
-
-void handle_M(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* pars[128];
- char original[MAXBUF],target[MAXBUF];
- strncpy(original,params,MAXBUF);
- int index = 0;
- char* parameter = strtok(params," ");
- strncpy(target,parameter,MAXBUF);
- while (parameter)
- {
- pars[index++] = parameter;
- parameter = strtok(NULL," ");
- }
- merge_mode(pars,index);
- if (FindChan(target))
- {
- WriteChannelLocal(FindChan(target), NULL, "MODE %s",original);
- }
- if (Find(target))
- {
- WriteTo(NULL,Find(target),"MODE %s",original);
- }
-}
-
-// m is modes set by users only (not servers) valid targets are channels or users.
-
-void handle_m(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- // m blah #chatspike +b *!test@*4
- char* pars[128];
- char original[MAXBUF];
- strncpy(original,params,MAXBUF);
-
- if (!strchr(params,' '))
- {
- WriteOpers("WARNING! 'm' token in data stream without any parameters! Something fishy is going on!");
- return;
- }
-
- int index = 0;
-
- char* src = strtok(params," ");
- userrec* user = Find(src);
-
- if (user)
- {
- log(DEBUG,"Found user: %s",user->nick);
- char* parameter = strtok(NULL," ");
- while (parameter)
- {
- pars[index++] = parameter;
- parameter = strtok(NULL," ");
- }
-
- log(DEBUG,"Calling merge_mode2");
- merge_mode2(pars,index,user);
- }
-}
-
-
-void handle_L(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* nick = strtok(params," ");
- char* channel = strtok(NULL," :");
- char* reason = strtok(NULL,"\r\n");
- userrec* user = Find(nick);
- reason++;
- if (user)
- {
- if (strcmp(reason,""))
- {
- del_channel(user,channel,reason,true);
- }
- else
- {
- del_channel(user,channel,NULL,true);
- }
- }
-}
-
-void handle_K(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* src = strtok(params," ");
- char* nick = strtok(NULL," :");
- char* reason = strtok(NULL,"\r\n");
- char kreason[MAXBUF];
- 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(kreason,MAXBUF,"[%s] Killed (%s (%s))",source->name,user->nick,reason);
- kill_link(u,kreason);
- }
-}
-
-void handle_Q(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* nick = strtok(params," :");
- char* reason = strtok(NULL,"\r\n");
- reason++;
-
- userrec* user = Find(nick);
-
- if (user)
- {
- if (strlen(reason)>MAXQUIT)
- {
- reason[MAXQUIT-1] = '\0';
- }
-
-
- WriteCommonExcept(user,"QUIT :%s",reason);
-
- user_hash::iterator iter = clientlist.find(user->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();
- }
-}
-
-void handle_n(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* oldnick = strtok(params," ");
- char* newnick = strtok(NULL," ");
-
- userrec* user = Find(oldnick);
-
- if (user)
- {
- WriteCommon(user,"NICK %s",newnick);
- user = ReHashNick(user->nick, newnick);
- if (!user) return;
- if (!user->nick) return;
- strncpy(user->nick, newnick,NICKMAX);
- log(DEBUG,"new nick set: %s",user->nick);
- }
-}
-
-// k <SOURCE> <DEST> <CHANNEL> :<REASON>
-void handle_k(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* src = strtok(params," ");
- char* dest = strtok(NULL," ");
- char* channel = strtok(NULL," :");
- char* reason = strtok(NULL,"\r\n");
- reason++;
- userrec* s = Find(src);
- userrec* d = Find(dest);
- chanrec* c = FindChan(channel);
- if ((s) && (d) && (c))
- {
- kick_channel(s,d,c,reason);
- }
-}
-
-void handle_AT(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* who = strtok(params," :");
- char* text = strtok(NULL,"\r\n");
- text++;
- userrec* s = Find(who);
- if (s)
- {
- WriteWallOps(s,true,text);
- }
-}
-
-
-void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* tm = strtok(params," ");
- char* nick = strtok(NULL," ");
- char* host = strtok(NULL," ");
- char* dhost = strtok(NULL," ");
- char* ident = strtok(NULL," ");
- char* modes = strtok(NULL," ");
- char* server = strtok(NULL," :");
- char* gecos = strtok(NULL,"\r\n");
- gecos++;
- modes++;
- time_t TS = atoi(tm);
- user_hash::iterator iter = clientlist.find(nick);
- if (iter != clientlist.end())
- {
- // nick collision
- WriteOpers("Nickname collision: %s@%s != %s@%s",nick,server,iter->second->nick,iter->second->server);
- char str[MAXBUF];
- snprintf(str,MAXBUF,"Killed (Nick Collision (%s@%s < %s@%s))",nick,server,iter->second->nick,iter->second->server);
- WriteServ(iter->second->fd, "KILL %s :%s",iter->second->nick,str);
- kill_link(iter->second,str);
- }
- clientlist[nick] = new userrec();
- // remote users have an fd of -1. This is so that our Write abstraction
- // routines know to route any messages to this record away to whatever server
- // theyre on.
- clientlist[nick]->fd = -1;
- strncpy(clientlist[nick]->nick, nick,NICKMAX);
- strncpy(clientlist[nick]->host, host,160);
- strncpy(clientlist[nick]->dhost, dhost,160);
- strncpy(clientlist[nick]->server, server,256);
- strncpy(clientlist[nick]->ident, ident,10); // +1 char to compensate for tilde
- strncpy(clientlist[nick]->fullname, gecos,128);
- clientlist[nick]->signon = TS;
- clientlist[nick]->nping = 0; // this is ignored for a remote user anyway.
- clientlist[nick]->lastping = 1;
- clientlist[nick]->port = 0; // so is this...
- clientlist[nick]->registered = 7; // this however we need to set for them to receive messages and appear online
- clientlist[nick]->idle_lastmsg = time(NULL); // this is unrealiable and wont actually be used locally
- for (int i = 0; i < MAXCHANS; i++)
- {
- clientlist[nick]->chans[i].channel = NULL;
- clientlist[nick]->chans[i].uc_modes = 0;
- }
-}
-
-void handle_F(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- long tdiff = time(NULL) - atoi(params);
- if (tdiff)
- WriteOpers("TS split for %s -> %s: %d",source->name,reply->name,tdiff);
-}
-
-void handle_a(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* nick = strtok(params," :");
- char* gecos = strtok(NULL,"\r\n");
-
- userrec* user = Find(nick);
-
- if (user)
- strncpy(user->fullname,gecos,MAXBUF);
-}
-
-void handle_b(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* nick = strtok(params," ");
- char* host = strtok(NULL," ");
-
- userrec* user = Find(nick);
-
- if (user)
- strncpy(user->dhost,host,160);
-}
-
-void handle_plus(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- // %s %s %d %d
- // + test3.chatspike.net 7010 -2016508415
- char* servername = strtok(params," ");
- char* ipaddr = strtok(NULL," ");
- char* ipport = strtok(NULL," ");
- char* cookie = strtok(NULL," ");
- log(DEBUG,"*** Connecting back to %s:%d",ipaddr,atoi(ipport));
-
-
- bool conn_already = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (int j = 0; j < me[i]->connectors.size(); j++)
- {
- if (!strcasecmp(me[i]->connectors[j].GetServerName().c_str(),servername))
- {
- if (me[i]->connectors[j].GetServerPort() == atoi(ipport))
- {
- log(DEBUG,"Already got a connection to %s:%d, ignoring +",ipaddr,atoi(ipport));
- conn_already = true;
- }
- }
- }
- }
- }
- if (!conn_already)
- me[defaultRoute]->MeshCookie(ipaddr,atoi(ipport),atoi(cookie),servername);
-}
-
-void handle_R(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- char* server = strtok(params," ");
- char* data = strtok(NULL,"\r\n");
- log(DEBUG,"Forwarded packet '%s' to '%s'",data,server);
- NetSendToOne(server,data);
-}
-
-void handle_J(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- // IMPORTANT NOTE
- // The J token currently has no timestamp - this needs looking at
- // because it will allow splitriding.
- char* nick = strtok(params," ");
- char* channel = strtok(NULL," ");
- userrec* user = Find(nick);
- while (channel)
- {
- if ((user != NULL) && (strcmp(channel,"")))
- {
- char privilage = '\0';
- if (channel[0] != '#')
- {
- privilage = channel[0];
- channel++;
- }
- add_channel(user,channel,"",true);
-
- // now work out the privilages they should have on each channel
- // and send the appropriate servermodes.
- for (int i = 0; i != MAXCHANS; i++)
- {
- if (user->chans[i].channel)
- {
- if (!strcasecmp(user->chans[i].channel->name,channel))
- {
- if (privilage == '@')
- {
- user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_OP;
- WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +o %s",channel,user->nick);
- }
- if (privilage == '%')
- {
- user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_HOP;
- WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +h %s",channel,user->nick);
- }
- if (privilage == '+')
- {
- user->chans[i].uc_modes = user->chans[i].uc_modes | UCMODE_VOICE;
- WriteChannelLocal(user->chans[i].channel, NULL, "MODE %s +v %s",channel,user->nick);
- }
- }
- }
- }
-
- }
- channel = strtok(NULL," ");
- }
-}
-
void NetSendMyRoutingTable()
{
// send out a line saying what is reachable to us.
@@ -3308,36 +2848,6 @@ void NetSendMyRoutingTable()
NetSendToAll(buffer);
}
-void handle_dollar(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- log(DEBUG,"Storing routing table...");
- char* sourceserver = strtok(params," ");
- char* server = strtok(NULL," ");
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (int j = 0; j < me[i]->connectors.size(); j++)
- {
- if (!strcasecmp(me[i]->connectors[j].GetServerName().c_str(),sourceserver))
- {
- me[i]->connectors[j].routes.clear();
- log(DEBUG,"Found entry for source server.");
- while (server)
- {
- // store each route
- me[i]->connectors[j].routes.push_back(server);
- log(DEBUG,"*** Stored route: %s -> %s -> %s",ServerName,sourceserver,server);
- server = strtok(NULL," ");
- }
- return;
- }
- }
- }
- }
- log(DEBUG,"Warning! routing table received from nonexistent server!");
-}
-
void DoSplit(const char* params)
{
@@ -3413,472 +2923,6 @@ void RemoveServer(const char* name)
}
}
-void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
-{
- log(DEBUG,"Netsplit! %s split from mesh, removing!",params);
- bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (int i = 0; i < 32; i++)
- {
- if (me[i] != NULL)
- {
- for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
- {
- if (!strcasecmp(j->GetServerName().c_str(),params))
- {
- j->routes.clear();
- j->CloseConnection();
- me[i]->connectors.erase(j);
- go_again = true;
- break;
- }
- }
- }
- }
- }
- log(DEBUG,"Removed server. Will remove clients...");
- // iterate through the userlist and remove all users on this server.
- // because we're dealing with a mesh, we dont have to deal with anything
- // "down-route" from this server (nice huh)
- go_again = true;
- char reason[MAXBUF];
- snprintf(reason,MAXBUF,"%s %s",ServerName,params);
- while (go_again)
- {
- go_again = false;
- for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
- {
- if (!strcasecmp(u->second->server,params))
- {
- kill_link(u->second,reason);
- go_again = true;
- break;
- }
- }
- }
-}
-
-long authcookie;
-
-
-void process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,char* ipaddr,int port)
-{
- char buffer[MAXBUF];
-
- switch(token)
- {
- // Y <TS>
- // start netburst
- case 'Y':
- nb_start = time(NULL);
- WriteOpers("Server %s is starting netburst.",udp_host);
- // now broadcast this new servers address out to all servers that are linked to us,
- // except the newcomer. They'll all attempt to connect back to it.
- authcookie = rand()*rand();
- snprintf(buffer,MAXBUF,"~ %d",authcookie);
- NetSendToAll(buffer);
- break;
- // ~
- // Store authcookie
- // once stored, this authcookie permits other servers to log in
- // without user or password, using it.
- case '~':
- auth_cookies.push_back(atoi(params));
- log(DEBUG,"*** Stored auth cookie, will permit servers with auth-cookie %d",atoi(params));
- break;
- // connect back to a server using an authcookie
- case '+':
- handle_plus(token,params,source,reply,udp_host);
- break;
- // routing table
- case '$':
- handle_dollar(token,params,source,reply,udp_host);
- break;
- // node unreachable - we cant route to a server, sooooo we slit it off.
- // servers can generate these for themselves for an squit.
- case '&':
- handle_amp(token,params,source,reply,udp_host);
- break;
- // R <server> <data>
- // redirect token, send all of <data> along to the given
- // server as this server has been found to still have a route to it
- case 'R':
- handle_R(token,params,source,reply,udp_host);
- break;
- // ?
- // ping
- case '?':
- reply->SendPacket("!",udp_host);
- break;
- // ?
- // pong
- case '!':
- break;
- // *
- // no operation
- case '*':
- break;
- // N <TS> <NICK> <HOST> <DHOST> <IDENT> <MODES> <SERVER> :<GECOS>
- // introduce remote client
- case 'N':
- handle_N(token,params,source,reply,udp_host);
- break;
- // a <NICK> :<GECOS>
- // change GECOS (SETNAME)
- case 'a':
- handle_a(token,params,source,reply,udp_host);
- break;
- // b <NICK> :<HOST>
- // change displayed host (SETHOST)
- case 'b':
- handle_b(token,params,source,reply,udp_host);
- break;
- // t <NICK> <CHANNEL> :<TOPIC>
- // change a channel topic
- case 't':
- handle_t(token,params,source,reply,udp_host);
- break;
- // i <NICK> <CHANNEL>
- // invite a user to a channel
- case 'i':
- handle_i(token,params,source,reply,udp_host);
- break;
- // k <SOURCE> <DEST> <CHANNEL> :<REASON>
- // kick a user from a channel
- case 'k':
- handle_k(token,params,source,reply,udp_host);
- break;
- // n <NICK> <NEWNICK>
- // change nickname of client -- a server should only be able to
- // change the nicknames of clients that reside on it unless
- // they are ulined.
- case 'n':
- handle_n(token,params,source,reply,udp_host);
- break;
- // J <NICK> <CHANLIST>
- // Join user to channel list, merge channel permissions
- case 'J':
- handle_J(token,params,source,reply,udp_host);
- break;
- // T <TS> <CHANNEL> <TOPICSETTER> :<TOPIC>
- // change channel topic (netburst only)
- case 'T':
- handle_T(token,params,source,reply,udp_host);
- break;
- // M <TARGET> <MODES> [MODE-PARAMETERS]
- // Server setting modes on an object
- case 'M':
- handle_M(token,params,source,reply,udp_host);
- break;
- // m <SOURCE> <TARGET> <MODES> [MODE-PARAMETERS]
- // User setting modes on an object
- case 'm':
- handle_m(token,params,source,reply,udp_host);
- break;
- // P <SOURCE> <TARGET> :<TEXT>
- // Send a private/channel message
- case 'P':
- handle_P(token,params,source,reply,udp_host);
- break;
- // V <SOURCE> <TARGET> :<TEXT>
- // Send a private/channel notice
- case 'V':
- handle_V(token,params,source,reply,udp_host);
- break;
- // L <SOURCE> <CHANNEL> :<REASON>
- // User parting a channel
- case 'L':
- handle_L(token,params,source,reply,udp_host);
- break;
- // Q <SOURCE> :<REASON>
- // user quitting
- case 'Q':
- handle_Q(token,params,source,reply,udp_host);
- break;
- // K <SOURCE> <DEST> :<REASON>
- // remote kill
- case 'K':
- handle_K(token,params,source,reply,udp_host);
- break;
- // @ <SOURCE> :<TEXT>
- // wallops
- case '@':
- handle_AT(token,params,source,reply,udp_host);
- break;
- // F <TS>
- // end netburst
- case 'F':
- WriteOpers("Server %s has completed netburst. (%d secs)",udp_host,time(NULL)-nb_start);
- handle_F(token,params,source,reply,udp_host);
- nb_start = 0;
- // tell all the other servers to use this authcookie to connect back again
- // got '+ test3.chatspike.net 7010 -2016508415' from test.chatspike.net
- snprintf(buffer,MAXBUF,"+ %s %s %d %d",udp_host,ipaddr,port,authcookie);
- NetSendToAllExcept(udp_host,buffer);
- break;
- // X <reserved>
- // Send netburst now
- case 'X':
- WriteOpers("Sending my netburst to %s",udp_host);
- DoSync(source,udp_host);
- WriteOpers("Send of netburst to %s completed",udp_host);
- NetSendMyRoutingTable();
- break;
- // anything else
- default:
- WriteOpers("WARNING! Unknown datagram type '%c'",token);
- break;
- }
-}
-
-
-void handle_link_packet(char* udp_msg, char* udp_host, serverrec *serv)
-{
- char response[10240];
- char token = udp_msg[0];
- char* params = udp_msg + 2;
- char finalparam[1024];
- strcpy(finalparam," :xxxx");
- if (strstr(udp_msg," :")) {
- strncpy(finalparam,strstr(udp_msg," :"),1024);
- }
- if (token == '-') {
- char* cookie = strtok(params," ");
- char* servername = strtok(NULL," ");
- char* serverdesc = finalparam+2;
-
- WriteOpers("AuthCookie CONNECT from %s (%s)",servername,udp_host);
-
- for (int u = 0; u < auth_cookies.size(); u++)
- {
- if (auth_cookies[u] == atoi(cookie))
- {
- WriteOpers("Allowed cookie from %s, is now part of the mesh",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(),udp_host))
- {
- me[j]->connectors[k].SetServerName(servername);
- me[j]->connectors[k].SetDescription(serverdesc);
- me[j]->connectors[k].SetState(STATE_CONNECTED);
- NetSendMyRoutingTable();
- return;
- }
- }
- }
- WriteOpers("\2WARNING!\2 %s sent us an authentication packet but we are not authenticating with this server right now! Possible intrusion attempt!",udp_host);
- return;
- }
-
-
- return;
- }
- }
- // bad cookie, bad bad! go sit in the corner!
- WriteOpers("Bad cookie from %s!",servername);
- return;
- }
- else
- if (token == 'S') {
- // S test.chatspike.net password portn :ChatSpike InspIRCd test server
- char* servername = strtok(params," ");
- char* password = strtok(NULL," ");
- char* myport = strtok(NULL," ");
- char* revision = strtok(NULL," ");
- char* serverdesc = finalparam+2;
-
- WriteOpers("CONNECT from %s (%s) (their port: %d)",servername,udp_host,atoi(myport));
-
- ircd_connector* cn = serv->FindHost(servername);
-
- if (cn)
- {
- WriteOpers("CONNECT aborted: Server %s already exists from %s",servername,ServerName);
- char buffer[MAXBUF];
- sprintf(buffer,"E :Server %s already exists!",servername);
- serv->SendPacket(buffer,udp_host);
- RemoveServer(udp_host);
- return;
- }
-
- if (atoi(revision) != GetRevision())
- {
- WriteOpers("CONNECT aborted: Could not link to %s, is an incompatible version %s, our version is %d",servername,revision,GetRevision());
- char buffer[MAXBUF];
- sprintf(buffer,"E :Version number mismatch");
- serv->SendPacket(buffer,udp_host);
- RemoveServer(udp_host);
- RemoveServer(servername);
- return;
- }
-
- for (int j = 0; j < serv->connectors.size(); j++)
- {
- 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));
- }
- }
-
-
- char Link_ServerName[1024];
- char Link_IPAddr[1024];
- char Link_Port[1024];
- char Link_Pass[1024];
- char Link_SendPass[1024];
- int LinkPort = 0;
-
- // search for a corresponding <link> block in the config files
- 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","recvpass",i,Link_Pass,&config_f);
- ConfValue("link","sendpass",i,Link_SendPass,&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 (!strcasecmp(Link_ServerName,servername))
- {
- // we have a matching link line -
- // 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;
- }
- }
- char buffer[MAXBUF];
- sprintf(buffer,"E :Access is denied (no matching link block)");
- serv->SendPacket(buffer,udp_host);
- WriteOpers("CONNECT from %s denied, no matching link block",servername);
- RemoveServer(udp_host);
- RemoveServer(servername);
- return;
- }
- else
- if (token == 's') {
- // S test.chatspike.net password :ChatSpike InspIRCd test server
- char* servername = strtok(params," ");
- char* password = strtok(NULL," ");
- char* serverdesc = finalparam+2;
-
- // TODO: we should do a check here to ensure that this server is one we recently initiated a
- // link with, and didnt hear an 's' or 'E' back from yet (these are the only two valid responses
- // 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);
-
- char Link_ServerName[1024];
- char Link_IPAddr[1024];
- char Link_Port[1024];
- char Link_Pass[1024];
- char Link_SendPass[1024];
- int LinkPort = 0;
-
- // search for a corresponding <link> block in the config files
- 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","recvpass",i,Link_Pass,&config_f);
- ConfValue("link","sendpass",i,Link_SendPass,&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 (!strcasecmp(Link_ServerName,servername))
- {
- // matching link at this end too, we're all done!
- // 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);
- NetSendMyRoutingTable();
- return;
- }
- }
- }
- WriteOpers("\2WARNING!\2 %s sent us an authentication packet but we are not authenticating with this server right noe! Possible intrusion attempt!",udp_host);
- return;
- }
- }
- else {
- log(DEBUG,"Server names '%s' and '%s' don't match",Link_ServerName,servername);
- }
- }
- char buffer[MAXBUF];
- sprintf(buffer,"E :Access is denied (no matching link block)");
- serv->SendPacket(buffer,udp_host);
- WriteOpers("CONNECT from %s denied, no matching link block",servername);
- RemoveServer(udp_host);
- RemoveServer(servername);
- return;
- }
- else
- if (token == 'E') {
- char* error_message = finalparam+2;
- WriteOpers("ERROR from %s: %s",udp_host,error_message);
- return;
- }
- else {
-
- serverrec* source_server = NULL;
-
- for (int j = 0; j < 32; j++)
- {
- if (me[j] != NULL)
- {
- for (int x = 0; x < me[j]->connectors.size(); x++)
- {
- 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))
- {
- 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;
- }
- }
- }
- }
- }
-
- log(DEBUG,"Unrecognised token or unauthenticated host in datagram from %s: %c",udp_host,token);
- }
-}
int reap_counter = 0;
@@ -4057,7 +3101,7 @@ int InspIRCd(void)
length = sizeof (client);
- char udp_msg[MAXBUF], udp_host[MAXBUF];
+ char udp_msg[MAXBUF], tcp_host[MAXBUF];
/* main loop, this never returns */
for (;;)
@@ -4128,7 +3172,7 @@ int InspIRCd(void)
{
std::deque<std::string> msgs;
msgs.clear();
- if (me[x]->RecvPacket(msgs, udp_host))
+ if (me[x]->RecvPacket(msgs, tcp_host))
{
for (int ctr = 0; ctr < msgs.size(); ctr++)
{
@@ -4136,16 +3180,16 @@ int InspIRCd(void)
strncpy(udp_msg,msgs[ctr].c_str(),MAXBUF);
if (strlen(udp_msg)<1)
{
- log(DEBUG,"Invalid string from %s [route%d]",udp_host,x);
+ log(DEBUG,"Invalid string from %s [route%d]",tcp_host,x);
break;
}
// during a netburst, send all data to all other linked servers
if ((nb_start>0) && (udp_msg[0] != 'Y') && (udp_msg[0] != 'X') && (udp_msg[0] != 'F'))
{
- NetSendToAllExcept(udp_host,udp_msg);
+ NetSendToAllExcept(tcp_host,udp_msg);
}
FOREACH_MOD OnPacketReceive(udp_msg);
- handle_link_packet(udp_msg, udp_host, me[x]);
+ handle_link_packet(udp_msg, tcp_host, me[x]);
}
goto label;
}