summaryrefslogtreecommitdiff
path: root/docs/man/man3/ircd_connector.3
blob: 6bd266f7b2f0deded838273e8d61d1e0daa32d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
.TH "ircd_connector" 3 "25 May 2005" "InspIRCd" \" -*- nroff -*-
.ad l
.nh
.SH NAME
ircd_connector \- Each connection has one or more of these each represents ONE outbound connection to another ircd so each inbound has multiple outbounds.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <connection.h>\fP
.PP
Inherits \fBExtensible\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBircd_connector\fP ()"
.br
.RI "\fIConstructor clears the sendq and initialises the fd to -1. \fP"
.ti -1c
.RI "bool \fBMakeOutboundConnection\fP (char *newhost, int newport)"
.br
.RI "\fICreate an outbound connection to a listening socket. \fP"
.ti -1c
.RI "std::string \fBGetServerName\fP ()"
.br
.RI "\fIReturn the servername on this established connection. \fP"
.ti -1c
.RI "void \fBSetServerName\fP (std::string serv)"
.br
.RI "\fISet the server name of this connection. \fP"
.ti -1c
.RI "int \fBGetDescriptor\fP ()"
.br
.RI "\fIGet the file descriptor associated with this connection. \fP"
.ti -1c
.RI "void \fBSetDescriptor\fP (int \fBfd\fP)"
.br
.RI "\fISet the file descriptor for this connection. \fP"
.ti -1c
.RI "int \fBGetState\fP ()"
.br
.RI "\fIGet the state flags for this connection. \fP"
.ti -1c
.RI "void \fBSetState\fP (int \fBstate\fP)"
.br
.RI "\fISet the state flags for this connection. \fP"
.ti -1c
.RI "char * \fBGetServerIP\fP ()"
.br
.RI "\fIGet the ip address (not servername) associated with this connection. \fP"
.ti -1c
.RI "std::string \fBGetDescription\fP ()"
.br
.RI "\fIGet the server description of this connection. \fP"
.ti -1c
.RI "void \fBSetDescription\fP (std::string desc)"
.br
.RI "\fISet the server description of this connection. \fP"
.ti -1c
.RI "int \fBGetServerPort\fP ()"
.br
.RI "\fIGet the port number being used for this connection If the connection is outbound this will be the remote port otherwise it will be the local port, so it can always be gautanteed as open at the address given in \fBGetServerIP()\fP. \fP"
.ti -1c
.RI "void \fBSetServerPort\fP (int p)"
.br
.RI "\fISet the port used by this connection. \fP"
.ti -1c
.RI "bool \fBSetHostAndPort\fP (char *newhost, int newport)"
.br
.RI "\fISet both the host and the port in one operation for this connection. \fP"
.ti -1c
.RI "void \fBCloseConnection\fP ()"
.br
.RI "\fIClose the connection by calling close() on its file descriptor This function call updates no other data. \fP"
.ti -1c
.RI "bool \fBAddBuffer\fP (std::string a)"
.br
.RI "\fIThis method adds text to the ircd connection's buffer. \fP"
.ti -1c
.RI "bool \fBBufferIsComplete\fP ()"
.br
.RI "\fIThis method returns true if the buffer contains at least one carriage return character, e.g. \fP"
.ti -1c
.RI "void \fBClearBuffer\fP ()"
.br
.RI "\fIThis method clears the server's buffer by setting it to an empty string. \fP"
.ti -1c
.RI "std::string \fBGetBuffer\fP ()"
.br
.RI "\fIThis method retrieves the first string from the tail end of the buffer and advances the tail end of the buffer past the returned string, in a similar manner to strtok(). \fP"
.ti -1c
.RI "void \fBSetVersionString\fP (std::string newversion)"
.br
.RI "\fIThis method sets the version string of the remote server. \fP"
.ti -1c
.RI "std::string \fBGetVersionString\fP ()"
.br
.RI "\fIThis method returns the version string of the remote server. \fP"
.ti -1c
.RI "bool \fBAddWriteBuf\fP (std::string data)"
.br
.RI "\fIAdds data to the connection's sendQ to be flushed later. \fP"
.ti -1c
.RI "bool \fBFlushWriteBuf\fP ()"
.br
.RI "\fIFlushes as much of the data from the buffer as possible, and advances the queue pointer to what is left. \fP"
.ti -1c
.RI "void \fBSetWriteError\fP (std::string error)"
.br
.RI "\fISets the error string for this connection. \fP"
.ti -1c
.RI "std::string \fBGetWriteError\fP ()"
.br
.RI "\fIGets the error string for this connection. \fP"
.ti -1c
.RI "bool \fBHasBufferedOutput\fP ()"
.br
.RI "\fIReturns true if there is data to be written that hasn't been sent yet. \fP"
.ti -1c
.RI "bool \fBCheckPing\fP ()"
.br
.RI "\fIChecks if the connection replied to its last ping, and if it did sends another and returns true, if not, returns false. \fP"
.ti -1c
.RI "void \fBResetPing\fP ()"
.br
.RI "\fIResets the ping counter. \fP"
.in -1c
.SS "Public Attributes"

