]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/servers_8cpp-source.html
Fixed 'fake direction' messages being put out by user->registered = 7 being set too...
[user/henk/code/inspircd.git] / docs / module-doc / servers_8cpp-source.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>InspIRCd: servers.cpp Source File</title>
4 <link href="inspircd.doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <h1>servers.cpp</h1><a href="servers_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*       +------------------------------------+</span>
9 00002 <span class="comment"> *       | Inspire Internet Relay Chat Daemon |</span>
10 00003 <span class="comment"> *       +------------------------------------+</span>
11 00004 <span class="comment"> *</span>
12 00005 <span class="comment"> *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.</span>
13 00006 <span class="comment"> *                       E-mail:</span>
14 00007 <span class="comment"> *                &lt;brain@chatspike.net&gt;</span>
15 00008 <span class="comment"> *                &lt;Craig@chatspike.net&gt;</span>
16 00009 <span class="comment"> *     </span>
17 00010 <span class="comment"> * Written by Craig Edwards, Craig McLure, and others.</span>
18 00011 <span class="comment"> * This program is free but copyrighted software; see</span>
19 00012 <span class="comment"> *            the file COPYING for details.</span>
20 00013 <span class="comment"> *</span>
21 00014 <span class="comment"> * ---------------------------------------------------</span>
22 00015 <span class="comment"> */</span>
23 00016 
24 00017 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
25 00018 
26 00019 <span class="preprocessor">#include "inspircd_config.h"</span> 
27 00020 <span class="preprocessor">#include "<a class="code" href="servers_8h.html">servers.h</a>"</span>
28 00021 <span class="preprocessor">#include "inspircd.h"</span>
29 00022 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
30 00023 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
31 00024 <span class="preprocessor">#include &lt;poll.h&gt;</span>
32 00025 <span class="preprocessor">#include &lt;sys/errno.h&gt;</span>
33 00026 <span class="preprocessor">#include &lt;sys/ioctl.h&gt;</span>
34 00027 <span class="preprocessor">#include &lt;sys/utsname.h&gt;</span>
35 00028 <span class="preprocessor">#include &lt;vector&gt;</span>
36 00029 <span class="preprocessor">#include &lt;string&gt;</span>
37 00030 <span class="preprocessor">#include &lt;deque&gt;</span>
38 00031 <span class="preprocessor">#include &lt;sstream&gt;</span>
39 00032 <span class="preprocessor">#include &lt;map&gt;</span>
40 00033 <span class="preprocessor">#include "inspstring.h"</span>
41 00034 <span class="preprocessor">#include "helperfuncs.h"</span>
42 00035 <span class="preprocessor">#include "<a class="code" href="connection_8h.html">connection.h</a>"</span>
43 00036 
44 <a name="l00037"></a><a class="code" href="servers_8cpp.html#a0">00037</a> <span class="keyword">extern</span> time_t <a class="code" href="channels_8cpp.html#a36">TIME</a>;
45 <a name="l00038"></a><a class="code" href="servers_8cpp.html#a1">00038</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="servers_8cpp.html#a1">MaxConn</a>;
46 00039 
47 <a name="l00040"></a><a class="code" href="servers_8cpp.html#a2">00040</a> <span class="keyword">extern</span> <a class="code" href="classserverrec.html">serverrec</a>* <a class="code" href="channels_8cpp.html#a34">me</a>[32];
48 00041 
49 <a name="l00042"></a><a class="code" href="servers_8cpp.html#a3">00042</a> <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a>;
50 00043 
51 <a name="l00044"></a><a class="code" href="servers_8cpp.html#a4">00044</a> std::deque&lt;std::string&gt; <a class="code" href="servers_8cpp.html#a4">xsums</a>;
52 00045 
53 <a name="l00046"></a><a class="code" href="classserverrec.html#a0">00046</a> <a class="code" href="classserverrec.html#a0">serverrec::serverrec</a>()
54 00047 {
55 00048         strlcpy(<a class="code" href="classserverrec.html#o0">name</a>,<span class="stringliteral">""</span>,256);
56 00049         <a class="code" href="classserverrec.html#o1">pingtime</a> = 0;
57 00050         <a class="code" href="classconnection.html#o10">lastping</a> = <a class="code" href="channels_8cpp.html#a36">TIME</a>;
58 00051         <a class="code" href="classserverrec.html#o2">usercount_i</a> = <a class="code" href="classserverrec.html#o3">usercount</a> = <a class="code" href="classserverrec.html#o4">opercount</a> = <a class="code" href="classserverrec.html#o6">version</a> = 0;
59 00052         <a class="code" href="classserverrec.html#o5">hops_away</a> = 1;
60 00053         <a class="code" href="classconnection.html#o11">signon</a> = <a class="code" href="channels_8cpp.html#a36">TIME</a>;
61 00054         <a class="code" href="classserverrec.html#o7">jupiter</a> = <span class="keyword">false</span>;
62 00055         <a class="code" href="classconnection.html#o0">fd</a> = 0;
63 00056         <a class="code" href="classserverrec.html#o10">sync_soon</a> = <span class="keyword">false</span>;
64 00057         strlcpy(<a class="code" href="classserverrec.html#o9">nickserv</a>,<span class="stringliteral">""</span>,NICKMAX);
65 00058         <a class="code" href="classserverrec.html#o11">connectors</a>.clear();
66 00059 }
67 00060 
68 00061  
69 <a name="l00062"></a><a class="code" href="classserverrec.html#a2">00062</a> <a class="code" href="classserverrec.html#a2">serverrec::~serverrec</a>()
70 00063 {
71 00064 }
72 00065 
73 <a name="l00066"></a><a class="code" href="classserverrec.html#a1">00066</a> <a class="code" href="classserverrec.html#a0">serverrec::serverrec</a>(<span class="keywordtype">char</span>* n, <span class="keywordtype">long</span> ver, <span class="keywordtype">bool</span> jupe)
74 00067 {
75 00068         strlcpy(<a class="code" href="classserverrec.html#o0">name</a>,n,256);
76 00069         <a class="code" href="classconnection.html#o10">lastping</a> = <a class="code" href="channels_8cpp.html#a36">TIME</a>;
77 00070         <a class="code" href="classserverrec.html#o2">usercount_i</a> = <a class="code" href="classserverrec.html#o3">usercount</a> = <a class="code" href="classserverrec.html#o4">opercount</a> = 0;
78 00071         <a class="code" href="classserverrec.html#o6">version</a> = ver;
79 00072         <a class="code" href="classserverrec.html#o5">hops_away</a> = 1;
80 00073         <a class="code" href="classconnection.html#o11">signon</a> = <a class="code" href="channels_8cpp.html#a36">TIME</a>;
81 00074         <a class="code" href="classserverrec.html#o7">jupiter</a> = jupe;
82 00075         <a class="code" href="classconnection.html#o0">fd</a> = 0;
83 00076         <a class="code" href="classserverrec.html#o10">sync_soon</a> = <span class="keyword">false</span>;
84 00077         strlcpy(<a class="code" href="classserverrec.html#o9">nickserv</a>,<span class="stringliteral">""</span>,NICKMAX);
85 00078         <a class="code" href="classserverrec.html#o11">connectors</a>.clear();
86 00079 }
87 00080 
88 <a name="l00081"></a><a class="code" href="classserverrec.html#a3">00081</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a3">serverrec::CreateListener</a>(<span class="keywordtype">char</span>* newhost, <span class="keywordtype">int</span> p)
89 00082 {
90 00083         sockaddr_in host_address;
91 00084         <span class="keywordtype">int</span> flags;
92 00085         in_addr addy;
93 00086         <span class="keywordtype">int</span> on = 0;
94 00087         <span class="keyword">struct </span>linger linger = { 0 };
95 00088 
96 00089         this-&gt;<a class="code" href="classconnection.html#o8">port</a> = p;
97 00090 
98 00091         <a class="code" href="classconnection.html#o0">fd</a> = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
99 00092         <span class="keywordflow">if</span> (<a class="code" href="classconnection.html#o0">fd</a> &lt;= 0)
100 00093         {
101 00094                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
102 00095         }
103 00096 
104 00097         setsockopt(<a class="code" href="classconnection.html#o0">fd</a>,SOL_SOCKET,SO_REUSEADDR,(<span class="keyword">const</span> <span class="keywordtype">char</span>*)&amp;on,<span class="keyword">sizeof</span>(on));
105 00098         linger.l_onoff = 1;
106 00099         linger.l_linger = 1;
107 00100         setsockopt(<a class="code" href="classconnection.html#o0">fd</a>,SOL_SOCKET,SO_LINGER,(<span class="keyword">const</span> <span class="keywordtype">char</span>*)&amp;linger,<span class="keyword">sizeof</span>(linger));
108 00101 
109 00102         <span class="comment">// attempt to increase socket sendq and recvq as high as its possible</span>
110 00103         <span class="comment">// to get them on linux.</span>
111 00104         <span class="keywordtype">int</span> sendbuf = 32768;
112 00105         <span class="keywordtype">int</span> recvbuf = 32768;
113 00106         setsockopt(<a class="code" href="classconnection.html#o0">fd</a>,SOL_SOCKET,SO_SNDBUF,(<span class="keyword">const</span> <span class="keywordtype">void</span> *)&amp;sendbuf,<span class="keyword">sizeof</span>(sendbuf));
114 00107         setsockopt(<a class="code" href="classconnection.html#o0">fd</a>,SOL_SOCKET,SO_RCVBUF,(<span class="keyword">const</span> <span class="keywordtype">void</span> *)&amp;recvbuf,<span class="keyword">sizeof</span>(sendbuf));
115 00108 
116 00109         memset((<span class="keywordtype">void</span>*)&amp;host_address, 0, <span class="keyword">sizeof</span>(host_address));
117 00110 
118 00111         host_address.sin_family = AF_INET;
119 00112 
120 00113         <span class="keywordflow">if</span> (!strcmp(newhost,<span class="stringliteral">""</span>))
121 00114         {
122 00115                 host_address.sin_addr.s_addr = htonl(INADDR_ANY);
123 00116         }
124 00117         <span class="keywordflow">else</span>
125 00118         {
126 00119                 inet_aton(newhost,&amp;addy);
127 00120                 host_address.sin_addr = addy;
128 00121         }
129 00122 
130 00123         host_address.sin_port = htons(p);
131 00124 
132 00125         <span class="keywordflow">if</span> (bind(<a class="code" href="classconnection.html#o0">fd</a>,(sockaddr*)&amp;host_address,<span class="keyword">sizeof</span>(host_address))&lt;0)
133 00126         {
134 00127                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
135 00128         }
136 00129 
137 00130         <span class="comment">// make the socket non-blocking</span>
138 00131         flags = fcntl(<a class="code" href="classconnection.html#o0">fd</a>, F_GETFL, 0);
139 00132         fcntl(<a class="code" href="classconnection.html#o0">fd</a>, F_SETFL, flags | O_NONBLOCK);
140 00133 
141 00134         this-&gt;<a class="code" href="classconnection.html#o8">port</a> = p;
142 00135 
143 00136         listen(this-&gt;fd, <a class="code" href="servers_8cpp.html#a1">MaxConn</a>);
144 00137 
145 00138         <span class="keywordflow">return</span> <span class="keyword">true</span>;
146 00139 }
147 00140 
148 00141 
149 <a name="l00142"></a><a class="code" href="classserverrec.html#a4">00142</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a4">serverrec::BeginLink</a>(<span class="keywordtype">char</span>* targethost, <span class="keywordtype">int</span> newport, <span class="keywordtype">char</span>* password, <span class="keywordtype">char</span>* servername, <span class="keywordtype">int</span> myport)
150 00143 {
151 00144         <span class="keywordtype">char</span> connect[MAXBUF];
152 00145 
153 00146         <a class="code" href="classircd__connector.html">ircd_connector</a> connector;
154 00147         <a class="code" href="classircd__connector.html">ircd_connector</a> *cn = this-&gt;<a class="code" href="classserverrec.html#a9">FindHost</a>(servername);
155 00148 
156 00149 
157 00150         <span class="keywordflow">if</span> (cn)
158 00151         {
159 00152                 WriteOpers(<span class="stringliteral">"CONNECT aborted: Server %s already exists"</span>,servername);
160 00153                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
161 00154         }
162 00155 
163 00156 
164 00157         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classconnection.html#o0">fd</a>)
165 00158         {
166 00159                 <span class="keywordflow">if</span> (connector.<a class="code" href="classircd__connector.html#a1">MakeOutboundConnection</a>(targethost,newport))
167 00160                 {
168 00161                         <span class="comment">// targethost has been turned into an ip...</span>
169 00162                         <span class="comment">// we dont want this as the server name.</span>
170 00163                         connector.<a class="code" href="classircd__connector.html#a3">SetServerName</a>(servername);
171 00164                         snprintf(connect,MAXBUF,<span class="stringliteral">"S %s %s %lu %s :%s"</span>,getservername().c_str(),password,(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)myport,GetRevision().c_str(),getserverdesc().c_str());
172 00165                         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a4">STATE_NOAUTH_OUTBOUND</a>);
173 00166                         connector.<a class="code" href="classircd__connector.html#a13">SetHostAndPort</a>(targethost, newport);
174 00167                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.push_back(connector);
175 00168                         <span class="comment">// this packet isn't actually sent until the socket connects -- the STATE_NOAUTH_OUTBOUND state</span>
176 00169                         <span class="comment">// queues outbound data until the socket is polled as writeable (e.g. the connection is established)</span>
177 00170                         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classserverrec.html#a7">SendPacket</a>(connect, servername);
178 00171                 }
179 00172                 <span class="keywordflow">else</span>
180 00173                 {
181 00174                         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
182 00175                         WriteOpers(<span class="stringliteral">"Could not create outbound connection to %s:%d"</span>,targethost,newport);
183 00176                 }
184 00177         }
185 00178         <span class="keywordflow">return</span> <span class="keyword">false</span>;
186 00179 }
187 00180 
188 00181 
189 <a name="l00182"></a><a class="code" href="classserverrec.html#a5">00182</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a5">serverrec::MeshCookie</a>(<span class="keywordtype">char</span>* targethost, <span class="keywordtype">int</span> newport, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> cookie, <span class="keywordtype">char</span>* servername)
190 00183 {
191 00184         <span class="keywordtype">char</span> connect[MAXBUF];
192 00185 
193 00186         <a class="code" href="classircd__connector.html">ircd_connector</a> connector;
194 00187 
195 00188         WriteOpers(<span class="stringliteral">"Establishing meshed link to %s:%d"</span>,servername,newport);
196 00189 
197 00190         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classconnection.html#o0">fd</a>)
198 00191         {
199 00192                 <span class="keywordflow">if</span> (connector.<a class="code" href="classircd__connector.html#a1">MakeOutboundConnection</a>(targethost,newport))
200 00193                 {
201 00194                         <span class="comment">// targethost has been turned into an ip...</span>
202 00195                         <span class="comment">// we dont want this as the server name.</span>
203 00196                         connector.<a class="code" href="classircd__connector.html#a3">SetServerName</a>(servername);
204 00197                         snprintf(connect,MAXBUF,<span class="stringliteral">"- %lu %s :%s"</span>,cookie,getservername().c_str(),getserverdesc().c_str());
205 00198                         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a4">STATE_NOAUTH_OUTBOUND</a>);
206 00199                         connector.<a class="code" href="classircd__connector.html#a13">SetHostAndPort</a>(targethost, newport);
207 00200                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.push_back(connector);
208 00201                         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classserverrec.html#a7">SendPacket</a>(connect, servername);
209 00202                 }
210 00203                 <span class="keywordflow">else</span>
211 00204                 {
212 00205                         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
213 00206                         WriteOpers(<span class="stringliteral">"Could not create outbound connection to %s:%d"</span>,targethost,newport);
214 00207                 }
215 00208         }
216 00209         <span class="keywordflow">return</span> <span class="keyword">false</span>;
217 00210 }
218 00211 
219 <a name="l00212"></a><a class="code" href="classserverrec.html#a10">00212</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a10">serverrec::AddIncoming</a>(<span class="keywordtype">int</span> newfd, <span class="keywordtype">char</span>* targethost, <span class="keywordtype">int</span> sourceport)
220 00213 {
221 00214         <a class="code" href="classircd__connector.html">ircd_connector</a> connector;
222 00215 
223 00216         <span class="comment">// targethost has been turned into an ip...</span>
224 00217         <span class="comment">// we dont want this as the server name.</span>
225 00218         connector.<a class="code" href="classircd__connector.html#a3">SetServerName</a>(targethost);
226 00219         connector.<a class="code" href="classircd__connector.html#a5">SetDescriptor</a>(newfd);
227 00220         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a3">STATE_NOAUTH_INBOUND</a>);
228 00221         <span class="keywordtype">int</span> flags = fcntl(newfd, F_GETFL, 0);
229 00222         fcntl(newfd, F_SETFL, flags | O_NONBLOCK);
230 00223         <span class="keywordtype">int</span> sendbuf = 32768;
231 00224         <span class="keywordtype">int</span> recvbuf = 32768;
232 00225         setsockopt(newfd,SOL_SOCKET,SO_SNDBUF,(<span class="keyword">const</span> <span class="keywordtype">void</span> *)&amp;sendbuf,<span class="keyword">sizeof</span>(sendbuf));
233 00226         setsockopt(newfd,SOL_SOCKET,SO_RCVBUF,(<span class="keyword">const</span> <span class="keywordtype">void</span> *)&amp;recvbuf,<span class="keyword">sizeof</span>(sendbuf));
234 00227         connector.<a class="code" href="classircd__connector.html#a13">SetHostAndPort</a>(targethost, sourceport);
235 00228         connector.<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a3">STATE_NOAUTH_INBOUND</a>);
236 00229         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"serverrec::AddIncoming() Added connection: %s:%d"</span>,targethost,sourceport);
237 00230         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.push_back(connector);
238 00231         <span class="keywordflow">return</span> <span class="keyword">true</span>;
239 00232 }
240 00233 
241 <a name="l00234"></a><a class="code" href="classserverrec.html#a6">00234</a> <span class="keywordtype">void</span> <a class="code" href="classserverrec.html#a6">serverrec::TerminateLink</a>(<span class="keywordtype">char</span>* targethost)
242 00235 {
243 00236         <span class="comment">// this locates the targethost in the serverrec::connectors vector of the class,</span>
244 00237        <span class="comment">// and terminates it by sending it an SQUIT token and closing its descriptor.</span>
245 00238         <span class="comment">// TerminateLink with a null string causes a terminate of ALL links</span>
246 00239 }
247 00240 
248 00241 <span class="comment">// Returns a pointer to the connector for 'host'</span>
249 <a name="l00242"></a><a class="code" href="classserverrec.html#a9">00242</a> <a class="code" href="classircd__connector.html">ircd_connector</a>* <a class="code" href="classserverrec.html#a9">serverrec::FindHost</a>(std::string findhost)
250 00243 {
251 00244         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.size(); i++)
252 00245         {
253 00246                 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetServerName() == findhost)
254 00247                 {
255 00248                         <span class="keywordflow">return</span> &amp;this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i];
256 00249                 }
257 00250         }
258 00251         <span class="keywordflow">return</span> NULL;
259 00252 }
260 00253 
261 00254 
262 00255 <span class="comment">// Checks to see if we can still reach a server at all (e.g. is it in ANY routing table?)</span>
263 <a name="l00256"></a><a class="code" href="servers_8cpp.html#a5">00256</a> <span class="keywordtype">bool</span> <a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(std::string servername)
264 00257 {
265 00258         <span class="keywordtype">int</span> c = 0;
266 00259         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> x = 0; x &lt; 32; x++)
267 00260         <span class="keywordflow">if</span> (<a class="code" href="channels_8cpp.html#a34">me</a>[x])
268 00261         {
269 00262                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="channels_8cpp.html#a34">me</a>[x]-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.size(); i++)
270 00263                 {
271 00264                         <span class="keywordflow">if</span> ((<a class="code" href="channels_8cpp.html#a34">me</a>[x]-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetServerName() == servername) &amp;&amp; (<a class="code" href="channels_8cpp.html#a34">me</a>[x]-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetState() != <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>))
272 00265                         {
273 00266                                 c++;
274 00267                         }
275 00268                 }
276 00269         }
277 00270         <span class="keywordflow">return</span> (c != 0);
278 00271 }
279 00272 
280 00273 
281 <a name="l00274"></a><a class="code" href="classserverrec.html#a11">00274</a> <span class="keywordtype">void</span> <a class="code" href="classserverrec.html#a11">serverrec::FlushWriteBuffers</a>()
282 00275 {
283 00276         <span class="keywordtype">char</span> buffer[MAXBUF];
284 00277         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.size(); i++)
285 00278         {
286 00279                 <span class="comment">// don't try and ping a NOAUTH_OUTBOUND state, its not authed yet!</span>
287 00280                 <span class="keywordflow">if</span> ((this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetState() == <a class="code" href="connection_8h.html#a4">STATE_NOAUTH_OUTBOUND</a>) &amp;&amp; (<a class="code" href="channels_8cpp.html#a36">TIME</a> &gt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].age+30))
288 00281                 {
289 00282                         <span class="comment">// however if we reach this timer its connected timed out :)</span>
290 00283                         WriteOpers(<span class="stringliteral">"*** Connection to %s timed out"</span>,this-&gt;connectors[i].GetServerName().c_str());
291 00284                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
292 00285                         NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
293 00286                         DoSplit(this-&gt;connectors[i].GetServerName().c_str());
294 00287                         <span class="keywordflow">return</span>;
295 00288                 }
296 00289                 <span class="keywordflow">if</span> ((this-&gt;connectors[i].GetState() == <a class="code" href="connection_8h.html#a3">STATE_NOAUTH_INBOUND</a>) &amp;&amp; (<a class="code" href="channels_8cpp.html#a36">TIME</a> &gt; this-&gt;connectors[i].age+30))
297 00290                 {
298 00291                         WriteOpers(<span class="stringliteral">"*** Connection from %s timed out"</span>,this-&gt;connectors[i].GetServerName().c_str());
299 00292                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
300 00293                         NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
301 00294                         DoSplit(this-&gt;connectors[i].GetServerName().c_str());
302 00295                         <span class="keywordflow">return</span>;
303 00296                 }
304 00297                 <span class="keywordflow">if</span> (this-&gt;connectors[i].GetState() != <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>)
305 00298                 {
306 00299                         <span class="keywordflow">if</span> (!this-&gt;connectors[i].CheckPing())
307 00300                         {
308 00301                                 WriteOpers(<span class="stringliteral">"*** Lost single connection to %s: Ping timeout"</span>,this-&gt;connectors[i].GetServerName().c_str());
309 00302                                 this-&gt;connectors[i].CloseConnection();
310 00303                                 this-&gt;connectors[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
311 00304                                 <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
312 00305                                 {
313 00306                                         WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting."</span>,this-&gt;connectors[i].GetServerName().c_str());
314 00307                                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
315 00308                                         NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
316 00309                                         DoSplit(this-&gt;connectors[i].GetServerName().c_str());
317 00310                                 }
318 00311                                 <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
319 00312                         }
320 00313                 }
321 00314                 <span class="keywordflow">if</span> ((this-&gt;connectors[i].GetWriteError() !=<span class="stringliteral">""</span>) &amp;&amp; (this-&gt;connectors[i].GetState() != <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>))
322 00315                 {
323 00316                         <span class="comment">// if we're here the write() caused an error, we cannot proceed</span>
324 00317                         WriteOpers(<span class="stringliteral">"*** Lost single connection to %s, link inactive and retrying: %s"</span>,this-&gt;connectors[i].GetServerName().c_str(),this-&gt;connectors[i].GetWriteError().c_str());
325 00318                         this-&gt;connectors[i].CloseConnection();
326 00319                         this-&gt;connectors[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
327 00320                         <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
328 00321                         {
329 00322                                 WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting."</span>,this-&gt;connectors[i].GetServerName().c_str());
330 00323                                 snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
331 00324                                 NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
332 00325                                 DoSplit(this-&gt;connectors[i].GetServerName().c_str());
333 00326                         }
334 00327                         <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
335 00328                 }
336 00329                 <span class="keywordflow">if</span> ((this-&gt;connectors[i].HasBufferedOutput()) &amp;&amp; (this-&gt;connectors[i].GetState() != <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>))
337 00330                 {
338 00331                         <span class="keywordflow">if</span> (!this-&gt;connectors[i].FlushWriteBuf())
339 00332                         {
340 00333                                 <span class="comment">// if we're here the write() caused an error, we cannot proceed</span>
341 00334                                 WriteOpers(<span class="stringliteral">"*** Lost single connection to %s, link inactive and retrying: %s"</span>,this-&gt;connectors[i].GetServerName().c_str(),this-&gt;connectors[i].GetWriteError().c_str());
342 00335                                 this-&gt;connectors[i].CloseConnection();
343 00336                                 this-&gt;connectors[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
344 00337                                 <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
345 00338                                 {
346 00339                                         WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting."</span>,this-&gt;connectors[i].GetServerName().c_str());
347 00340                                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
348 00341                                         NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
349 00342                                         DoSplit(this-&gt;connectors[i].GetServerName().c_str());
350 00343                                 }
351 00344                                 <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
352 00345                         }
353 00346                 }
354 00347         }
355 00348 }
356 00349 
357 <a name="l00350"></a><a class="code" href="classserverrec.html#a7">00350</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a7">serverrec::SendPacket</a>(<span class="keywordtype">char</span> *message, <span class="keyword">const</span> <span class="keywordtype">char</span>* sendhost)
358 00351 {
359 00352         <span class="keywordflow">if</span> ((!message) || (!sendhost))
360 00353                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
361 00354 
362 00355         <a class="code" href="classircd__connector.html">ircd_connector</a>* cn = this-&gt;<a class="code" href="classserverrec.html#a9">FindHost</a>(sendhost);
363 00356 
364 00357         <span class="keywordflow">if</span> (!strchr(message,<span class="charliteral">'\n'</span>))
365 00358         {
366 00359                 strlcat(message,<span class="stringliteral">"\n"</span>,MAXBUF);
367 00360         }
368 00361 
369 00362         <span class="keywordflow">if</span> (cn)
370 00363         {
371 00364                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"main: serverrec::SendPacket() sent '%s' to %s"</span>,message,cn-&gt;<a class="code" href="classircd__connector.html#a2">GetServerName</a>().c_str());
372 00365 
373 00366                 <span class="keywordflow">if</span> (cn-&gt;<a class="code" href="classircd__connector.html#a6">GetState</a>() == <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>)
374 00367                 {
375 00368                         <span class="comment">// fix: can only route one hop to avoid a loop</span>
376 00369                         <span class="keywordflow">if</span> (strncmp(message,<span class="stringliteral">"R "</span>,2))
377 00370                         {
378 00371                                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Not a double reroute"</span>);
379 00372                                 <span class="comment">// this route is down, we must re-route the packet through an available point in the mesh.</span>
380 00373                                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k = 0; k &lt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.size(); k++)
381 00374                                 {
382 00375                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Check connector %d: %s"</span>,k,this-&gt;connectors[k].GetServerName().c_str());
383 00376                                         <span class="comment">// search for another point in the mesh which can 'reach' where we want to go</span>
384 00377                                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> m = 0; m &lt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[k].routes.size(); m++)
385 00378                                         {
386 00379                                                 <span class="keywordflow">if</span> (!strcasecmp(this-&gt;connectors[k].routes[m].c_str(),sendhost))
387 00380                                                 {
388 00381                                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Found alternative route for packet: %s"</span>,this-&gt;connectors[k].GetServerName().c_str());
389 00382                                                         <span class="keywordtype">char</span> buffer[MAXBUF];
390 00383                                                         snprintf(buffer,MAXBUF,<span class="stringliteral">"R %s %s"</span>,sendhost,message);
391 00384                                                         this-&gt;<a class="code" href="classserverrec.html#a7">SendPacket</a>(buffer,this-&gt;connectors[k].GetServerName().c_str());
392 00385                                                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
393 00386                                                 }
394 00387                                         }
395 00388                                 }
396 00389                         }
397 00390                         <span class="keywordtype">char</span> buffer[MAXBUF];
398 00391                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,sendhost);
399 00392                         WriteOpers(<span class="stringliteral">"*** All connections to %s lost."</span>,sendhost);
400 00393                         NetSendToAllExcept(sendhost,buffer);
401 00394                         DoSplit(sendhost);
402 00395                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
403 00396                 }
404 00397 
405 00398                 <span class="comment">// returns false if the packet could not be sent (e.g. target host down)</span>
406 00399                 <span class="keywordflow">if</span> (!cn-&gt;<a class="code" href="classircd__connector.html#a21">AddWriteBuf</a>(message))
407 00400                 {
408 00401                         <span class="comment">// if we're here, there was an error pending, and the send cannot proceed</span>
409 00402                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"cn-&gt;AddWriteBuf() failed for serverrec::SendPacket(): %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a24">GetWriteError</a>().c_str());
410 00403                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Disabling connector: %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a2">GetServerName</a>().c_str());
411 00404                         cn-&gt;<a class="code" href="classircd__connector.html#a14">CloseConnection</a>();
412 00405                         cn-&gt;<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
413 00406                         WriteOpers(<span class="stringliteral">"*** Lost single connection to %s, link inactive and retrying: %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a2">GetServerName</a>().c_str(),cn-&gt;<a class="code" href="classircd__connector.html#a24">GetWriteError</a>().c_str());
414 00407                         <span class="comment">// retry the packet along a new route so either arrival OR failure are gauranteed (bugfix)</span>
415 00408                         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classserverrec.html#a7">SendPacket</a>(message,sendhost);
416 00409                 }
417 00410                 <span class="keywordflow">if</span> (!cn-&gt;<a class="code" href="classircd__connector.html#a22">FlushWriteBuf</a>())
418 00411                 {
419 00412                         <span class="comment">// if we're here the write() caused an error, we cannot proceed</span>
420 00413                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"cn-&gt;FlushWriteBuf() failed for serverrec::SendPacket(): %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a24">GetWriteError</a>().c_str());
421 00414                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Disabling connector: %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a2">GetServerName</a>().c_str());
422 00415                         cn-&gt;<a class="code" href="classircd__connector.html#a14">CloseConnection</a>();
423 00416                         cn-&gt;<a class="code" href="classircd__connector.html#a7">SetState</a>(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
424 00417                         WriteOpers(<span class="stringliteral">"*** Lost single connection to %s, link inactive and retrying: %s"</span>,cn-&gt;<a class="code" href="classircd__connector.html#a2">GetServerName</a>().c_str(),cn-&gt;<a class="code" href="classircd__connector.html#a24">GetWriteError</a>().c_str());
425 00418                         <span class="comment">// retry the packet along a new route so either arrival OR failure are gauranteed</span>
426 00419                         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classserverrec.html#a7">SendPacket</a>(message,sendhost);
427 00420                 }
428 00421                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
429 00422         }
430 00423 }
431 00424 
432 <a name="l00425"></a><a class="code" href="servers_8cpp.html#a6">00425</a> <span class="keywordtype">bool</span> <a class="code" href="servers_8cpp.html#a6">already_have_sum</a>(std::string sum)
433 00426 {
434 00427         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="servers_8cpp.html#a4">xsums</a>.size(); i++)
435 00428         {
436 00429                 <span class="keywordflow">if</span> (<a class="code" href="servers_8cpp.html#a4">xsums</a>[i] == sum)
437 00430                 {
438 00431                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
439 00432                 }
440 00433         }
441 00434         <span class="keywordflow">if</span> (<a class="code" href="servers_8cpp.html#a4">xsums</a>.size() &gt;= 128)
442 00435         {
443 00436                 <a class="code" href="servers_8cpp.html#a4">xsums</a>.pop_front();
444 00437         }
445 00438         <a class="code" href="servers_8cpp.html#a4">xsums</a>.push_back(sum);
446 00439         <span class="keywordflow">return</span> <span class="keyword">false</span>;
447 00440 }
448 00441 
449 00442 <span class="comment">// receives a packet from any where there is data waiting, first come, first served</span>
450 00443 <span class="comment">// fills the message and host values with the host where the data came from.</span>
451 00444 
452 <a name="l00445"></a><a class="code" href="classserverrec.html#a8">00445</a> <span class="keywordtype">bool</span> <a class="code" href="classserverrec.html#a8">serverrec::RecvPacket</a>(std::deque&lt;std::string&gt; &amp;messages, <span class="keywordtype">char</span>* recvhost,std::deque&lt;std::string&gt; &amp;sums)
453 00446 {
454 00447         <span class="keywordtype">char</span> data[65536],buffer[MAXBUF];
455 00448         memset(data, 0, 65536);
456 00449         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>.size(); i++)
457 00450         {
458 00451                 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetState() != <a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>)
459 00452                 {
460 00453                         <span class="comment">// returns false if the packet could not be sent (e.g. target host down)</span>
461 00454                         <span class="keywordtype">int</span> rcvsize = 0;
462 00455 
463 00456                         <span class="comment">// check if theres any data on this socket</span>
464 00457                         <span class="comment">// if not, continue onwards to the next.</span>
465 00458                         pollfd polls;
466 00459                         polls.fd = this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetDescriptor();
467 00460                         polls.events = POLLIN;
468 00461                         <span class="keywordtype">int</span> ret = poll(&amp;polls,1,1);
469 00462                         <span class="keywordflow">if</span> (ret &lt;= 0) <span class="keywordflow">continue</span>;
470 00463 
471 00464                         rcvsize = recv(this-&gt;connectors[i].GetDescriptor(),data,65000,0);
472 00465                         data[rcvsize] = <span class="charliteral">'\0'</span>;
473 00466                         <span class="keywordflow">if</span> (rcvsize == 0)
474 00467                         {
475 00468                                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"recv() failed for serverrec::RecvPacket(): EOF"</span>);
476 00469                                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Disabling connector: %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
477 00470                                 this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].CloseConnection();
478 00471                                 this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
479 00472                                 <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
480 00473                                 {
481 00474                                         WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting (EOF)"</span>,this-&gt;connectors[i].GetServerName().c_str());
482 00475                                         snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
483 00476                                         NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
484 00477                                         DoSplit(this-&gt;connectors[i].GetServerName().c_str());
485 00478                                 }
486 00479                                 <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
487 00480                         }
488 00481                         <span class="keywordflow">if</span> (rcvsize == -1)
489 00482                         {
490 00483                                 <span class="keywordflow">if</span> (errno != EAGAIN)
491 00484                                 {
492 00485                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"recv() failed for serverrec::RecvPacket(): %s"</span>,strerror(errno));
493 00486                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Disabling connector: %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
494 00487                                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].CloseConnection();
495 00488                                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
496 00489                                         <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
497 00490                                         {
498 00491                                                 WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting."</span>,this-&gt;connectors[i].GetServerName().c_str());
499 00492                                                 snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
500 00493                                                 NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
501 00494                                                 DoSplit(this-&gt;connectors[i].GetServerName().c_str());
502 00495                                         }
503 00496                                         <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
504 00497                                 }
505 00498                         }
506 00499                         <span class="keywordtype">int</span> pushed = 0;
507 00500                         <span class="keywordflow">if</span> (rcvsize &gt; 0)
508 00501                         {
509 00502                                 <span class="keywordflow">if</span> (!this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].AddBuffer(data))
510 00503                                 {
511 00504                                         WriteOpers(<span class="stringliteral">"*** Read buffer for %s exceeds maximum, closing connection!"</span>,this-&gt;connectors[i].GetServerName().c_str());
512 00505                                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].CloseConnection();
513 00506                                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].SetState(<a class="code" href="connection_8h.html#a0">STATE_DISCONNECTED</a>);
514 00507                                         <span class="keywordflow">if</span> (!<a class="code" href="servers_8cpp.html#a5">IsRoutable</a>(this-&gt;connectors[i].GetServerName()))
515 00508                                         {
516 00509                                                 WriteOpers(<span class="stringliteral">"*** Server %s is no longer routable, disconnecting."</span>,this-&gt;connectors[i].GetServerName().c_str());
517 00510                                                 snprintf(buffer,MAXBUF,<span class="stringliteral">"&amp; %s"</span>,this-&gt;connectors[i].GetServerName().c_str());
518 00511                                                 NetSendToAllExcept(this-&gt;connectors[i].GetServerName().c_str(),buffer);
519 00512                                                 DoSplit(this-&gt;connectors[i].GetServerName().c_str());
520 00513                                         }
521 00514                                         <a class="code" href="servers_8cpp.html#a3">has_been_netsplit</a> = <span class="keyword">true</span>;
522 00515                                 }
523 00516                                 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].BufferIsComplete())
524 00517                                 {
525 00518                                         this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].ResetPing();
526 00519                                         <span class="keywordflow">while</span> (this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].BufferIsComplete())
527 00520                                         {
528 00521                                                 std::string text = this-&gt;<a class="code" href="classserverrec.html#o11">connectors</a>[i].GetBuffer();
529 00522                                                 <span class="keywordflow">if</span> (text != <span class="stringliteral">""</span>)
530 00523                                                 {
531 00524                                                         <span class="keywordflow">if</span> ((text[0] == <span class="charliteral">':'</span>) &amp;&amp; (text.find(<span class="stringliteral">" "</span>) != std::string::npos))
532 00525                                                         {
533 00526                                                                 std::string orig = text;
534 00527                                                                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Original: %s"</span>,text.c_str());
535 00528                                                                 std::string sum = text.substr(1,text.find(<span class="stringliteral">" "</span>)-1);
536 00529                                                                 text = text.substr(text.find(<span class="stringliteral">" "</span>)+1,text.length());
537 00530                                                                 std::string possible_token = text.substr(1,text.find(<span class="stringliteral">" "</span>)-1);
538 00531                                                                 <span class="keywordflow">if</span> (possible_token.length() &gt; 1)
539 00532                                                                 {
540 00533                                                                         sums.push_back(<span class="stringliteral">"*"</span>);
541 00534                                                                         text = orig;
542 00535                                                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Non-mesh, non-tokenized string passed up the chain"</span>);
543 00536                                                                 }
544 00537                                                                 <span class="keywordflow">else</span>
545 00538                                                                 {
546 00539                                                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Packet sum: '%s'"</span>,sum.c_str());
547 00540                                                                         <span class="keywordflow">if</span> ((<a class="code" href="servers_8cpp.html#a6">already_have_sum</a>(sum)) &amp;&amp; (sum != <span class="stringliteral">"*"</span>))
548 00541                                                                         {
549 00542                                                                                 <span class="comment">// we don't accept dupes</span>
550 00543                                                                                 <span class="keywordflow">continue</span>;
551 00544                                                                         }
552 00545                                                                         sums.push_back(sum.c_str());
553 00546                                                                 }
554 00547                                                         }
555 00548                                                         <span class="keywordflow">else</span> sums.push_back(<span class="stringliteral">"*"</span>);
556 00549                                                         messages.push_back(text.c_str());
557 00550                                                         strlcpy(recvhost,this-&gt;connectors[i].GetServerName().c_str(),160);
558 00551                                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"serverrec::RecvPacket() %d:%s-&gt;%s"</span>,pushed++,recvhost,text.c_str());
559 00552                                                 }
560 00553                                         }
561 00554                                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
562 00555                                 }
563 00556                         }
564 00557                 }
565 00558         }
566 00559         <span class="comment">// nothing new yet -- message and host will be undefined</span>
567 00560         <span class="keywordflow">return</span> <span class="keyword">false</span>;
568 00561 }
569 00562 
570 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon May 30 05:15:21 2005 for InspIRCd by
571 <a href="http://www.doxygen.org/index.html">
572 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
573 </a>1.3.3 </small></address>
574 </body>
575 </html>