dnsbl-client 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +8 -0
  3. data/data/three-level-tlds +2129 -1
  4. data/data/two-level-tlds +1858 -0
  5. data/html/DNSBL.html +98 -0
  6. data/html/DNSBL/Client.html +646 -0
  7. data/html/DNSBL/DNSBLResult.html +114 -0
  8. data/html/README_md.html +141 -0
  9. data/html/Resolv.html +98 -0
  10. data/html/Resolv/DNS.html +98 -0
  11. data/html/Resolv/DNS/Config.html +169 -0
  12. data/html/created.rid +4 -0
  13. data/html/fonts.css +167 -0
  14. data/html/fonts/Lato-Light.ttf +0 -0
  15. data/html/fonts/Lato-LightItalic.ttf +0 -0
  16. data/html/fonts/Lato-Regular.ttf +0 -0
  17. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  18. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  19. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  20. data/html/images/add.png +0 -0
  21. data/html/images/arrow_up.png +0 -0
  22. data/html/images/brick.png +0 -0
  23. data/html/images/brick_link.png +0 -0
  24. data/html/images/bug.png +0 -0
  25. data/html/images/bullet_black.png +0 -0
  26. data/html/images/bullet_toggle_minus.png +0 -0
  27. data/html/images/bullet_toggle_plus.png +0 -0
  28. data/html/images/date.png +0 -0
  29. data/html/images/delete.png +0 -0
  30. data/html/images/find.png +0 -0
  31. data/html/images/loadingAnimation.gif +0 -0
  32. data/html/images/macFFBgHack.png +0 -0
  33. data/html/images/package.png +0 -0
  34. data/html/images/page_green.png +0 -0
  35. data/html/images/page_white_text.png +0 -0
  36. data/html/images/page_white_width.png +0 -0
  37. data/html/images/plugin.png +0 -0
  38. data/html/images/ruby.png +0 -0
  39. data/html/images/tag_blue.png +0 -0
  40. data/html/images/tag_green.png +0 -0
  41. data/html/images/transparent.png +0 -0
  42. data/html/images/wrench.png +0 -0
  43. data/html/images/wrench_orange.png +0 -0
  44. data/html/images/zoom.png +0 -0
  45. data/html/index.html +98 -0
  46. data/html/js/darkfish.js +140 -0
  47. data/html/js/jquery.js +18 -0
  48. data/html/js/navigation.js +142 -0
  49. data/html/js/search.js +109 -0
  50. data/html/js/search_index.js +1 -0
  51. data/html/js/searcher.js +228 -0
  52. data/html/rdoc.css +580 -0
  53. data/html/table_of_contents.html +120 -0
  54. data/lib/dnsbl/client.rb +65 -57
  55. data/lib/dnsbl/client/version.rb +3 -2
  56. metadata +51 -2