.in +1c
.ti -1c
.RI "std::string \fBircdbuffer\fP"
.br
.RI "\fIIRCD Buffer for input characters, holds as many lines as are pending - Note that the final line may not be complete and should only be read when there is a 
.br
 seperator. \fP"
.ti -1c
.RI "char \fBhost\fP [MAXBUF]"
.br
.RI "\fIWhen MakeOutboundConnection is called, these public members are filled with the details passed to the function, for future reference. \fP"
.ti -1c
.RI "int \fBport\fP"
.br
.RI "\fIWhen MakeOutboundConnection is called, these public members are filled with the details passed to the function, for future reference. \fP"
.ti -1c
.RI "std::vector< std::string > \fBroutes\fP"
.br
.RI "\fI\fBServer\fP names of servers that this server is linked to So for A->B->C, if this was the record for B it would contain A and C whilever both servers are connected to B. \fP"
.in -1c
.SS "Private Member Functions"

.in +1c
.ti -1c
.RI "bool \fBSetHostAddress\fP (char *\fBhost\fP, int \fBport\fP)"
.br
.RI "\fIPRIVATE function to set the host address and port to connect to. \fP"
.in -1c
.SS "Private Attributes"

.in +1c
.ti -1c
.RI "sockaddr_in \fBaddr\fP"
.br
.RI "\fISockaddr of the outbound ip and port. \fP"
.ti -1c
.RI "int \fBfd\fP"
.br
.RI "\fIFile descriptor of the connection. \fP"
.ti -1c
.RI "std::string \fBservername\fP"
.br
.RI "\fI\fBServer\fP name. \fP"
.ti -1c
.RI "std::string \fBdescription\fP"
.br
.RI "\fI\fBServer\fP 'GECOS'. \fP"
.ti -1c
.RI "char \fBstate\fP"
.br
.RI "\fIState. \fP"
.ti -1c
.RI "std::string \fBversion\fP"
.br
.RI "\fIThis string holds the ircd's version response. \fP"
.ti -1c
.RI "std::string \fBsendq\fP"
.br
.RI "\fISendQ of the outbound connector, does not have a limit. \fP"
.ti -1c
.RI "std::string \fBWriteError\fP"
.br
.RI "\fIWrite error of connection. \fP"
.ti -1c
.RI "time_t \fBnextping\fP"
.br
.RI "\fITime this connection was last pinged. \fP"
.ti -1c
.RI "bool \fBreplied\fP"
.br
.RI "\fIDid this connection reply to its last ping? \fP"
.in -1c
.SH "Detailed Description"
.PP 
Each connection has one or more of these each represents ONE outbound connection to another ircd so each inbound has multiple outbounds. 

A listening socket that accepts server type connections is represented by one class serverrec. Class serverrec will instantiate several objects of type ircd_connector to represent each established connection, inbound or outbound. So, to determine all linked servers you must walk through all the serverrecs that the core defines, and in each one iterate through until you find connection(s) relating to the server you want information on. The core and module API provide functions for this. 
.PP
Definition at line 56 of file connection.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "ircd_connector::ircd_connector ()"
.PP
Constructor clears the sendq and initialises the fd to -1. 
.SH "Member Function Documentation"
.PP 
.SS "bool ircd_connector::AddBuffer (std::string a)"
.PP
This method adds text to the ircd connection's buffer. \fBParameters:\fP
.RS 4
\fIa\fP The text to add to the buffer up to a maximum size of 1MB
.RE
.PP
This buffer's maximum size is one megabyte, the method returning false if the buffer is full.
.PP
\fBReturns:\fP
.RS 4
True on success, false if the buffer is full or the connection is down
.RE
.PP

