diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-08 00:52:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-08 00:52:03 +0000 |
commit | a81394b65dc366a9650fe05edf1c0f18d0ac700a (patch) | |
tree | 7fa3844d14ce8c1a3595687a1859aa5b660b38f5 | |
parent | 50ef6d1e9825230b99bfb42a7f9d4826bc61d8e7 (diff) |
Changed the final bunch of udp_* vars to server_*/tcp_*
Fixed ircservices sending PING
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1326 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/commands.h | 2 | ||||
-rw-r--r-- | src/channels.cpp | 2 | ||||
-rw-r--r-- | src/commands.cpp | 108 | ||||
-rw-r--r-- | src/inspircd.cpp | 34 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/xline.cpp | 2 |
6 files changed, 78 insertions, 72 deletions
diff --git a/include/commands.h b/include/commands.h index 076db91ae..2777de1a2 100644 --- a/include/commands.h +++ b/include/commands.h @@ -84,7 +84,7 @@ void handle_unloadmodule(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 handle_link_packet(char* tcp_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) diff --git a/src/channels.cpp b/src/channels.cpp index fcc1c732d..0a6cdfdbb 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -93,7 +93,7 @@ extern std::vector<std::string> module_names; extern int boundPortCount; extern int portCount; -extern int UDPportCount; +extern int SERVERportCount; extern int ports[MAXSOCKS]; extern int defaultRoute; diff --git a/src/commands.cpp b/src/commands.cpp index fb8b3072a..b8e312688 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -105,7 +105,7 @@ extern std::vector<std::string> module_names; extern char MyExecutable[1024]; extern int boundPortCount; extern int portCount; -extern int UDPportCount; +extern int SERVERportCount; extern int ports[MAXSOCKS]; extern int defaultRoute; @@ -3083,9 +3083,9 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve } -void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) +void handle_link_packet(char* tcp_msg, char* tcp_host, serverrec *serv) { - if ((!strncmp(udp_msg,"USER ",5)) || (!strncmp(udp_msg,"NICK ",5)) || (!strncmp(udp_msg,"PASS ",5)) || (!strncmp(udp_msg,"SERVER ",7))) + if ((!strncmp(tcp_msg,"USER ",5)) || (!strncmp(tcp_msg,"NICK ",5)) || (!strncmp(tcp_msg,"PASS ",5)) || (!strncmp(tcp_msg,"SERVER ",7))) { // a user on a server port, just close their connection. RemoveServer(tcp_host); @@ -3093,33 +3093,39 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) } char response[10240]; - char token = udp_msg[0]; - char* old = udp_msg; + char token = tcp_msg[0]; + char* old = tcp_msg; - if ((token != ':') && (strlen(udp_msg)>1) && (udp_msg[1] != ' ')) + if (!strncmp(tcp_msg,"PING",4)) { - WriteOpers("*** Discarded %d chars illegal data from %s",strlen(udp_msg),tcp_host); + // some muppet of a server is sending PING. We don't know what PING is. drop it silently. + return; + } + + if ((token != ':') && (strlen(tcp_msg)>1) && (tcp_msg[1] != ' ')) + { + WriteOpers("*** Discarded %d chars illegal data from %s",strlen(tcp_msg),tcp_host); } if (token == ':') // leading :servername or details - strip them off (services does this, sucky) { - char* src = udp_msg+1; - while (udp_msg[0] != ' ') - udp_msg++; - udp_msg[0] = 0; - udp_msg++; - char* comd = udp_msg; - while (udp_msg[0] != ' ') - udp_msg++; - udp_msg[0] = 0; - udp_msg++; + char* src = tcp_msg+1; + while (tcp_msg[0] != ' ') + tcp_msg++; + tcp_msg[0] = 0; + tcp_msg++; + char* comd = tcp_msg; + while (tcp_msg[0] != ' ') + tcp_msg++; + tcp_msg[0] = 0; + tcp_msg++; char data[MAXBUF]; char source[MAXBUF]; char command[MAXBUF]; - strlcpy(data,udp_msg,512); + strlcpy(data,tcp_msg,512); strlcpy(source,src,MAXBUF); strlcpy(command,comd,MAXBUF); - udp_msg = old; + tcp_msg = old; // unused numeric: // :services-dev.chatspike.net 433 Craig Craig :Nickname is registered to someone else @@ -3137,13 +3143,13 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) } if (!strcmp(command,"NOTICE")) { - snprintf(udp_msg,MAXBUF,"V %s %s",source,data); - log(DEBUG,"Rewrote NOTICE from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"V %s %s",source,data); + log(DEBUG,"Rewrote NOTICE from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"QUIT")) { - if ((!udp_msg) || (!strcmp(data,"")) || (strcmp(data,":"))) + if ((!tcp_msg) || (!strcmp(data,"")) || (strcmp(data,":"))) { strcpy(data,":No reason"); } @@ -3151,70 +3157,70 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) { strcpy(data,":No reason"); } - snprintf(udp_msg,MAXBUF,"Q %s %s",source,data); - log(DEBUG,"Rewrote QUIT from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"Q %s %s",source,data); + log(DEBUG,"Rewrote QUIT from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"SQUIT")) { - snprintf(udp_msg,MAXBUF,"& %s",source); - log(DEBUG,"Rewrote SQUIT from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"& %s",source); + log(DEBUG,"Rewrote SQUIT from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"SVSMODE")) { - snprintf(udp_msg,MAXBUF,"m %s %s",source,data); - log(DEBUG,"Rewrote SVSMODE from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"m %s %s",source,data); + log(DEBUG,"Rewrote SVSMODE from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"SVS2MODE")) { - snprintf(udp_msg,MAXBUF,"m %s %s",source,data); - log(DEBUG,"Rewrote SVS2MODE from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"m %s %s",source,data); + log(DEBUG,"Rewrote SVS2MODE from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } // todo: this wont work without u:lines // in give_ops etc allow nick on a u:lined serv to do just about anything if (!strcmp(command,"MODE")) { - snprintf(udp_msg,MAXBUF,"m %s %s",source,data); - log(DEBUG,"Rewrote MODE from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"m %s %s",source,data); + log(DEBUG,"Rewrote MODE from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"KICK")) { - snprintf(udp_msg,MAXBUF,"k %s %s",source,data); - log(DEBUG,"Rewrote KICK from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"k %s %s",source,data); + log(DEBUG,"Rewrote KICK from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"KILL")) { - snprintf(udp_msg,MAXBUF,"K %s %s",source,data); - log(DEBUG,"Rewrote KILL from services to: '%s'",udp_msg); - token = udp_msg[0]; + snprintf(tcp_msg,MAXBUF,"K %s %s",source,data); + log(DEBUG,"Rewrote KILL from services to: '%s'",tcp_msg); + token = tcp_msg[0]; } if (!strcmp(command,"SVSJOIN")) { - snprintf(udp_msg,MAXBUF,"J %s",data); - NetSendToOne(tcp_host,udp_msg); + snprintf(tcp_msg,MAXBUF,"J %s",data); + NetSendToOne(tcp_host,tcp_msg); char* nick = strtok(data," "); char* chan = strtok(NULL," "); - log(DEBUG,"Rewrote SVSJOIN from services to: '%s'",udp_msg); + log(DEBUG,"Rewrote SVSJOIN from services to: '%s'",tcp_msg); userrec* u = Find(nick); if (u) { add_channel(u,chan,"",true); } - token = udp_msg[0]; + token = tcp_msg[0]; } } - char* params = udp_msg + 2; + char* params = tcp_msg + 2; char finalparam[1024]; strcpy(finalparam," :xxxx"); - if (strstr(udp_msg," :")) { - strlcpy(finalparam,strstr(udp_msg," :"),1024); + if (strstr(tcp_msg," :")) { + strlcpy(finalparam,strstr(tcp_msg," :"),1024); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index af965cf26..e31628305 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -200,7 +200,7 @@ ClassVector Classes; struct linger linger = { 0 }; char MyExecutable[1024]; int boundPortCount = 0; -int portCount = 0, UDPportCount = 0, ports[MAXSOCKS]; +int portCount = 0, SERVERportCount = 0, ports[MAXSOCKS]; int defaultRoute = 0; char ModPath[MAXBUF]; @@ -3956,9 +3956,9 @@ int InspIRCd(char** argv, int argc) log(DEBUG,"InspIRCd: startup: read binding %s:%s [%s] from config",Addr,configToken, Type); } portCount = clientportcount; - UDPportCount = serverportcount; + SERVERportCount = serverportcount; - log(DEBUG,"InspIRCd: startup: read %lu total client ports and %lu total server ports",(unsigned long)portCount,(unsigned long)UDPportCount); + log(DEBUG,"InspIRCd: startup: read %lu total client ports and %lu total server ports",(unsigned long)portCount,(unsigned long)SERVERportCount); log(DEBUG,"InspIRCd: startup: InspIRCd is now starting!"); printf("\n"); @@ -4037,7 +4037,7 @@ int InspIRCd(char** argv, int argc) WritePID(PID); length = sizeof (client); - char udp_msg[MAXBUF],tcp_host[MAXBUF]; + char tcp_msg[MAXBUF],tcp_host[MAXBUF]; fd_set serverfds; timeval tvs; @@ -4084,7 +4084,7 @@ int InspIRCd(char** argv, int argc) FD_ZERO(&serverfds); - for (int x = 0; x != UDPportCount; x++) + for (int x = 0; x != SERVERportCount; x++) { if (me[x]) FD_SET(me[x]->fd, &serverfds); @@ -4097,7 +4097,7 @@ int InspIRCd(char** argv, int argc) int servresult = select(32767, &serverfds, NULL, NULL, &tvs); if (servresult > 0) { - for (int x = 0; x != UDPportCount; x++) + for (int x = 0; x != SERVERportCount; x++) { if ((me[x]) && (FD_ISSET (me[x]->fd, &serverfds))) { @@ -4119,7 +4119,7 @@ int InspIRCd(char** argv, int argc) } } - for (int x = 0; x < UDPportCount; x++) + for (int x = 0; x < SERVERportCount; x++) { std::deque<std::string> msgs; msgs.clear(); @@ -4127,30 +4127,30 @@ int InspIRCd(char** argv, int argc) { for (int ctr = 0; ctr < msgs.size(); ctr++) { - strlcpy(udp_msg,msgs[ctr].c_str(),MAXBUF); - log(DEBUG,"Processing: %s",udp_msg); - if (!udp_msg[0]) + strlcpy(tcp_msg,msgs[ctr].c_str(),MAXBUF); + log(DEBUG,"Processing: %s",tcp_msg); + if (!tcp_msg[0]) { log(DEBUG,"Invalid string from %s [route%lu]",tcp_host,(unsigned long)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'))) || (is_uline(tcp_host))) + if ((((nb_start>0) && (tcp_msg[0] != 'Y') && (tcp_msg[0] != 'X') && (tcp_msg[0] != 'F'))) || (is_uline(tcp_host))) { if (is_uline(tcp_host)) { - if ((udp_msg[0] != 'Y') && (udp_msg[0] != 'X') && (udp_msg[0] != 'F')) + if ((tcp_msg[0] != 'Y') && (tcp_msg[0] != 'X') && (tcp_msg[0] != 'F')) { - NetSendToAllExcept(tcp_host,udp_msg); + NetSendToAllExcept(tcp_host,tcp_msg); } } else - NetSendToAllExcept(tcp_host,udp_msg); + NetSendToAllExcept(tcp_host,tcp_msg); } - std::string msg = udp_msg; + std::string msg = tcp_msg; FOREACH_MOD OnPacketReceive(msg,tcp_host); - strlcpy(udp_msg,msg.c_str(),MAXBUF); - handle_link_packet(udp_msg, tcp_host, me[x]); + strlcpy(tcp_msg,msg.c_str(),MAXBUF); + handle_link_packet(tcp_msg, tcp_host, me[x]); } goto label; } diff --git a/src/modules.cpp b/src/modules.cpp index ec870cb5d..495181cf4 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -96,7 +96,7 @@ extern std::vector<std::string> module_names; extern int boundPortCount; extern int portCount; -extern int UDPportCount; +extern int SERVERportCount; extern int ports[MAXSOCKS]; extern int defaultRoute; diff --git a/src/xline.cpp b/src/xline.cpp index 7452d81f0..921d96045 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -93,7 +93,7 @@ extern std::vector<std::string> module_names; extern int boundPortCount; extern int portCount; -extern int UDPportCount; +extern int SERVERportCount; extern int ports[MAXSOCKS]; extern int defaultRoute; |