data/html/DNSBL.html ADDED
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>module DNSBL - RDoc Documentation</title>
8
+
9
+ <link href="./fonts.css" rel="stylesheet">
10
+ <link href="./rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "./";
14
+ </script>
15
+
16
+ <script src="./js/jquery.js"></script>
17
+ <script src="./js/navigation.js"></script>
18
+ <script src="./js/search_index.js"></script>
19
+ <script src="./js/search.js"></script>
20
+ <script src="./js/searcher.js"></script>
21
+ <script src="./js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="module">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+
62
+
63
+
64
+ </div>
65
+ </nav>
66
+
67
+ <main role="main" aria-labelledby="module-DNSBL">
68
+ <h1 id="module-DNSBL" class="module">
69
+ module DNSBL
70
+ </h1>
71
+
72
+ <section class="description">
73
+
74
+ </section>
75
+
76
+
77
+
78
+
79
+ <section id="5Buntitled-5D" class="documentation-section">
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ </section>
90
+ </main>
91
+
92
+
93
+ <footer id="validator-badges" role="contentinfo">
94
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
95
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
96
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
97
+ </footer>
98
+
@@ -0,0 +1,646 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class DNSBL::Client - RDoc Documentation</title>
8
+
9
+ <link href="../fonts.css" rel="stylesheet">
10
+ <link href="../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../";
14
+ </script>
15
+
16
+ <script src="../js/jquery.js"></script>
17
+ <script src="../js/navigation.js"></script>
18
+ <script src="../js/search_index.js"></script>
19
+ <script src="../js/search.js"></script>
20
+ <script src="../js/searcher.js"></script>
21
+ <script src="../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
63
+
64
+ <p class="link">Object
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li ><a href="#method-c-new">::new</a>
77
+
78
+ <li ><a href="#method-i-__phpot_decoder">#__phpot_decoder</a>
79
+
80
+ <li ><a href="#method-i-_decode_response">#_decode_response</a>
81
+
82
+ <li ><a href="#method-i-_encode_query">#_encode_query</a>
83
+
84
+ <li ><a href="#method-i-add_dnsbl">#add_dnsbl</a>
85
+
86
+ <li ><a href="#method-i-dnsbls">#dnsbls</a>
87
+
88
+ <li ><a href="#method-i-lookup">#lookup</a>
89
+
90
+ <li ><a href="#method-i-nameservers-3D">#nameservers=</a>
91
+
92
+ <li ><a href="#method-i-normalize">#normalize</a>
93
+
94
+ </ul>
95
+ </div>
96
+
97
+ </div>
98
+ </nav>
99
+
100
+ <main role="main" aria-labelledby="class-DNSBL::Client">
101
+ <h1 id="class-DNSBL::Client" class="class">
102
+ class DNSBL::Client
103
+ </h1>
104
+
105
+ <section class="description">
106
+
107
+ <p><a href="Client.html">Client</a> actually handles the sending of queries to
108
+ a recursive DNS server and places any replies into DNSBLResults</p>
109
+
110
+ </section>
111
+
112
+
113
+
114
+
115
+ <section id="5Buntitled-5D" class="documentation-section">
116
+
117
+
118
+
119
+
120
+
121
+ <section class="constants-list">
122
+ <header>
123
+ <h3>Constants</h3>
124
+ </header>
125
+ <dl>
126
+
127
+ <dt id="VERSION">VERSION
128
+
129
+ <dd><p>Current version of the dnsbl-client gem</p>
130
+
131
+
132
+ </dl>
133
+ </section>
134
+
135
+
136
+
137
+
138
+
139
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
140
+ <header>
141
+ <h3>Public Class Methods</h3>
142
+ </header>
143
+
144
+
145
+ <div id="method-c-new" class="method-detail ">
146
+
147
+ <div class="method-heading">
148
+ <span class="method-name">new</span><span
149
+ class="method-args">(config = YAML.load(File.open(File.expand_path('../../../data', __FILE__)+"/dnsbl.yaml").read), two_level_tldfile = File.expand_path('../../../data', __FILE__)+"/two-level-tlds", three_level_tldfile = File.expand_path('../../../data', __FILE__)+"/three-level-tlds")</span>
150
+
151
+ <span class="method-click-advice">click to toggle source</span>
152
+
153
+ </div>
154
+
155
+
156
+ <div class="method-description">
157
+
158
+ <p>initialize a new <a href="Client.html">DNSBL::Client</a> object the config
159
+ file automatically points to a YAML file containing the list of DNSBLs and
160
+ their return codes the two-level-tlds file lists most of the two level
161
+ tlds, needed for hostname to domain normalization</p>
162
+
163
+
164
+
165
+
166
+ <div class="method-source-code" id="new-source">
167
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 40</span>
168
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">config</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&#39;../../../data&#39;</span>, <span class="ruby-keyword">__FILE__</span>)<span class="ruby-operator">+</span><span class="ruby-string">&quot;/dnsbl.yaml&quot;</span>).<span class="ruby-identifier">read</span>),
169
+ <span class="ruby-identifier">two_level_tldfile</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&#39;../../../data&#39;</span>, <span class="ruby-keyword">__FILE__</span>)<span class="ruby-operator">+</span><span class="ruby-string">&quot;/two-level-tlds&quot;</span>,
170
+ <span class="ruby-identifier">three_level_tldfile</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&#39;../../../data&#39;</span>, <span class="ruby-keyword">__FILE__</span>)<span class="ruby-operator">+</span><span class="ruby-string">&quot;/three-level-tlds&quot;</span>)
171
+ <span class="ruby-ivar">@dnsbls</span> = <span class="ruby-identifier">config</span>
172
+ <span class="ruby-ivar">@two_level_tld</span> = []
173
+ <span class="ruby-ivar">@three_level_tld</span> = []
174
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">two_level_tldfile</span>).<span class="ruby-identifier">readlines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
175
+ <span class="ruby-ivar">@two_level_tld</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">strip</span>
176
+ <span class="ruby-keyword">end</span>
177
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">three_level_tldfile</span>).<span class="ruby-identifier">readlines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
178
+ <span class="ruby-ivar">@three_level_tld</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">strip</span>
179
+ <span class="ruby-keyword">end</span>
180
+ <span class="ruby-ivar">@sockets</span> = []
181
+ <span class="ruby-identifier">config</span> = <span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">new</span>
182
+ <span class="ruby-identifier">config</span>.<span class="ruby-identifier">nameservers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ip</span>,<span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
183
+ <span class="ruby-identifier">sock</span> = <span class="ruby-constant">UDPSocket</span>.<span class="ruby-identifier">new</span>
184
+ <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">connect</span>(<span class="ruby-identifier">ip</span>,<span class="ruby-identifier">port</span>)
185
+ <span class="ruby-ivar">@sockets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sock</span>
186
+ <span class="ruby-keyword">break</span> <span class="ruby-comment"># let&#39;s just the first nameserver in this version of the library</span>
187
+ <span class="ruby-keyword">end</span>
188
+ <span class="ruby-ivar">@socket_index</span> = <span class="ruby-value">0</span>
189
+ <span class="ruby-keyword">end</span></pre>
190
+ </div>
191
+
192
+ </div>
193
+
194
+
195
+
196
+
197
+ </div>
198
+
199
+
200
+ </section>
201
+
202
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
203
+ <header>
204
+ <h3>Public Instance Methods</h3>
205
+ </header>
206
+
207
+
208
+ <div id="method-i-_encode_query" class="method-detail ">
209
+
210
+ <div class="method-heading">
211
+ <span class="method-name">_encode_query</span><span
212
+ class="method-args">(item,itemtype,domain,apikey=nil)</span>
213
+
214
+ <span class="method-click-advice">click to toggle source</span>
215
+
216
+ </div>
217
+
218
+
219
+ <div class="method-description">
220
+
221
+ <p>converts an ip or a hostname into the DNS query packet requires to lookup
222
+ the result</p>
223
+
224
+
225
+
226
+
227
+ <div class="method-source-code" id="_encode_query-source">
228
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 108</span>
229
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">_encode_query</span>(<span class="ruby-identifier">item</span>,<span class="ruby-identifier">itemtype</span>,<span class="ruby-identifier">domain</span>,<span class="ruby-identifier">apikey</span>=<span class="ruby-keyword">nil</span>)
230
+ <span class="ruby-identifier">label</span> = <span class="ruby-keyword">nil</span>
231
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">itemtype</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;ip&#39;</span>
232
+ <span class="ruby-identifier">label</span> = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\./</span>).<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
233
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">itemtype</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;domain&#39;</span>
234
+ <span class="ruby-identifier">label</span> = <span class="ruby-identifier">normalize</span>(<span class="ruby-identifier">item</span>)
235
+ <span class="ruby-keyword">end</span>
236
+ <span class="ruby-identifier">lookup</span> = <span class="ruby-node">&quot;#{label}.#{domain}&quot;</span>
237
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">apikey</span>
238
+ <span class="ruby-identifier">lookup</span> = <span class="ruby-node">&quot;#{apikey}.#{lookup}&quot;</span>
239
+ <span class="ruby-keyword">end</span>
240
+ <span class="ruby-identifier">txid</span> = <span class="ruby-identifier">lookup</span>.<span class="ruby-identifier">sum</span>
241
+ <span class="ruby-identifier">message</span> = <span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">txid</span>)
242
+ <span class="ruby-identifier">message</span>.<span class="ruby-identifier">rd</span> = <span class="ruby-value">1</span>
243
+ <span class="ruby-identifier">message</span>.<span class="ruby-identifier">add_question</span>(<span class="ruby-identifier">lookup</span>,<span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Resource</span><span class="ruby-operator">::</span><span class="ruby-constant">IN</span><span class="ruby-operator">::</span><span class="ruby-constant">A</span>)
244
+ <span class="ruby-identifier">message</span>.<span class="ruby-identifier">encode</span>
245
+ <span class="ruby-keyword">end</span></pre>
246
+ </div>
247
+
248
+ </div>
249
+
250
+
251
+
252
+
253
+ </div>
254
+
255
+
256
+ <div id="method-i-add_dnsbl" class="method-detail ">
257
+
258
+ <div class="method-heading">
259
+ <span class="method-name">add_dnsbl</span><span
260
+ class="method-args">(name,domain,type='ip',codes={"0"=>"OK","127.0.0.2"=>"Blacklisted"})</span>
261
+
262
+ <span class="method-click-advice">click to toggle source</span>
263
+
264
+ </div>
265
+
266
+
267
+ <div class="method-description">
268
+
269
+ <p>allows the adding of a new <a href="../DNSBL.html">DNSBL</a> to the set of
270
+ configured DNSBLs</p>
271
+
272
+
273
+
274
+
275
+ <div class="method-source-code" id="add_dnsbl-source">
276
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 96</span>
277
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">add_dnsbl</span>(<span class="ruby-identifier">name</span>,<span class="ruby-identifier">domain</span>,<span class="ruby-identifier">type</span>=<span class="ruby-string">&#39;ip&#39;</span>,<span class="ruby-identifier">codes</span>={<span class="ruby-string">&quot;0&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;OK&quot;</span>,<span class="ruby-string">&quot;127.0.0.2&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-string">&quot;Blacklisted&quot;</span>})
278
+ <span class="ruby-ivar">@dnsbls</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">codes</span>
279
+ <span class="ruby-ivar">@dnsbls</span>[<span class="ruby-identifier">name</span>][<span class="ruby-string">&#39;domain&#39;</span>] = <span class="ruby-identifier">domain</span>
280
+ <span class="ruby-ivar">@dnsbls</span>[<span class="ruby-identifier">name</span>][<span class="ruby-string">&#39;type&#39;</span>] = <span class="ruby-identifier">type</span>
281
+ <span class="ruby-keyword">end</span></pre>
282
+ </div>
283
+
284
+ </div>
285
+
286
+
287
+
288
+
289
+ </div>
290
+
291
+
292
+ <div id="method-i-dnsbls" class="method-detail ">
293
+
294
+ <div class="method-heading">
295
+ <span class="method-name">dnsbls</span><span
296
+ class="method-args">()</span>
297
+
298
+ <span class="method-click-advice">click to toggle source</span>
299
+
300
+ </div>
301
+
302
+
303
+ <div class="method-description">
304
+
305
+ <p>returns a list of <a href="../DNSBL.html">DNSBL</a> names currently
306
+ configured</p>
307
+
308
+
309
+
310
+
311
+ <div class="method-source-code" id="dnsbls-source">
312
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 103</span>
313
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">dnsbls</span>
314
+ <span class="ruby-ivar">@dnsbls</span>.<span class="ruby-identifier">keys</span>
315
+ <span class="ruby-keyword">end</span></pre>
316
+ </div>
317
+
318
+ </div>
319
+
320
+
321
+
322
+
323
+ </div>
324
+
325
+
326
+ <div id="method-i-lookup" class="method-detail ">
327
+
328
+ <div class="method-heading">
329
+ <span class="method-name">lookup</span><span
330
+ class="method-args">(item)</span>
331
+
332
+ <span class="method-click-advice">click to toggle source</span>
333
+
334
+ </div>
335
+
336
+
337
+ <div class="method-description">
338
+
339
+ <p>lookup performs the sending of DNS queries for the given items returns an
340
+ array of <a href="DNSBLResult.html">DNSBLResult</a></p>
341
+
342
+
343
+
344
+
345
+ <div class="method-source-code" id="lookup-source">
346
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 129</span>
347
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">lookup</span>(<span class="ruby-identifier">item</span>)
348
+ <span class="ruby-comment"># if item is an array, use it, otherwise make it one</span>
349
+ <span class="ruby-identifier">items</span> = <span class="ruby-identifier">item</span>
350
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
351
+ <span class="ruby-identifier">items</span> = [<span class="ruby-identifier">item</span>]
352
+ <span class="ruby-keyword">end</span>
353
+ <span class="ruby-comment"># place the results in the results array</span>
354
+ <span class="ruby-identifier">results</span> = []
355
+ <span class="ruby-comment"># for each ip or hostname</span>
356
+ <span class="ruby-identifier">items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
357
+ <span class="ruby-comment"># sent is used to determine when we have all the answers</span>
358
+ <span class="ruby-identifier">sent</span> = <span class="ruby-value">0</span>
359
+ <span class="ruby-comment"># record the start time</span>
360
+ <span class="ruby-ivar">@starttime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span>
361
+ <span class="ruby-comment"># determine the type of query</span>
362
+ <span class="ruby-identifier">itemtype</span> = (<span class="ruby-identifier">item</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/</span>) <span class="ruby-operator">?</span> <span class="ruby-string">&#39;ip&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;domain&#39;</span>
363
+ <span class="ruby-comment"># for each dnsbl that supports our type, create the DNS query packet and send it</span>
364
+ <span class="ruby-comment"># rotate across our configured name servers and increment sent</span>
365
+ <span class="ruby-ivar">@dnsbls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>,<span class="ruby-identifier">config</span><span class="ruby-operator">|</span>
366
+ <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;disabled&#39;</span>]
367
+ <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;type&#39;</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">itemtype</span>
368
+ <span class="ruby-keyword">begin</span>
369
+ <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">_encode_query</span>(<span class="ruby-identifier">item</span>,<span class="ruby-identifier">itemtype</span>,<span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;domain&#39;</span>],<span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;apikey&#39;</span>])
370
+ <span class="ruby-ivar">@sockets</span>[<span class="ruby-ivar">@socket_index</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">msg</span>,<span class="ruby-value">0</span>)
371
+ <span class="ruby-ivar">@socket_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
372
+ <span class="ruby-ivar">@socket_index</span> <span class="ruby-operator">=</span> <span class="ruby-ivar">@sockets</span>.<span class="ruby-identifier">length</span>
373
+ <span class="ruby-identifier">sent</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
374
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
375
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>
376
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
377
+ <span class="ruby-keyword">end</span>
378
+ <span class="ruby-keyword">end</span>
379
+ <span class="ruby-comment"># while we still expect answers</span>
380
+ <span class="ruby-keyword">while</span> <span class="ruby-identifier">sent</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
381
+ <span class="ruby-comment"># wait on the socket for maximally 1.5 seconds</span>
382
+ <span class="ruby-identifier">r</span>,<span class="ruby-identifier">_</span>,<span class="ruby-identifier">_</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-ivar">@sockets</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-value">1.5</span>)
383
+ <span class="ruby-comment"># if we time out, break out of the loop</span>
384
+ <span class="ruby-keyword">break</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">r</span>
385
+ <span class="ruby-comment"># for each reply, decode it and receive results, decrement the pending answers</span>
386
+ <span class="ruby-identifier">r</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
387
+ <span class="ruby-keyword">begin</span>
388
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">_decode_response</span>(<span class="ruby-identifier">s</span>.<span class="ruby-identifier">recv</span>(<span class="ruby-value">4096</span>))
389
+ <span class="ruby-identifier">results</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">response</span>
390
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
391
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>
392
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
393
+ <span class="ruby-keyword">end</span>
394
+ <span class="ruby-identifier">sent</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
395
+ <span class="ruby-keyword">end</span>
396
+ <span class="ruby-keyword">end</span>
397
+ <span class="ruby-keyword">end</span>
398
+ <span class="ruby-identifier">results</span>
399
+ <span class="ruby-keyword">end</span></pre>
400
+ </div>
401
+
402
+ </div>
403
+
404
+
405
+
406
+
407
+ </div>
408
+
409
+
410
+ <div id="method-i-nameservers-3D" class="method-detail ">
411
+
412
+ <div class="method-heading">
413
+ <span class="method-name">nameservers=</span><span
414
+ class="method-args">(ns=Resolv::DNS::Config.new.nameservers)</span>
415
+
416
+ <span class="method-click-advice">click to toggle source</span>
417
+
418
+ </div>
419
+
420
+
421
+ <div class="method-description">
422
+
423
+ <p>sets the nameservers used for performing DNS lookups in round-robin fashion</p>
424
+
425
+
426
+
427
+
428
+ <div class="method-source-code" id="nameservers-3D-source">
429
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 64</span>
430
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">nameservers=</span>(<span class="ruby-identifier">ns</span>=<span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">nameservers</span>)
431
+ <span class="ruby-ivar">@sockets</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
432
+ <span class="ruby-identifier">s</span>.<span class="ruby-identifier">close</span>
433
+ <span class="ruby-keyword">end</span>
434
+ <span class="ruby-ivar">@sockets</span> = []
435
+ <span class="ruby-identifier">ns</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ip</span>,<span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
436
+ <span class="ruby-identifier">sock</span> = <span class="ruby-constant">UDPSocket</span>.<span class="ruby-identifier">new</span>
437
+ <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">connect</span>(<span class="ruby-identifier">ip</span>,<span class="ruby-identifier">port</span>)
438
+ <span class="ruby-ivar">@sockets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sock</span>
439
+ <span class="ruby-keyword">break</span> <span class="ruby-comment"># let&#39;s just the first nameserver in this version of the library</span>
440
+ <span class="ruby-keyword">end</span>
441
+ <span class="ruby-ivar">@socket_index</span> = <span class="ruby-value">0</span>
442
+ <span class="ruby-keyword">end</span></pre>
443
+ </div>
444
+
445
+ </div>
446
+
447
+
448
+
449
+
450
+ </div>
451
+
452
+
453
+ <div id="method-i-normalize" class="method-detail ">
454
+
455
+ <div class="method-heading">
456
+ <span class="method-name">normalize</span><span
457
+ class="method-args">(domain)</span>
458
+
459
+ <span class="method-click-advice">click to toggle source</span>
460
+
461
+ </div>
462
+
463
+
464
+ <div class="method-description">
465
+
466
+ <p>Converts a hostname to the domain: e.g., <a
467
+ href="www.google.com">www.google.com</a> =&gt; google.com,
468
+ science.somewhere.co.uk =&gt; somewhere.co.uk</p>
469
+
470
+
471
+
472
+
473
+ <div class="method-source-code" id="normalize-source">
474
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 79</span>
475
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">normalize</span>(<span class="ruby-identifier">domain</span>)
476
+ <span class="ruby-comment"># strip off the protocol (\w{1,20}://), the URI (/), parameters (?), port number (:), and username (.*@)</span>
477
+ <span class="ruby-comment"># then split into parts via the .</span>
478
+ <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^\w{1,20}:\/\//</span>,<span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[\/\?\:].*/</span>,<span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/.*?\@/</span>,<span class="ruby-string">&#39;&#39;</span>).<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\./</span>)
479
+ <span class="ruby-comment"># grab the last two parts of the domain</span>
480
+ <span class="ruby-identifier">dom</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">-2</span>,<span class="ruby-value">2</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
481
+ <span class="ruby-comment"># if the dom is in the two_level_tld list, then use three parts</span>
482
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@two_level_tld</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">dom</span>)
483
+ <span class="ruby-identifier">dom</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">-3</span>,<span class="ruby-value">3</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
484
+ <span class="ruby-keyword">end</span>
485
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@three_level_tld</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">dom</span>)
486
+ <span class="ruby-identifier">dom</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">-4</span>,<span class="ruby-value">4</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
487
+ <span class="ruby-keyword">end</span>
488
+ <span class="ruby-identifier">dom</span>
489
+ <span class="ruby-keyword">end</span></pre>
490
+ </div>
491
+
492
+ </div>
493
+
494
+
495
+
496
+
497
+ </div>
498
+
499
+
500
+ </section>
501
+
502
+ <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
503
+ <header>
504
+ <h3>Private Instance Methods</h3>
505
+ </header>
506
+
507
+
508
+ <div id="method-i-__phpot_decoder" class="method-detail ">
509
+
510
+ <div class="method-heading">
511
+ <span class="method-name">__phpot_decoder</span><span
512
+ class="method-args">(ip)</span>
513
+
514
+ <span class="method-click-advice">click to toggle source</span>
515
+
516
+ </div>
517
+
518
+
519
+ <div class="method-description">
520
+
521
+ <p>decodes the response from Project Honey Pot&#39;s service</p>
522
+
523
+
524
+
525
+
526
+ <div class="method-source-code" id="__phpot_decoder-source">
527
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 222</span>
528
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">__phpot_decoder</span>(<span class="ruby-identifier">ip</span>)
529
+ <span class="ruby-identifier">octets</span> = <span class="ruby-identifier">ip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\./</span>)
530
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">octets</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-value">4</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">octets</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;127&quot;</span>
531
+ <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;invalid response&quot;</span>
532
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">octets</span>[<span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&quot;0&quot;</span>
533
+ <span class="ruby-identifier">search_engines</span> = [<span class="ruby-string">&quot;undocumented&quot;</span>, <span class="ruby-string">&quot;AltaVista&quot;</span>, <span class="ruby-string">&quot;Ask&quot;</span>, <span class="ruby-string">&quot;Baidu&quot;</span>, <span class="ruby-string">&quot;Excite&quot;</span>, <span class="ruby-string">&quot;Google&quot;</span>, <span class="ruby-string">&quot;Looksmart&quot;</span>, <span class="ruby-string">&quot;Lycos&quot;</span>, <span class="ruby-string">&quot;MSN&quot;</span>, <span class="ruby-string">&quot;Yahoo&quot;</span>, <span class="ruby-string">&quot;Cuil&quot;</span>, <span class="ruby-string">&quot;InfoSeek&quot;</span>, <span class="ruby-string">&quot;Miscellaneous&quot;</span>]
534
+ <span class="ruby-identifier">sindex</span> = <span class="ruby-identifier">octets</span>[<span class="ruby-value">2</span>].<span class="ruby-identifier">to_i</span>
535
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">sindex</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">search_engines</span>.<span class="ruby-identifier">length</span>
536
+ <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;type=search engine,engine=unknown&quot;</span>
537
+ <span class="ruby-keyword">else</span>
538
+ <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;type=search engine,engine=#{search_engines[sindex]}&quot;</span>
539
+ <span class="ruby-keyword">end</span>
540
+ <span class="ruby-keyword">else</span>
541
+ <span class="ruby-identifier">days</span>, <span class="ruby-identifier">threatscore</span>, <span class="ruby-identifier">flags</span> = <span class="ruby-identifier">octets</span>[<span class="ruby-value">1</span>,<span class="ruby-value">3</span>]
542
+ <span class="ruby-identifier">flags</span> = <span class="ruby-identifier">flags</span>.<span class="ruby-identifier">to_i</span>
543
+ <span class="ruby-identifier">types</span> = []
544
+ <span class="ruby-keyword">if</span> (<span class="ruby-identifier">flags</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0x1</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0x1</span>
545
+ <span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;suspicious&quot;</span>
546
+ <span class="ruby-keyword">end</span>
547
+ <span class="ruby-keyword">if</span> (<span class="ruby-identifier">flags</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0x2</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0x2</span>
548
+ <span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;harvester&quot;</span>
549
+ <span class="ruby-keyword">end</span>
550
+ <span class="ruby-keyword">if</span> (<span class="ruby-identifier">flags</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0x4</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0x4</span>
551
+ <span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;comment spammer&quot;</span>
552
+ <span class="ruby-keyword">end</span>
553
+ <span class="ruby-keyword">if</span> (<span class="ruby-identifier">flags</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0xf8</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
554
+ <span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;reserved&quot;</span>
555
+ <span class="ruby-keyword">end</span>
556
+ <span class="ruby-identifier">type</span> = <span class="ruby-identifier">types</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;,&quot;</span>)
557
+ <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;days=#{days},score=#{threatscore},type=#{type}&quot;</span>
558
+ <span class="ruby-keyword">end</span>
559
+ <span class="ruby-keyword">end</span></pre>
560
+ </div>
561
+
562
+ </div>
563
+
564
+
565
+
566
+
567
+ </div>
568
+
569
+
570
+ <div id="method-i-_decode_response" class="method-detail ">
571
+
572
+ <div class="method-heading">
573
+ <span class="method-name">_decode_response</span><span
574
+ class="method-args">(buf)</span>
575
+
576
+ <span class="method-click-advice">click to toggle source</span>
577
+
578
+ </div>
579
+
580
+
581
+ <div class="method-description">
582
+
583
+ <p>takes a DNS response and converts it into a <a
584
+ href="DNSBLResult.html">DNSBLResult</a></p>
585
+
586
+
587
+
588
+
589
+ <div class="method-source-code" id="_decode_response-source">
590
+ <pre><span class="ruby-comment"># File lib/dnsbl/client.rb, line 186</span>
591
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">_decode_response</span>(<span class="ruby-identifier">buf</span>)
592
+ <span class="ruby-identifier">reply</span> = <span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Message</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">buf</span>)
593
+ <span class="ruby-identifier">results</span> = []
594
+ <span class="ruby-identifier">reply</span>.<span class="ruby-identifier">each_answer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>,<span class="ruby-identifier">ttl</span>,<span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
595
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(.+)$/</span>
596
+ <span class="ruby-identifier">ip</span> = [<span class="ruby-node">$4</span>,<span class="ruby-node">$3</span>,<span class="ruby-node">$2</span>,<span class="ruby-node">$1</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
597
+ <span class="ruby-identifier">domain</span> = <span class="ruby-node">$5</span>
598
+ <span class="ruby-ivar">@dnsbls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dnsblname</span>, <span class="ruby-identifier">config</span><span class="ruby-operator">|</span>
599
+ <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Resolv</span><span class="ruby-operator">::</span><span class="ruby-constant">DNS</span><span class="ruby-operator">::</span><span class="ruby-constant">Resource</span><span class="ruby-operator">::</span><span class="ruby-constant">IN</span><span class="ruby-operator">::</span><span class="ruby-constant">A</span>
600
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">domain</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;domain&#39;</span>]
601
+ <span class="ruby-identifier">meaning</span> = <span class="ruby-identifier">config</span>[<span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>
602
+ <span class="ruby-identifier">results</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">DNSBLResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dnsblname</span>, <span class="ruby-identifier">ip</span>, <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">meaning</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@starttime</span>)
603
+ <span class="ruby-keyword">break</span>
604
+ <span class="ruby-keyword">end</span>
605
+ <span class="ruby-keyword">end</span>
606
+ <span class="ruby-keyword">else</span>
607
+ <span class="ruby-ivar">@dnsbls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dnsblname</span>, <span class="ruby-identifier">config</span><span class="ruby-operator">|</span>
608
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;domain&#39;</span>])
609
+ <span class="ruby-identifier">meaning</span> = <span class="ruby-keyword">nil</span>
610
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;decoder&#39;</span>]
611
+ <span class="ruby-identifier">meaning</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>((<span class="ruby-string">&quot;__&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;decoder&#39;</span>]).<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>)
612
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">config</span>[<span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>]
613
+ <span class="ruby-identifier">meaning</span> = <span class="ruby-identifier">config</span>[<span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>]
614
+ <span class="ruby-keyword">else</span>
615
+ <span class="ruby-identifier">meaning</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>
616
+ <span class="ruby-keyword">end</span>
617
+ <span class="ruby-identifier">results</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">DNSBLResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dnsblname</span>, <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&quot;.&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;domain&#39;</span>],<span class="ruby-string">&#39;&#39;</span>), <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">meaning</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@starttime</span>)
618
+ <span class="ruby-keyword">break</span>
619
+ <span class="ruby-keyword">end</span>
620
+ <span class="ruby-keyword">end</span>
621
+ <span class="ruby-keyword">end</span>
622
+ <span class="ruby-keyword">end</span>
623
+ <span class="ruby-identifier">results</span>
624
+ <span class="ruby-keyword">end</span></pre>
625
+ </div>
626
+
627
+ </div>
628
+
629
+
630
+
631
+
632
+ </div>
633
+
634
+
635
+ </section>
636
+
637
+ </section>
638
+ </main>
639
+
640
+
641
+ <footer id="validator-badges" role="contentinfo">
642
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
643
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
644
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
645
+ </footer>
646
+