.SS "bool ircd_connector::AddWriteBuf (std::string data)"
.PP
Adds data to the connection's sendQ to be flushed later. \fBParameters:\fP
.RS 4
\fIdata\fP The data to add to the write buffer
.RE
.PP
Fails if there is an error pending on the connection.
.PP
\fBReturns:\fP
.RS 4
True on success, false if the connection is down or the buffer is full
.RE
.PP
Referenced by serverrec::SendPacket().
.SS "bool ircd_connector::BufferIsComplete ()"
.PP
This method returns true if the buffer contains at least one carriage return character, e.g. one line can be read from the buffer successfully.
.PP
\fBReturns:\fP
.RS 4
True if there is at least one complete line waiting to be processed
.RE
.PP

.SS "bool ircd_connector::CheckPing ()"
.PP
Checks if the connection replied to its last ping, and if it did sends another and returns true, if not, returns false. \fBReturns:\fP
.RS 4
True if the server is still replying to pings
.RE
.PP

.SS "void ircd_connector::ClearBuffer ()"
.PP
This method clears the server's buffer by setting it to an empty string. 
.SS "void ircd_connector::CloseConnection ()"
.PP
Close the connection by calling close() on its file descriptor This function call updates no other data. Referenced by serverrec::SendPacket().
.SS "bool ircd_connector::FlushWriteBuf ()"
.PP
Flushes as much of the data from the buffer as possible, and advances the queue pointer to what is left. \fBReturns:\fP
.RS 4
True if the flush succeeded, false if the connection is down
.RE
.PP
Referenced by serverrec::SendPacket().
.SS "std::string ircd_connector::GetBuffer ()"
.PP
This method retrieves the first string from the tail end of the buffer and advances the tail end of the buffer past the returned string, in a similar manner to strtok(). \fBReturns:\fP
.RS 4
The first line of the buffer up to a carriage return
.RE
.PP

.SS "std::string ircd_connector::GetDescription ()"
.PP
Get the server description of this connection. \fBReturns:\fP
.RS 4
The description (GECOS) of this connection
.RE
.PP

.SS "int ircd_connector::GetDescriptor ()"
.PP
Get the file descriptor associated with this connection. \fBReturns:\fP
.RS 4
The file descriptor associated with this connection
.RE
.PP

.SS "char* ircd_connector::GetServerIP ()"
.PP
Get the ip address (not servername) associated with this connection. \fBReturns:\fP
.RS 4
The connections IP address in dotted decimal form
.RE
.PP

.SS "std::string ircd_connector::GetServerName ()"
.PP
Return the servername on this established connection. Referenced by serverrec::SendPacket().
.SS "int ircd_connector::GetServerPort ()"
.PP
Get the port number being used for this connection If the connection is outbound this will be the remote port otherwise it will be the local port, so it can always be gautanteed as open at the address given in \fBGetServerIP()\fP. \fBReturns:\fP
.RS 4
The port number of this connection
.RE
.PP

.SS "int ircd_connector::GetState ()"
.PP
Get the state flags for this connection. \fBReturns:\fP
.RS 4
The state flags associated with this connection
.RE
.PP
Referenced by IsRoutable(), and serverrec::SendPacket().
.SS "std::string ircd_connector::GetVersionString ()"
.PP
This method returns the version string of the remote server. If the server has no version string an empty string is returned.
.PP
\fBReturns:\fP
.RS 4
The version text of this connection
.RE
.PP

.SS "std::string ircd_connector::GetWriteError ()"
.PP
Gets the error string for this connection. \fBReturns:\fP
.RS 4
The last error to occur or an empty string
.RE
.PP
Referenced by serverrec::SendPacket().
.SS "bool ircd_connector::HasBufferedOutput ()"
.PP
Returns true if there is data to be written that hasn't been sent yet. \fBReturns:\fP
.RS 4
True if the buffer is not empty
.RE
.PP

.SS "bool ircd_connector::MakeOutboundConnection (char * newhost, int newport)"
.PP
Create an outbound connection to a listening socket. Referenced by serverrec::BeginLink(), and serverrec::MeshCookie().
.SS "void ircd_connector::ResetPing ()"
.PP
Resets the ping counter. 
.SS "void ircd_connector::SetDescription (std::string desc)"
.PP
Set the server description of this connection. \fBParameters:\fP
.RS 4
\fIdesc\fP The description (GECOS) of this connection to be set
.RE
.PP

