summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-10 13:29:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-10 13:29:38 +0000
commita8ddb6ccc27eac6db1f7457e998678aa07879513 (patch)
tree7172635b297e5a7fca2587d04d725eec7839cbf6
parentc5a01fa08eb78a786ca45ff32472eec4f3be88c6 (diff)
Added /map and /links
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@493 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/servers.h28
-rw-r--r--src/inspircd.cpp50
2 files changed, 65 insertions, 13 deletions
diff --git a/include/servers.h b/include/servers.h
index 9bf16defc..dfb3a8ef8 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -20,39 +20,43 @@ class serverrec : public connection
{
private:
public:
- /** server name
- */
+ /** server name
+ */
char name[MAXBUF];
/** last ping response (ms)
- */
+ */
long pingtime;
/** invisible users on server
- */
+ */
long usercount_i;
/** non-invisible users on server
- */
+ */
long usercount;
/** opers on server
- */
+ */
long opercount;
/** number of hops away (for quick access)
- */
+ */
int hops_away;
/** ircd version
- */
+ */
long version;
/** is a JUPE server (faked to enforce a server ban)
- */
+ */
bool jupiter;
+
+ /** Description of the server
+ */
+ char description[MAXBUF];
/** Constructor
- */
+ */
serverrec();
/** Constructor which initialises some of the main variables
- */
+ */
serverrec(char* n, long ver, bool jupe);
/** Destructor
- */
+ */
~serverrec();
};
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 60b74b4d4..07d055b74 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -4779,6 +4779,50 @@ void handle_squit(char **parameters, int pcnt, userrec *user)
// send out an squit across the mesh and then clear the server list (for local squit)
}
+char islast(serverrec* s)
+{
+ char c = '`';
+ for (int j = 0; j < 255; j++)
+ {
+ if (servers[j] != NULL)
+ {
+ c = '|';
+ }
+ if (servers[j] == s)
+ {
+ c = '`';
+ }
+ }
+ return c;
+}
+
+void handle_links(char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,ServerName,ServerName,ServerDesc);
+ for (int j = 0; j < 255; j++)
+ {
+ if (servers[j] != NULL)
+ {
+ WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,servers[j]->name,ServerName,servers[j]->description);
+ }
+ }
+ WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
+}
+
+void handle_map(char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"006 %s :%s",user->nick,ServerName);
+ for (int j = 0; j < 255; j++)
+ {
+ if (servers[j] != NULL)
+ {
+ WriteServ(user->fd,"006 %s :%c-%s",user->nick,islast(servers[j]),servers[j]->name);
+ }
+ }
+ WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
+}
+
+
void handle_oper(char **parameters, int pcnt, userrec *user)
{
char LoginName[MAXBUF];
@@ -5263,6 +5307,8 @@ void SetupCommandTable(void)
createcommand("CONNECT",handle_connect,'o',1);
createcommand("SQUIT",handle_squit,'o',1);
createcommand("MODULES",handle_modules,'o',0);
+ createcommand("LINKS",handle_links,0,0);
+ createcommand("MAP",handle_map,0,0);
}
void process_buffer(const char* cmdbuf,userrec *user)
@@ -5556,7 +5602,7 @@ void handle_link_packet(long theirkey, char* udp_msg, char* udp_host, int udp_po
char* servername = strtok(params," ");
char* password = strtok(NULL," ");
char* serverdesc = finalparam+2;
- WriteOpers("CONNECT from %s (%s)",servername,udp_host,password,serverdesc);
+ WriteOpers("CONNECT from %s (%s)",servername,udp_host);
char Link_ServerName[1024];
@@ -5589,6 +5635,7 @@ void handle_link_packet(long theirkey, char* udp_msg, char* udp_host, int udp_po
servers[j] = new serverrec;
strcpy(servers[j]->internal_addr,udp_host);
strcpy(servers[j]->name,servername);
+ strcpy(servers[j]->description,serverdesc);
// create a server record for this server
snprintf(response,10240,"O %d",MyKey);
serv->SendPacket(response,udp_host,udp_port,0);
@@ -5675,6 +5722,7 @@ void handle_link_packet(long theirkey, char* udp_msg, char* udp_host, int udp_po
for (int j = 0; j < 255; j++) {
if (servers[j] != NULL) {
if (!strcasecmp(servers[j]->internal_addr,udp_host)) {
+ strcpy(servers[j]->description,serverdesc);
WriteOpers("Server %s authenticated, exchanging server keys...",servername);
snprintf(response,10240,"O %d",MyKey);
serv->SendPacket(response,udp_host,udp_port,0);