summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/extern.h36
-rw-r--r--include/modules.h9
-rw-r--r--include/servers.h179
-rw-r--r--include/services.h93
4 files changed, 188 insertions, 129 deletions
diff --git a/include/extern.h b/include/extern.h
index 5ede04dc8..79f1702f9 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -23,8 +23,6 @@
E void ModuleRunTimeDirCleanUp();
-E char *uplink;
-
/* IRC Variables */
E IRCDVar *ircd;
@@ -423,7 +421,7 @@ E int add_szline(User * u, const char *mask, const char *by,
E void expire_szlines();
E int check_szline(const char *nick, char *ip);
-E Server *server_global(Server * s, char *msg);
+E void server_global(Server *s, const std::string &message);
E std::vector<NewsItem *> News;
@@ -459,37 +457,6 @@ E void notice_lang(const std::string &source, User *dest, int message, ...); //
E void notice_help(const char *source, User *dest, int message, ...); // MARK_DEPRECATED;
-/**** servers.c ****/
-
-E Server *servlist;
-E Server *me_server;
-E Server *serv_uplink;
-E Flags<CapabType> Capab;
-E CapabInfo Capab_Info[];
-
-E Server *first_server(ServerFlag flag);
-E Server *next_server(ServerFlag flag);
-
-E void CapabParse(int ac, const char **av);
-E int is_ulined(const char *server);
-E int is_sync(Server *server);
-
-E Server *new_server(Server * uplink, const char *name, const char *desc, ServerFlag flag, const std::string &suid);
-
-E Server *findserver(Server *s, const char *name);
-
-E void do_server(const char *source, const char *servername, const char *hops, const char *descript, const std::string &numeric);
-E void do_squit(const char *source, int ac, const char **av);
-E int anope_check_sync(const char *name);
-
-E void finish_sync(Server *serv, int sync_links);
-
-E void ts6_uid_init();
-E void ts6_uid_increment(unsigned int slot);
-E const char *ts6_uid_retrieve();
-
-E const char *ts6_sid_retrieve();
-
/**** sessions.c ****/
E Exception *exceptions;
@@ -550,7 +517,6 @@ E User *first_uid();
E User *next_uid();
E Server *findserver_uid(Server * s, const char *name);
E char *TS6SID;
-E char *TS6UPLINK;
E User *do_nick(const char *source, const char *nick, const char *username, const char *host,
const char *server, const char *realname, time_t ts, uint32 ip, const char *vhost, const char *uid);
diff --git a/include/modules.h b/include/modules.h
index dcaac342c..afc6806d1 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -585,9 +585,9 @@ class CoreExport Module
*/
virtual void OnServerConnect() { }
- /** Called when we are done synching with the uplink, just before we send the EOB
+ /** Called when we are almost done synching with the uplink, just before we send the EOB
*/
- virtual void OnFinishSync(Server *serv) { }
+ virtual void OnPreUplinkSync(Server *serv) { }
/** Called when Anope disconnects from its uplink, before it tries to reconnect
*/
@@ -1060,8 +1060,9 @@ class CoreExport Module
virtual void OnServerSync(Server *s) { }
/** Called when we sync with our uplink
+ * @param s Our uplink
*/
- virtual void OnUplinkSync() { }
+ virtual void OnUplinkSync(Server *s) { }
};
@@ -1109,7 +1110,7 @@ enum Implementation
I_OnModuleLoad, I_OnModuleUnload,
/* Other */
- I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnFinishSync, I_OnServerDisconnect, I_OnPreCommandRun,
+ I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun,
I_OnPreCommand, I_OnPostCommand, I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnEncryptInPlace, I_OnEncryptCheckLen, I_OnDecrypt, I_OnCheckPassword,
diff --git a/include/servers.h b/include/servers.h
new file mode 100644
index 000000000..f6a5933ed
--- /dev/null
+++ b/include/servers.h
@@ -0,0 +1,179 @@
+/* Anope */
+extern CoreExport Server *Me;
+
+extern CoreExport void CapabParse(int ac, const char **av);
+
+extern CoreExport void do_server(const std::string &source, const std::string &servername, unsigned int hops, const std::string &descript, const std::string &numeric);
+extern CoreExport void do_squit(const char *source, int ac, const char **av);
+
+extern CoreExport const char *ts6_uid_retrieve();
+extern CoreExport const char *ts6_sid_retrieve();
+
+/* Types of capab
+ */
+enum CapabType
+{
+ CAPAB_BEGIN,
+
+ CAPAB_NOQUIT,
+ CAPAB_TSMODE,
+ CAPAB_UNCONNECT,
+ CAPAB_NICKIP,
+ CAPAB_NSJOIN,
+ CAPAB_ZIP,
+ CAPAB_BURST,
+ CAPAB_TS3,
+ CAPAB_TS5,
+ CAPAB_DKEY,
+ CAPAB_DOZIP,
+ CAPAB_DODKEY,
+ CAPAB_QS,
+ CAPAB_SCS,
+ CAPAB_PT4,
+ CAPAB_UID,
+ CAPAB_KNOCK,
+ CAPAB_CLIENT,
+ CAPAB_IPV6,
+ CAPAB_SSJ5,
+ CAPAB_SN2,
+ CAPAB_VHOST,
+ CAPAB_TOKEN,
+ CAPAB_SSJ3,
+ CAPAB_NICK2,
+ CAPAB_VL,
+ CAPAB_TLKEXT,
+ CAPAB_CHANMODE,
+ CAPAB_SJB64,
+ CAPAB_NICKCHARS,
+
+ CAPAB_END
+};
+
+/* CAPAB stuffs */
+struct CapabInfo
+{
+ std::string Token;
+ CapabType Flag;
+};
+
+extern CoreExport Flags<CapabType> Capab;
+extern CoreExport CapabInfo Capab_Info[];
+
+/** Flags set on servers
+ */
+enum ServerFlag
+{
+ /* Server is syncing */
+ SERVER_SYNCING,
+ /* This server was juped */
+ SERVER_JUPED
+};
+
+/** Class representing a server
+ */
+class Server : public Flags<ServerFlag>
+{
+ private:
+ /* Server name */
+ std::string Name;
+ /* Hops between services and server */
+ unsigned int Hops;
+ /* Server description */
+ std::string Description;
+ /* Server ID */
+ std::string SID;
+ /* Links for this server */
+ std::list<Server *>* Links;
+ /* Uplink for this server */
+ Server *UplinkServer;
+
+ /* Reason this server was quit */
+ std::string QReason;
+
+ public:
+ /** Constructor
+ * @param uplink The uplink this server is from, is only NULL when creating Me
+ * @param name The server name
+ * @param hops Hops from services server
+ * @param description Server rdescription
+ * @param sid Server sid/numeric
+ */
+ Server(Server *uplink, const std::string &name, unsigned int hops, const std::string &description, const std::string &sid);
+
+ /** Destructor
+ */
+ ~Server();
+
+ /** Delete this server with a reason
+ * @param reason The reason
+ */
+ void Delete(const std::string &reason);
+
+ /** Get the name for this server
+ * @return The name
+ */
+ const std::string& GetName() const;
+
+ /** Get the number of hops this server is from services
+ * @return Number of hops
+ */
+ unsigned int GetHops() const;
+
+ /** Set the server description
+ * @param desc The new description
+ */
+ void SetDescription(const std::string& desc);
+
+ /** Get the server description
+ * @return The server description
+ */
+ const std::string& GetDescription() const;
+
+ /** Get the server numeric/SID
+ * @return The numeric/SID
+ */
+ const std::string& GetSID() const;
+
+ /** Get the list of links this server has, or NULL if it has none
+ * @return A list of servers
+ */
+ const std::list<Server*>* GetLinks() const;
+
+ /** Get the uplink server for this server, if this is our uplink will be Me
+ * @return The servers uplink
+ */
+ Server* GetUplink() const;
+
+ /** Adds a link to this server
+ * @param s The linking server
+ */
+ void AddLink(Server *s);
+
+ /** Delinks a server from this server
+ * @param s The server
+ */
+ void DelLink(Server *s);
+
+ /** Finish syncing this server and optionally all links to it
+ * @param SyncLinks True to sync the links for this server too (if any)
+ */
+ void Sync(bool SyncLinks);
+
+ /** Check if this server is synced
+ * @return true or false
+ */
+ bool IsSynced() const;
+
+ /** Check if this server is ULined
+ * @return true or false
+ */
+ bool IsULined() const;
+
+ /** Find a server
+ * @param name The name or SID/numeric
+ * @param s The server list to search for this server on, defaults to our Uplink
+ * @return The server
+ */
+ static Server* Find(const std::string &name, Server *s = NULL);
+};
+
diff --git a/include/services.h b/include/services.h
index 2741e0178..4dd35a751 100644
--- a/include/services.h
+++ b/include/services.h
@@ -348,6 +348,7 @@ template<typename T> class Flags
class User;
class ChannelInfo;
class Channel;
+class Server;
struct EList;
typedef struct bandata_ BanData;
@@ -677,48 +678,7 @@ typedef struct {
/*************************************************************************/
-/* Server data */
-
-typedef enum {
- SSYNC_IN_PROGRESS = 0, /* Sync is currently in progress */
- SSYNC_DONE = 1 /* We're in sync */
-} SyncState;
-
-/** Flags set on servers
- */
-enum ServerFlag
-{
- SERVER_START,
-
- /* This server is me */
- SERVER_ISME,
- /* This server was juped */
- SERVER_JUPED,
- /* This server is the current uplink */
- SERVER_ISUPLINK,
-
- SERVER_END
-};
-
-class Server : public Flags<ServerFlag>
-{
- public:
- Server *next, *prev;
-
- char *name; /* Server name */
- uint16 hops; /* Hops between services and server */
- char *desc; /* Server description */
- char *suid; /* Server Univeral ID */
- SyncState sync; /* Server sync state (see above) */
-
- Server *links; /* Linked list head for linked servers */
- Server *uplink; /* Server which pretends to be the uplink */
-};
-
-/*************************************************************************/
-
#include "users.h"
-
/* This structure stocks ban data since it must not be removed when
* user is kicked.
*/
@@ -920,55 +880,6 @@ enum DefconLevel
/*************************************************************************/
-/* Types of capab
- */
-enum CapabType
-{
- CAPAB_BEGIN,
-
- CAPAB_NOQUIT,
- CAPAB_TSMODE,
- CAPAB_UNCONNECT,
- CAPAB_NICKIP,
- CAPAB_NSJOIN,
- CAPAB_ZIP,
- CAPAB_BURST,
- CAPAB_TS3,
- CAPAB_TS5,
- CAPAB_DKEY,
- CAPAB_DOZIP,
- CAPAB_DODKEY,
- CAPAB_QS,
- CAPAB_SCS,
- CAPAB_PT4,
- CAPAB_UID,
- CAPAB_KNOCK,
- CAPAB_CLIENT,
- CAPAB_IPV6,
- CAPAB_SSJ5,
- CAPAB_SN2,
- CAPAB_VHOST,
- CAPAB_TOKEN,
- CAPAB_SSJ3,
- CAPAB_NICK2,
- CAPAB_VL,
- CAPAB_TLKEXT,
- CAPAB_CHANMODE,
- CAPAB_SJB64,
- CAPAB_NICKCHARS,
-
- CAPAB_END
-};
-
-/* CAPAB stuffs */
-struct CapabInfo
-{
- std::string Token;
- CapabType Flag;
-};
-
-/*************************************************************************/
-
/**
* RFC: defination of a valid nick
* nickname = ( letter / special ) *8( letter / digit / special / "-" )
@@ -986,7 +897,9 @@ struct CapabInfo
class IRCDProto;
struct Uplink;
class ServerConfig;
+
#include "extern.h"
+#include "servers.h"
#include "configreader.h"
class CoreExport IRCDProto