.SS "void ircd_connector::SetDescriptor (int fd)"
.PP
Set the file descriptor for this connection. \fBParameters:\fP
.RS 4
\fIfd\fP The file descriptor to associate with the connection
.RE
.PP
Referenced by serverrec::AddIncoming().
.SS "bool ircd_connector::SetHostAddress (char * host, int port)\fC [private]\fP"
.PP
PRIVATE function to set the host address and port to connect to. 
.SS "bool ircd_connector::SetHostAndPort (char * newhost, int newport)"
.PP
Set both the host and the port in one operation for this connection. \fBParameters:\fP
.RS 4
\fInewhost\fP The hostname to set for this connection 
.br
\fInewport\fP The port number to set for this connection 
.RE
.PP
\fBReturns:\fP
.RS 4
True on success, false on failure
.RE
.PP
Referenced by serverrec::AddIncoming(), serverrec::BeginLink(), and serverrec::MeshCookie().
.SS "void ircd_connector::SetServerName (std::string serv)"
.PP
Set the server name of this connection. \fBParameters:\fP
.RS 4
\fIserv\fP The server name to set
.RE
.PP
Referenced by serverrec::AddIncoming(), serverrec::BeginLink(), and serverrec::MeshCookie().
.SS "void ircd_connector::SetServerPort (int p)"
.PP
Set the port used by this connection. \fBParameters:\fP
.RS 4
\fIp\fP The port number to set for this connection
.RE
.PP

.SS "void ircd_connector::SetState (int state)"
.PP
Set the state flags for this connection. \fBParameters:\fP
.RS 4
\fIstate\fP The state flags to set for this connection
.RE
.PP
Referenced by serverrec::AddIncoming(), serverrec::BeginLink(), serverrec::MeshCookie(), and serverrec::SendPacket().
.SS "void ircd_connector::SetVersionString (std::string newversion)"
.PP
This method sets the version string of the remote server. \fBParameters:\fP
.RS 4
\fInewversion\fP The version string to set
.RE
.PP

.SS "void ircd_connector::SetWriteError (std::string error)"
.PP
Sets the error string for this connection. \fBParameters:\fP
.RS 4
\fIerror\fP The error string to set
.RE
.PP

.SH "Member Data Documentation"
.PP 
.SS "sockaddr_in \fBircd_connector::addr\fP\fC [private]\fP"
.PP
Sockaddr of the outbound ip and port. Definition at line 61 of file connection.h.
.SS "std::string \fBircd_connector::description\fP\fC [private]\fP"
.PP
\fBServer\fP 'GECOS'. Definition at line 73 of file connection.h.
.SS "int \fBircd_connector::fd\fP\fC [private]\fP"
.PP
File descriptor of the connection. Definition at line 65 of file connection.h.
.SS "char \fBircd_connector::host\fP[MAXBUF]"
.PP
When MakeOutboundConnection is called, these public members are filled with the details passed to the function, for future reference. Definition at line 117 of file connection.h.
.SS "std::string \fBircd_connector::ircdbuffer\fP"
.PP
IRCD Buffer for input characters, holds as many lines as are pending - Note that the final line may not be complete and should only be read when there is a 
.br
 seperator. Definition at line 110 of file connection.h.
.SS "time_t \fBircd_connector::nextping\fP\fC [private]\fP"
.PP
Time this connection was last pinged. Definition at line 98 of file connection.h.
.SS "int \fBircd_connector::port\fP"
.PP
When MakeOutboundConnection is called, these public members are filled with the details passed to the function, for future reference. Definition at line 123 of file connection.h.
.SS "bool \fBircd_connector::replied\fP\fC [private]\fP"
.PP
Did this connection reply to its last ping? Definition at line 102 of file connection.h.
.SS "std::vector<std::string> \fBircd_connector::routes\fP"
.PP
\fBServer\fP names of servers that this server is linked to So for A->B->C, if this was the record for B it would contain A and C whilever both servers are connected to B. Definition at line 129 of file connection.h.
.SS "std::string \fBircd_connector::sendq\fP\fC [private]\fP"
.PP
SendQ of the outbound connector, does not have a limit. Definition at line 90 of file connection.h.
.SS "std::string \fBircd_connector::servername\fP\fC [private]\fP"
.PP
\fBServer\fP name. Definition at line 69 of file connection.h.
.SS "char \fBircd_connector::state\fP\fC [private]\fP"
.PP
State. STATE_NOAUTH_INBOUND, STATE_NOAUTH_OUTBOUND STATE_SYNC, STATE_DISCONNECTED, STATE_CONNECTEDDefinition at line 78 of file connection.h.
.SS "std::string \fBircd_connector::version\fP\fC [private]\fP"
.PP
This string holds the ircd's version response. Definition at line 86 of file connection.h.
.SS "std::string \fBircd_connector::WriteError\fP\fC [private]\fP"
.PP
Write error of connection. Definition at line 94 of file connection.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for InspIRCd from the source code.