]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/servers.h
Changed length of user::modes buffer from 512 to much more sensible 54
[user/henk/code/inspircd.git] / include / servers.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "inspircd_config.h" 
18 #include "connection.h"
19 #include <string>
20 #include <map>
21  
22 #ifndef __SERVERS_H__ 
23 #define __SERVERS_H__ 
24  
25 #define LINK_ACTIVE     1
26 #define LINK_INACTIVE   0
27
28 /** A class that defines the local server or a remote server
29  */
30 class serverrec : public connection
31 {
32  private:
33  public:
34         /** server name
35          */
36         char name[MAXBUF];
37         /** last ping response (ms)
38          */
39         long pingtime;
40         /** invisible users on server
41          */
42         long usercount_i;
43         /** non-invisible users on server
44          */
45         long usercount;
46         /** opers on server
47          */
48         long opercount;
49         /** number of hops away (for quick access)
50          */
51         int hops_away;
52         /** ircd version
53          */
54         long version;
55         /** is a JUPE server (faked to enforce a server ban)
56          */
57         bool jupiter;
58         
59         /** Description of the server
60          */     
61         char description[MAXBUF];
62
63         /** Holds nickserv's name on U:lined (services) servers (this is a kludge for ircservices which ASSUMES things :/)
64          */
65         char nickserv[NICKMAX];
66         
67         bool sync_soon;
68
69         /** Constructor
70          */
71         serverrec();
72         /** Constructor which initialises some of the main variables
73          */
74         serverrec(char* n, long ver, bool jupe);
75         /** Destructor
76          */
77         ~serverrec();
78
79         /** With a serverrec, this is a list of all established server connections.
80          */
81         std::vector<ircd_connector> connectors;
82
83
84         /** Create a listening socket on 'host' using port number 'p'
85          */
86         bool CreateListener(char* host, int p);
87
88         /** Begin an outbound link to another ircd at targethost.
89          */
90         bool BeginLink(char* targethost, int port, char* password, char* servername, int myport);
91
92         /** Begin an outbound mesh link to another ircd on a network you are already an authenticated member of
93          */
94         bool MeshCookie(char* targethost, int port, unsigned long cookie, char* servername);
95
96         /** Terminate a link to 'targethost' by calling the ircd_connector::CloseConnection method.
97          */
98         void TerminateLink(char* targethost);
99
100         /** Send a message to a server by name, if the server is unavailable directly route the packet via another server
101          * If the server still cannot be reached after attempting to route the message remotely, returns false.
102          */
103         bool SendPacket(char *message, const char* host);
104
105         /** Returns the next available packet and returns true if data is available. Writes the servername the data came from to 'host'.
106          * If no data is available this function returns false.
107          * This function will automatically close broken links and reroute pathways, generating split messages on the network.
108          */
109         bool RecvPacket(std::deque<std::string> &messages, char* host, std::deque<std::string> &sums);
110
111         /** Find the ircd_connector oject related to a certain servername given in 'host'
112          */
113         ircd_connector* FindHost(std::string host);
114
115         /** Add an incoming connection to the connection pool.
116          * (reserved for core use)
117          */
118         bool AddIncoming(int fd,char* targethost, int sourceport);      
119
120         /** Flushes all data waiting to be written for all of this server's connections
121          */
122         void FlushWriteBuffers();
123 };
124
125 #endif
126