summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp11
-rw-r--r--src/connection.cpp15
-rw-r--r--src/inspircd.cpp53
-rw-r--r--src/modules.cpp32
4 files changed, 89 insertions, 22 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 219ee55d0..11d0c2365 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1830,6 +1830,13 @@ void handle_nick(char **parameters, int pcnt, userrec *user)
}
+void handle_v(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
+{
+ char* servername = strtok(params," ");
+ char* versionstr = strtok(NULL,"\r\n");
+ ircd_connector* cn = reply->FindHost(servername);
+ cn->SetVersionString(servername);
+}
void handle_V(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
{
@@ -2722,6 +2729,10 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve
case 'V':
handle_V(token,params,source,reply,tcp_host);
break;
+ // v <servername> <arbitary version string>
+ case 'v':
+ handle_v(token,params,source,reply,tcp_host);
+ break;
// L <SOURCE> <CHANNEL> :<REASON>
// User parting a channel
case 'L':
diff --git a/src/connection.cpp b/src/connection.cpp
index 36a4570eb..75d1bea04 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -266,6 +266,21 @@ bool connection::BeginLink(char* targethost, int newport, char* password, char*
return false;
}
+void ircd_connector::SetVersionString(std::string newversion)
+{
+ log(DEBUG,"Set version of %s to %s",this->servername.c_str(),newversion.c_str());
+ this->version = newversion;
+}
+
+std::string ircd_connector::GetVersionString()
+{
+ if (this->version == "")
+ {
+ return "(No version available for "+this->servername+")";
+ }
+ else return this->version;
+}
+
bool connection::MeshCookie(char* targethost, int newport, unsigned long cookie, char* servername)
{
char connect[MAXBUF];
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index e2adcce16..4a5b3cba3 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2678,18 +2678,45 @@ void ConnectUser(userrec *user)
}
}
-void handle_version(char **parameters, int pcnt, userrec *user)
+std::string GetVersionString()
{
- char Revision[] = "$Revision$";
-
- char *s1 = Revision;
- char *savept;
- char *v2 = strtok_r(s1," ",&savept);
- s1 = savept;
- v2 = strtok_r(s1," ",&savept);
- s1 = savept;
+ char Revision[] = "$Revision$";
+ char versiondata[MAXBUF];
+ char *s1 = Revision;
+ char *savept;
+ char *v2 = strtok_r(s1," ",&savept);
+ s1 = savept;
+ v2 = strtok_r(s1," ",&savept);
+ s1 = savept;
+ snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s (O=%lu)",VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION);
- WriteServ(user->fd,"351 %s :%s Rev. %s %s :%s (O=%lu)",user->nick,VERSION,v2,ServerName,SYSTEM,(unsigned long)OPTIMISATION);
+}
+
+void handle_version(char **parameters, int pcnt, userrec *user)
+{
+ if (!pcnt)
+ {
+ WriteServ(user->fd,"351 %s :%s",user->nick,GetVersionString().c_str());
+ }
+ else
+ {
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int x = 0; x < me[j]->connectors.size(); x++)
+ {
+ 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;
+ }
+ }
+ }
+ }
+ WriteServ(user->fd,"402 %s %s :No such server",user->nick,parameters[0]);
+ }
+ return;
}
@@ -3308,6 +3335,7 @@ void DoSync(serverrec* serv, char* tcp_host)
NetSendMyRoutingTable();
+ // send all routing table and uline voodoo. The ordering of these commands is IMPORTANT!
for (int j = 0; j < 32; j++)
{
if (me[j] != NULL)
@@ -3323,6 +3351,11 @@ void DoSync(serverrec* serv, char* tcp_host)
}
}
+ // send our version for the remote side to cache
+ snprintf(data,MAXBUF,"v %s %s",ServerName,GetVersionString().c_str());
+ serv->SendPacket(data,tcp_host);
+
+ // sync the users and channels, give the modules a look-in.
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
snprintf(data,MAXBUF,"N %lu %s %s %s %s +%s %s %s :%s",(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,u->second->ip,u->second->server,u->second->fullname);
diff --git a/src/modules.cpp b/src/modules.cpp
index af3ef5303..339374ae2 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -619,22 +619,30 @@ Admin Server::GetAdmin()
bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int params_when_on, int params_when_off)
{
- if (type == MT_SERVER)
+ if (((modechar >= 'A') && (modechar <= 'Z')) || ((modechar >= 'a') && (modechar <= 'z')))
{
- log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion");
- return false;
- }
- if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT))
- {
- log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported");
- return false;
+ if (type == MT_SERVER)
+ {
+ log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion");
+ return false;
+ }
+ if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT))
+ {
+ log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported");
+ return false;
+ }
+ if ((params_when_on>1) || (params_when_off>1))
+ {
+ log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported");
+ return false;
+ }
+ return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off);
}
- if ((params_when_on>1) || (params_when_off>1))
+ else
{
- log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported");
- return false;
+ log(DEBUG,"*** API ERROR *** Muppet modechar detected.");
}
- return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off);
+ return false;
}
bool Server::AddExtendedListMode(char modechar)