ident 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,2 @@
1
+ ident is a simple Ruby library for querying identd servers (RFC 1413).
2
+ For usage see the documentation and and the examples.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'rake/gempackagetask'
2
+ require 'yard'
3
+
4
+ VERSION = "0.0.1"
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = "ident"
8
+ s.summary = "A Ruby library for querying identd servers (RFC 1413)"
9
+ s.description = s.summary
10
+ s.version = VERSION
11
+ s.author = "Dominik Honnef"
12
+ s.email = "dominikho@gmx.net"
13
+ s.date = Time.now.strftime "%Y-%m-%d"
14
+ s.require_path = "lib"
15
+ s.homepage = "http://dominikh.fork-bomb.de"
16
+ s.platform = Gem::Platform::RUBY
17
+ s.rubyforge_project = "ident"
18
+
19
+ s.files = FileList["lib/**/*.rb", "[A-Z]*", "doc/**/*", "examples/**/*"].to_a
20
+ end
21
+
22
+ Rake::GemPackageTask.new(spec)do |pkg|
23
+ end
24
+
25
+ YARD::Rake::YardocTask.new do |t|
26
+ end
27
+
data/doc/Ident.html ADDED
@@ -0,0 +1,552 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
7
+ <link rel="stylesheet" href="custom.css" type="text/css" charset="utf-8" />
8
+ <link rel="stylesheet" href="syntax_highlight.css" type="text/css" charset="utf-8" />
9
+
10
+ <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
11
+ <script src="app.js" type="text/javascript" charset="utf-8"></script>
12
+ <title>Class: Ident</title>
13
+ </head>
14
+ <body>
15
+ <div id="content">
16
+ <div class="section class Ident">
17
+ <h1 class="title">Class: Ident</h1>
18
+ <div class="section attributes">
19
+ <h1>Attributes</h1>
20
+
21
+
22
+ <div class="instance">
23
+ <h2>Instance Attributes</h2>
24
+ <table>
25
+
26
+
27
+ <tr class="">
28
+ <th class='signature'>
29
+ <span class='name'>inbound</span>
30
+ </td>
31
+ <td class="readwrite">
32
+ [<span id='inbound-instance_method'>R</span><span id='inbound=-instance_method'>W</span>]
33
+ </td>
34
+ <td class="visibility">
35
+ public
36
+ </td>
37
+ <td class="docstring">
38
+ <p>
39
+ Returns the value of attribute <tt>inbound</tt>.
40
+ </p>
41
+
42
+
43
+ </td>
44
+ </tr>
45
+
46
+
47
+
48
+ <tr class="">
49
+ <th class='signature'>
50
+ <span class='name'>ip</span>
51
+ </td>
52
+ <td class="readwrite">
53
+ [<span id='ip-instance_method'>R</span><span id='ip=-instance_method'>W</span>]
54
+ </td>
55
+ <td class="visibility">
56
+ public
57
+ </td>
58
+ <td class="docstring">
59
+ <p>
60
+ Returns the value of attribute <tt>ip</tt>.
61
+ </p>
62
+
63
+
64
+ </td>
65
+ </tr>
66
+
67
+
68
+
69
+ <tr class="">
70
+ <th class='signature'>
71
+ <span class='name'>outbound</span>
72
+ </td>
73
+ <td class="readwrite">
74
+ [<span id='outbound-instance_method'>R</span><span id='outbound=-instance_method'>W</span>]
75
+ </td>
76
+ <td class="visibility">
77
+ public
78
+ </td>
79
+ <td class="docstring">
80
+ <p>
81
+ Returns the value of attribute <tt>outbound</tt>.
82
+ </p>
83
+
84
+
85
+ </td>
86
+ </tr>
87
+
88
+
89
+
90
+ <tr class="">
91
+ <th class='signature'>
92
+ <span class='name'>response</span>
93
+ </td>
94
+ <td class="readwrite">
95
+ [<span id='response-instance_method'>R</span>]
96
+ </td>
97
+ <td class="visibility">
98
+ public
99
+ </td>
100
+ <td class="docstring">
101
+ <p>
102
+ Returns the value of attribute <tt>response</tt>.
103
+ </p>
104
+
105
+
106
+ </td>
107
+ </tr>
108
+
109
+
110
+
111
+ <tr class="">
112
+ <th class='signature'>
113
+ <span class='name'>timeout</span>
114
+ </td>
115
+ <td class="readwrite">
116
+ [<span id='timeout-instance_method'>R</span><span id='timeout=-instance_method'>W</span>]
117
+ </td>
118
+ <td class="visibility">
119
+ public
120
+ </td>
121
+ <td class="docstring">
122
+ <p>
123
+ Returns the value of attribute <tt>timeout</tt>.
124
+ </p>
125
+
126
+
127
+ </td>
128
+ </tr>
129
+
130
+
131
+ </table>
132
+ </div>
133
+
134
+ </div>
135
+ <div class="section constants">
136
+ <div class="thisclass">
137
+ <h1>Constants</h1>
138
+ <dl>
139
+
140
+ <dt id="KNOWN_ERRORS-constant">KNOWN_ERRORS</dt>
141
+ <dd>[&quot;INVALID-PORT&quot; &quot;NO-USER&quot; &quot;HIDDEN-USER&quot; &quot;UNKNOWN-ERROR&quot;]</dd>
142
+
143
+ </dl>
144
+ </div>
145
+
146
+ </div><div class="section constructor">
147
+ <h1>Constructor Summary</h1>
148
+ <div id="initialize-instance_method" class="section method">
149
+ <div class="details_title">
150
+ <div class='section methodsignature'>
151
+ <tt class='def'>
152
+ <span class='visibility'>public</span>
153
+ <span class='return_types'></span>
154
+ <span class='name'>initialize</span><span class='args'>(ip = nil, outbound = nil, inbound = nil, timeout = 10)</span>
155
+ <span class='block'></span>
156
+ </tt>
157
+ </div>
158
+
159
+ </div><div class="section tags">
160
+ <h2>Meta Tags</h2>
161
+ <div class="see">
162
+ <h3>See Also:</h3>
163
+ <dl>
164
+ <dt></dt>
165
+ <dd>
166
+ <span class='desc'>
167
+ <tt><a href="#request-class_method" title="Ident.request">Ident.request</a></tt>
168
+ </span>
169
+ </dd>
170
+ </dl>
171
+ </div>
172
+
173
+ </div><div class="section source">
174
+ <span>[<a class="source_link" href="#">View source</a>]</span>
175
+ <div class="source_code">
176
+ <table>
177
+ <tr>
178
+ <td>
179
+ <pre class="lines">
180
+
181
+
182
+ 86
183
+ 87
184
+ 88
185
+ 89</pre>
186
+ </td>
187
+ <td>
188
+ <pre class="code"><span class="info file"># File 'lib/ident.rb', line 86</span>
189
+
190
+ <span class='kw'>def</span> <span class='id initialize'>initialize</span><span class='lparen'>(</span><span class='id ip'>ip</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id outbound'>outbound</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id inbound'>inbound</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id timeout'>timeout</span> <span class='op'>=</span> <span class='int'>10</span><span class='rparen'>)</span>
191
+ <span class='ivar'>@ip</span><span class='comma'>,</span> <span class='ivar'>@outbound</span><span class='comma'>,</span> <span class='ivar'>@inbound</span><span class='comma'>,</span> <span class='ivar'>@timeout</span> <span class='op'>=</span> <span class='id ip'>ip</span><span class='comma'>,</span> <span class='id outbound'>outbound</span><span class='comma'>,</span> <span class='id inbound'>inbound</span><span class='comma'>,</span> <span class='id timeout'>timeout</span>
192
+ <span class='ivar'>@response</span> <span class='op'>=</span> <span class='kw'>nil</span>
193
+ <span class='kw'>end</span></pre>
194
+ </td>
195
+ </tr>
196
+ </table>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div> <div class="section visibilitygroup public">
201
+ <h1>Public Visibility</h1>
202
+ <div class="section methodsummary class public">
203
+ <h1>Public Class Method Summary</h1>
204
+ <table class="summary">
205
+
206
+ <tr>
207
+ <th class="signature">
208
+
209
+ <span class='overload'>
210
+ <span class='name'><a href="#request-class_method" title="request">request</a></span><span class='args'>(ip, outbound, inbound, timeout_after = 10)</span>
211
+ <span class='block'></span>
212
+ </span>
213
+
214
+
215
+ </th>
216
+ <td class="docstring">
217
+ <p>
218
+ This method connects to an identd at `ip` and queries information for the
219
+ connection `outbound`->`inbound` where `outbound` is the port a connection
220
+ is coming from (usually anything >1024) and `inbound` is the port connected
221
+ to, the port your service is listening on (e.
222
+ </p>
223
+
224
+
225
+ <p class='returns'>
226
+ Returns:
227
+ <span class='return_types'>
228
+ <tt><a href="Ident/Response/USERID.html" title="Response::USERID">Response::USERID</a></tt>
229
+ </span>
230
+ </p>
231
+
232
+ </td>
233
+ </tr>
234
+
235
+ </table>
236
+
237
+ </div>
238
+ <div class="section methodsummary instance public">
239
+ <h1>Public Instance Method Summary</h1>
240
+ <table class="summary">
241
+
242
+ <tr>
243
+ <th class="signature">
244
+
245
+ <span class='overload'>
246
+ <span class='name'><a href="#request-instance_method" title="#request">#request</a></span><span class='args'></span>
247
+ <span class='block'></span>
248
+ </span>
249
+
250
+
251
+ </th>
252
+ <td class="docstring">
253
+
254
+
255
+ </td>
256
+ </tr>
257
+
258
+ </table>
259
+
260
+ </div>
261
+ <div class="section methoddetails class public">
262
+ <h1>Public Class Method Details</h1>
263
+
264
+ <div class="method">
265
+ <div class="method_header">
266
+ <h3>request</h3>
267
+ </div><div id="request-class_method" class="section method">
268
+ <div class="details_title">
269
+ <div class='section methodsignature'>
270
+ <tt class='def'>
271
+ <span class='visibility'>public</span>
272
+ <span class='return_types'><tt><a href="Ident/Response/USERID.html" title="Response::USERID">Response::USERID</a></tt></span>
273
+ <span class='name'>request</span><span class='args'>(ip, outbound, inbound, timeout_after = 10)</span>
274
+ <span class='block'></span>
275
+ </tt>
276
+ </div>
277
+
278
+ </div><div class="section docstring">
279
+ <p>
280
+ This method connects to an identd at `ip` and queries information for the
281
+ connection `outbound`->`inbound` where `outbound` is the port a connection
282
+ is coming from (usually anything >1024) and `inbound` is the port connected
283
+ to, the port your service is listening on (e.g. 6667 in the case of an
284
+ IRCd)
285
+ </p>
286
+
287
+ </div><div class="section tags">
288
+ <h2>Meta Tags</h2>
289
+ <div class="examples">
290
+
291
+ <h3>Example: <small>user A connects to our server on port 23, coming from 123.123.123.123 on port 6789</small></h3>
292
+ <div class="docstring">
293
+ <pre class="code"> <span class='const'>Ident</span><span class='period'>.</span><span class='id request'>request</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123.123.123.123</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='int'>6789</span><span class='comma'>,</span> <span class='int'>23</span><span class='rparen'>)</span></pre>
294
+ </div>
295
+
296
+ </div>
297
+ <div class="param">
298
+ <h3>Parameters:</h3>
299
+ <dl>
300
+
301
+
302
+ <dt>
303
+ <span class='type'>[<tt>String</tt>]</span>
304
+ <span class='name'>ip</span>
305
+
306
+ </dt>
307
+ <dd>
308
+ <span class='desc'><p>
309
+ The IP of the ident server
310
+ </p>
311
+ </span>
312
+ </dd>
313
+
314
+
315
+
316
+ <dt>
317
+ <span class='type'>[<tt>Integer</tt>]</span>
318
+ <span class='name'>outbound</span>
319
+
320
+ </dt>
321
+ <dd>
322
+ <span class='desc'><p>
323
+ The port from which the connection is coming
324
+ </p>
325
+ </span>
326
+ </dd>
327
+
328
+
329
+
330
+ <dt>
331
+ <span class='type'>[<tt>Integer</tt>]</span>
332
+ <span class='name'>inbound</span>
333
+
334
+ </dt>
335
+ <dd>
336
+ <span class='desc'><p>
337
+ The port to which was connected
338
+ </p>
339
+ </span>
340
+ </dd>
341
+
342
+
343
+
344
+ <dt>
345
+ <span class='type'>[<tt>Integer</tt>]</span>
346
+ <span class='name'>timeout_after</span>
347
+
348
+ </dt>
349
+ <dd>
350
+ <span class='desc'><p>
351
+ The timeout, defaults to 10 seconds
352
+ </p>
353
+ </span>
354
+ </dd>
355
+
356
+
357
+ </dl>
358
+ </div><div class="return">
359
+ <h3>Returns:</h3>
360
+ <dl>
361
+
362
+ <dt>
363
+
364
+ <span class='type'>[<tt><a href="Ident/Response/USERID.html" title="Response::USERID">Response::USERID</a></tt>]</span>
365
+
366
+
367
+ <span class='name'></span>
368
+
369
+
370
+ </dt>
371
+ <dd>
372
+ <span class='desc'><p>
373
+ if we successfully queried the ident server
374
+ </p>
375
+ </span>
376
+ </dd>
377
+
378
+ <dt>
379
+
380
+ <span class='type'>[<tt><a href="Ident/Response/ERROR.html" title="Response::ERROR">Response::ERROR</a></tt>]</span>
381
+
382
+
383
+ <span class='name'></span>
384
+
385
+
386
+ </dt>
387
+ <dd>
388
+ <span class='desc'><p>
389
+ in case of an error
390
+ </p>
391
+ </span>
392
+ </dd>
393
+
394
+ </dl>
395
+ </div>
396
+ <div class="raise">
397
+ <h3>Raises:</h3>
398
+ <dl>
399
+
400
+ <dt>
401
+
402
+ <span class='type'>[<tt>Timeout::Error</tt>]</span>
403
+
404
+
405
+
406
+ </dt>
407
+ <dd>
408
+ <span class='desc'><p>
409
+ In case of a timeout
410
+ </p>
411
+ </span>
412
+ </dd>
413
+
414
+ <dt>
415
+
416
+ <span class='type'>[<tt>Errno::ECONNREFUSED</tt>]</span>
417
+
418
+
419
+
420
+ </dt>
421
+ <dd>
422
+ <span class='desc'><p>
423
+ If no identd was running at the destination host
424
+ </p>
425
+ </span>
426
+ </dd>
427
+
428
+ </dl>
429
+ </div>
430
+
431
+ </div><div class="section source">
432
+ <span>[<a class="source_link" href="#">View source</a>]</span>
433
+ <div class="source_code">
434
+ <table>
435
+ <tr>
436
+ <td>
437
+ <pre class="lines">
438
+
439
+
440
+ 116
441
+ 117
442
+ 118
443
+ 119
444
+ 120
445
+ 121
446
+ 122
447
+ 123
448
+ 124
449
+ 125
450
+ 126
451
+ 127
452
+ 128
453
+ 129
454
+ 130</pre>
455
+ </td>
456
+ <td>
457
+ <pre class="code"><span class="info file"># File 'lib/ident.rb', line 116</span>
458
+
459
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id request'>request</span><span class='lparen'>(</span><span class='id ip'>ip</span><span class='comma'>,</span> <span class='id outbound'>outbound</span><span class='comma'>,</span> <span class='id inbound'>inbound</span><span class='comma'>,</span> <span class='id timeout_after'>timeout_after</span> <span class='op'>=</span> <span class='int'>10</span><span class='rparen'>)</span>
460
+ <span class='id r'>r</span> <span class='op'>=</span> <span class='kw'>nil</span>
461
+ <span class='id timeout'>timeout</span><span class='lparen'>(</span><span class='id timeout_after'>timeout_after</span><span class='rparen'>)</span> <span class='kw'>do</span>
462
+ <span class='id t'>t</span> <span class='op'>=</span> <span class='const'>TCPSocket</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id ip'>ip</span><span class='comma'>,</span> <span class='int'>113</span><span class='rparen'>)</span>
463
+ <span class='id t'>t</span><span class='period'>.</span><span class='id puts'>puts</span> <span class='lbracket'>[</span><span class='id outbound'>outbound</span><span class='comma'>,</span> <span class='id inbound'>inbound</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>, </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
464
+ <span class='id r'>r</span> <span class='op'>=</span> <span class='id t'>t</span><span class='period'>.</span><span class='id gets'>gets</span>
465
+ <span class='id t'>t</span><span class='period'>.</span><span class='id close'>close</span>
466
+ <span class='kw'>end</span>
467
+
468
+ <span class='comment'># in case the identd just kills our connection
469
+ </span> <span class='id r'>r</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id outbound'>outbound</span><span class='rbrace'>}</span><span class='tstring_content'>, </span><span class='embexpr_beg'>#{</span><span class='id inbound'>inbound</span><span class='rbrace'>}</span><span class='tstring_content'>:ERROR:UNKNOWN-ERROR</span><span class='tstring_end'>&quot;</span></span>
470
+
471
+ <span class='id r'>r</span><span class='period'>.</span><span class='id chomp!'>chomp!</span>
472
+ <span class='const'>Response</span><span class='period'>.</span><span class='id from'>from</span><span class='lparen'>(</span><span class='id r'>r</span><span class='rparen'>)</span>
473
+ <span class='kw'>end</span></pre>
474
+ </td>
475
+ </tr>
476
+ </table>
477
+ </div>
478
+ </div>
479
+ </div>
480
+ </div>
481
+
482
+ </div><div class="section methoddetails instance public">
483
+ <h1>Public Instance Method Details</h1>
484
+
485
+ <div class="method">
486
+ <div class="method_header">
487
+ <h3>request</h3>
488
+ </div><div id="request-instance_method" class="section method">
489
+ <div class="details_title">
490
+ <div class='section methodsignature'>
491
+ <tt class='def'>
492
+ <span class='visibility'>public</span>
493
+ <span class='return_types'></span>
494
+ <span class='name'>request</span><span class='args'></span>
495
+ <span class='block'></span>
496
+ </tt>
497
+ </div>
498
+
499
+ </div><div class="section tags">
500
+ <h2>Meta Tags</h2>
501
+ <div class="see">
502
+ <h3>See Also:</h3>
503
+ <dl>
504
+ <dt></dt>
505
+ <dd>
506
+ <span class='desc'>
507
+ <tt><a href="#request-class_method" title="Ident.request">Ident.request</a></tt>
508
+ </span>
509
+ </dd>
510
+ </dl>
511
+ </div>
512
+
513
+ </div><div class="section source">
514
+ <span>[<a class="source_link" href="#">View source</a>]</span>
515
+ <div class="source_code">
516
+ <table>
517
+ <tr>
518
+ <td>
519
+ <pre class="lines">
520
+
521
+
522
+ 92
523
+ 93
524
+ 94</pre>
525
+ </td>
526
+ <td>
527
+ <pre class="code"><span class="info file"># File 'lib/ident.rb', line 92</span>
528
+
529
+ <span class='kw'>def</span> <span class='id request'>request</span>
530
+ <span class='ivar'>@response</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id class'>class</span><span class='period'>.</span><span class='id request'>request</span><span class='lparen'>(</span><span class='ivar'>@ip</span><span class='comma'>,</span> <span class='ivar'>@outbound</span><span class='comma'>,</span> <span class='ivar'>@inbound</span><span class='comma'>,</span> <span class='ivar'>@timeout</span><span class='rparen'>)</span>
531
+ <span class='kw'>end</span></pre>
532
+ </td>
533
+ </tr>
534
+ </table>
535
+ </div>
536
+ </div>
537
+ </div>
538
+ </div>
539
+
540
+ </div>
541
+ </div>
542
+
543
+ </div>
544
+ </div>
545
+ <div id="yard_info">
546
+ Generated on Wednesday, October 14 2009 at 04:55:47 PM by
547
+ <abbr class="yard" title="Yay! A Ruby Documentation Tool"><a href="http://yard.soen.ca">YARD</a></abbr>
548
+ 0.2.3.3 (ruby-1.9.1).
549
+ </div>
550
+
551
+ </body>
552
+ </html>