From d190f6e7c22d0b246a90f60dbadb7f8f44f0d813 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 30 Apr 2005 16:27:32 +0000 Subject: [PATCH] Changed how remote version works a bit Commented some of connection.cpp git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1268 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/connection.cpp | 23 ++++++++++++++++++----- src/inspircd.cpp | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 75d1bea04..5cdd83f7f 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -39,6 +39,23 @@ extern int MODCOUNT; extern time_t TIME; + +/** + * The InspIRCd mesh network is maintained by a tree of objects which reference *themselves*. + * Every local server has an array of 32 *serverrecs, known as me[]. Each of these represents + * a local listening port, and is not null if the user has opened a listening port on the server. + * It is assumed nobody will ever want to open more than 32 listening server ports at any one + * time (i mean come on, why would you want more, the ircd works fine with ONE). + * Each me[] entry has multiple classes within it of type ircd_connector. These are stored in a vector + * and each represents a server linked via this socket. If the connection was created outbound, + * the connection is bound to the default ip address by using me[defaultRoute] (defaultRoute being + * a global variable which indicates the default server to make connections on). If the connection + * was created inbound, it is attached to the port the connection came in on. There may be as many + * ircd_connector objects as needed in each me[] entry. Each ircd_connector implements the specifics + * of an ircd connection in the mesh, however each ircd may have multiple ircd_connector connections + * to it, to maintain the mesh link. + */ + connection::connection() { fd = 0; @@ -274,11 +291,7 @@ void ircd_connector::SetVersionString(std::string newversion) std::string ircd_connector::GetVersionString() { - if (this->version == "") - { - return "(No version available for "+this->servername+")"; - } - else return this->version; + return this->version; } bool connection::MeshCookie(char* targethost, int newport, unsigned long cookie, char* servername) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 59256f8c0..2671de21b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2746,6 +2746,12 @@ void handle_version(char **parameters, int pcnt, userrec *user) } else { + if (match(ServerName,parameters[0])) + { + WriteServ(user->fd,"351 %s :%s",user->nick,GetVersionString().c_str()); + return; + } + bool displayed = false, found = false; for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -2754,12 +2760,21 @@ void handle_version(char **parameters, int pcnt, userrec *user) { 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; + found = true; + if ((me[j]->connectors[x].GetVersionString() != "") && (!displayed)) + { + displayed = true; + WriteServ(user->fd,"351 %s :%s",user->nick,me[j]->connectors[x].GetVersionString().c_str()); + } } } } } + if ((!displayed) && (found)) + { + WriteServ(user->fd,"402 %s %s :Server %s has no version information",user->nick,parameters[0],parameters[0]); + return; + } WriteServ(user->fd,"402 %s %s :No such server",user->nick,parameters[0]); } return; -- 2.39.5