From 114b15864ac8cf4143ed415dd90b7550e2b5687c Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 26 Jan 2003 20:15:03 +0000 Subject: Added server classes for linking git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@149 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/servers.h | 47 +++++++++++++++++++++++++++++++++++++++++ src/inspircd.cpp | 5 +++++ src/servers.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 include/servers.h create mode 100644 src/servers.cpp diff --git a/include/servers.h b/include/servers.h new file mode 100644 index 000000000..e62f4d3fa --- /dev/null +++ b/include/servers.h @@ -0,0 +1,47 @@ +/* + +$Log$ +Revision 1.1 2003/01/26 20:15:00 brain +Added server classes for linking + + +*/ + +#include "inspircd_config.h" +#include + +#ifndef __SERVERS_H__ +#define __SERVERS_H__ + +#define LINK_ACTIVE 1 +#define LINK_INACTIVE 0 + +typedef vector server_list; + +class serverrec +{ + private: + server_list leaf; // list of child servers (leaves) + public: + char name[MAXBUF]; // server name + int pingtime; // last ping response (ms) + int linktype; // link type, LINK_ACTIVE or LINK_INACTIVE + time_t lastping; // time the link was last pinged + long usercount_i; // invisible users on server + long usercount; // non-invisible users on server + long opercount; // opers on server + time_t connected_at; // time server was connected into the network + time_t hops_away; // number of hops away (for quick access) + long version; // ircd version + bool jupiter; // is a JUPE server (faked to enforce a server ban) + + serverrec(); + serverrec(char* n, int link_t, long ver, bool jupe); + ~serverrec() + void AddLeaf(serverrec *child); + void DelLeaf(char* n); +}; + + +#endif + diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 194bd29c2..a5bbdcfa0 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -14,6 +14,9 @@ * --------------------------------------------------- $Log$ + Revision 1.4 2003/01/26 20:15:03 brain + Added server classes for linking + Revision 1.3 2003/01/25 20:17:53 brain Fixed WHOWAS memory leak @@ -210,6 +213,7 @@ #include #include #include "users.h" +#include "servers.h" #include "ctables.h" #include "globals.h" #include "modules.h" @@ -301,6 +305,7 @@ typedef DLLFactory ircd_module; user_hash clientlist; chan_hash chanlist; user_hash whowas; +server_list servers; command_table cmdlist; file_cache MOTD; file_cache RULES; diff --git a/src/servers.cpp b/src/servers.cpp new file mode 100644 index 000000000..44bd2e0c3 --- /dev/null +++ b/src/servers.cpp @@ -0,0 +1,62 @@ +/* + +$Log$ +Revision 1.1 2003/01/26 20:15:03 brain +Added server classes for linking + + +*/ + +#include "inspircd_config.h" +#include "servers.h" +#include "inspircd.h" +#include + +serverrec::serverrec() +{ + leaf.clear(); + strcpy(name,""); + pingtime = 0; + linktype = LINK_ACTIVE; + lastping = time(NULL); + usercount_i = usercount = opercount = version = 0; + hops_away = 1; + connected_at = time(NULL); + jupiter = false; +} + + +serverrec::~serverrec() +{ +} + +serverrec::serverrec(char* n, int link_t, long ver, bool jupe) +{ + leaf.clear(); + strcpy(name,n); + linktype = link_t; + lastping = time(NULL); + usercount_i = usercount = opercount = 0; + version = ver; + hops_away = 1; + connected_at = time(NULL); + jupiter = jupe; +} + +void serverrec::AddLeaf(serverrec *child) +{ + leaf.push_back(child); +} + +void serverrec::DelLeaf(char* n) +{ + for (server_list::iterator i = leaf.begin(); i != leaf.end(); i++) + { + if (strcasecmp(n,i->name)) + { + leaf.erase(i); + return; + } + } +} + -- cgit v1.2.3