dnstraverse 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/LICENSE +674 -0
  2. data/README +4 -0
  3. data/Rakefile +19 -0
  4. data/a +44 -0
  5. data/bin/dnstraverse +300 -0
  6. data/doc.tar +0 -0
  7. data/doc/classes/DNSTraverse.html +198 -0
  8. data/doc/classes/DNSTraverse/CachingResolver.html +172 -0
  9. data/doc/classes/DNSTraverse/CachingResolver.src/M000055.html +21 -0
  10. data/doc/classes/DNSTraverse/CachingResolver.src/M000056.html +42 -0
  11. data/doc/classes/DNSTraverse/DecodedQuery.html +475 -0
  12. data/doc/classes/DNSTraverse/DecodedQuery.src/M000020.html +34 -0
  13. data/doc/classes/DNSTraverse/DecodedQuery.src/M000021.html +23 -0
  14. data/doc/classes/DNSTraverse/DecodedQuery.src/M000022.html +19 -0
  15. data/doc/classes/DNSTraverse/DecodedQuery.src/M000023.html +33 -0
  16. data/doc/classes/DNSTraverse/DecodedQuery.src/M000024.html +26 -0
  17. data/doc/classes/DNSTraverse/DecodedQuery.src/M000025.html +24 -0
  18. data/doc/classes/DNSTraverse/DecodedQuery.src/M000026.html +29 -0
  19. data/doc/classes/DNSTraverse/DecodedQuery.src/M000027.html +19 -0
  20. data/doc/classes/DNSTraverse/DecodedQuery.src/M000028.html +18 -0
  21. data/doc/classes/DNSTraverse/DecodedQuery.src/M000029.html +32 -0
  22. data/doc/classes/DNSTraverse/DecodedQuery.src/M000030.html +19 -0
  23. data/doc/classes/DNSTraverse/DecodedQuery.src/M000031.html +19 -0
  24. data/doc/classes/DNSTraverse/DecodedQuery.src/M000032.html +20 -0
  25. data/doc/classes/DNSTraverse/DecodedQuery.src/M000033.html +31 -0
  26. data/doc/classes/DNSTraverse/DecodedQueryCache.html +182 -0
  27. data/doc/classes/DNSTraverse/DecodedQueryCache.src/M000063.html +21 -0
  28. data/doc/classes/DNSTraverse/DecodedQueryCache.src/M000064.html +33 -0
  29. data/doc/classes/DNSTraverse/Fingerprint.html +277 -0
  30. data/doc/classes/DNSTraverse/Fingerprint.src/M000047.html +29 -0
  31. data/doc/classes/DNSTraverse/Fingerprint.src/M000048.html +18 -0
  32. data/doc/classes/DNSTraverse/Fingerprint.src/M000049.html +57 -0
  33. data/doc/classes/DNSTraverse/Fingerprint.src/M000050.html +28 -0
  34. data/doc/classes/DNSTraverse/Fingerprint.src/M000051.html +27 -0
  35. data/doc/classes/DNSTraverse/Fingerprint.src/M000052.html +35 -0
  36. data/doc/classes/DNSTraverse/Fingerprint.src/M000053.html +24 -0
  37. data/doc/classes/DNSTraverse/Fingerprint.src/M000054.html +29 -0
  38. data/doc/classes/DNSTraverse/InfoCache.html +235 -0
  39. data/doc/classes/DNSTraverse/InfoCache.src/M000034.html +20 -0
  40. data/doc/classes/DNSTraverse/InfoCache.src/M000035.html +23 -0
  41. data/doc/classes/DNSTraverse/InfoCache.src/M000036.html +28 -0
  42. data/doc/classes/DNSTraverse/InfoCache.src/M000037.html +25 -0
  43. data/doc/classes/DNSTraverse/InfoCache.src/M000038.html +27 -0
  44. data/doc/classes/DNSTraverse/InfoCache.src/M000039.html +33 -0
  45. data/doc/classes/DNSTraverse/MessageUtility.html +275 -0
  46. data/doc/classes/DNSTraverse/MessageUtility.src/M000011.html +35 -0
  47. data/doc/classes/DNSTraverse/MessageUtility.src/M000012.html +37 -0
  48. data/doc/classes/DNSTraverse/MessageUtility.src/M000013.html +28 -0
  49. data/doc/classes/DNSTraverse/MessageUtility.src/M000014.html +27 -0
  50. data/doc/classes/DNSTraverse/MessageUtility.src/M000015.html +30 -0
  51. data/doc/classes/DNSTraverse/MessageUtility.src/M000016.html +32 -0
  52. data/doc/classes/DNSTraverse/MessageUtility.src/M000017.html +34 -0
  53. data/doc/classes/DNSTraverse/MessageUtility.src/M000018.html +23 -0
  54. data/doc/classes/DNSTraverse/MessageUtility.src/M000019.html +36 -0
  55. data/doc/classes/DNSTraverse/Referral.html +641 -0
  56. data/doc/classes/DNSTraverse/Referral.src/M000065.html +22 -0
  57. data/doc/classes/DNSTraverse/Referral.src/M000066.html +21 -0
  58. data/doc/classes/DNSTraverse/Referral.src/M000067.html +23 -0
  59. data/doc/classes/DNSTraverse/Referral.src/M000068.html +19 -0
  60. data/doc/classes/DNSTraverse/Referral.src/M000069.html +18 -0
  61. data/doc/classes/DNSTraverse/Referral.src/M000070.html +54 -0
  62. data/doc/classes/DNSTraverse/Referral.src/M000071.html +25 -0
  63. data/doc/classes/DNSTraverse/Referral.src/M000072.html +27 -0
  64. data/doc/classes/DNSTraverse/Referral.src/M000073.html +23 -0
  65. data/doc/classes/DNSTraverse/Referral.src/M000074.html +20 -0
  66. data/doc/classes/DNSTraverse/Referral.src/M000075.html +40 -0
  67. data/doc/classes/DNSTraverse/Referral.src/M000076.html +52 -0
  68. data/doc/classes/DNSTraverse/Referral.src/M000077.html +29 -0
  69. data/doc/classes/DNSTraverse/Referral.src/M000078.html +54 -0
  70. data/doc/classes/DNSTraverse/Referral.src/M000079.html +18 -0
  71. data/doc/classes/DNSTraverse/Referral.src/M000080.html +22 -0
  72. data/doc/classes/DNSTraverse/Referral.src/M000081.html +20 -0
  73. data/doc/classes/DNSTraverse/Referral.src/M000082.html +29 -0
  74. data/doc/classes/DNSTraverse/Referral.src/M000083.html +28 -0
  75. data/doc/classes/DNSTraverse/Referral.src/M000084.html +29 -0
  76. data/doc/classes/DNSTraverse/Referral.src/M000085.html +55 -0
  77. data/doc/classes/DNSTraverse/Referral.src/M000086.html +30 -0
  78. data/doc/classes/DNSTraverse/Referral.src/M000087.html +24 -0
  79. data/doc/classes/DNSTraverse/Referral.src/M000088.html +20 -0
  80. data/doc/classes/DNSTraverse/Referral.src/M000089.html +58 -0
  81. data/doc/classes/DNSTraverse/ResolveError.html +111 -0
  82. data/doc/classes/DNSTraverse/Response.html +271 -0
  83. data/doc/classes/DNSTraverse/Response.src/M000057.html +27 -0
  84. data/doc/classes/DNSTraverse/Response.src/M000058.html +21 -0
  85. data/doc/classes/DNSTraverse/Response.src/M000059.html +19 -0
  86. data/doc/classes/DNSTraverse/Response.src/M000060.html +21 -0
  87. data/doc/classes/DNSTraverse/Response.src/M000061.html +31 -0
  88. data/doc/classes/DNSTraverse/Response.src/M000062.html +23 -0
  89. data/doc/classes/DNSTraverse/Response/NoGlue.html +222 -0
  90. data/doc/classes/DNSTraverse/Response/NoGlue.src/M000007.html +32 -0
  91. data/doc/classes/DNSTraverse/Response/NoGlue.src/M000008.html +18 -0
  92. data/doc/classes/DNSTraverse/Response/NoGlue.src/M000009.html +18 -0
  93. data/doc/classes/DNSTraverse/Response/NoGlue.src/M000010.html +18 -0
  94. data/doc/classes/DNSTraverse/Traverser.html +247 -0
  95. data/doc/classes/DNSTraverse/Traverser.src/M000040.html +17 -0
  96. data/doc/classes/DNSTraverse/Traverser.src/M000041.html +52 -0
  97. data/doc/classes/DNSTraverse/Traverser.src/M000042.html +61 -0
  98. data/doc/classes/DNSTraverse/Traverser.src/M000043.html +110 -0
  99. data/doc/classes/DNSTraverse/Traverser.src/M000044.html +63 -0
  100. data/doc/classes/DNSTraverse/Traverser.src/M000045.html +28 -0
  101. data/doc/classes/DNSTraverse/Traverser.src/M000046.html +18 -0
  102. data/doc/classes/FingerprintRules.html +175 -0
  103. data/doc/classes/Log.html +174 -0
  104. data/doc/classes/Log.src/M000002.html +18 -0
  105. data/doc/classes/Log.src/M000003.html +18 -0
  106. data/doc/classes/Log.src/M000004.html +18 -0
  107. data/doc/classes/Log/Formatter.html +165 -0
  108. data/doc/classes/Log/Formatter.src/M000005.html +22 -0
  109. data/doc/classes/Log/Formatter.src/M000006.html +24 -0
  110. data/doc/classes/TestFingerprint.html +137 -0
  111. data/doc/classes/TestFingerprint.src/M000001.html +22 -0
  112. data/doc/created.rid +1 -0
  113. data/doc/files/lib/dnstraverse/caching_resolver_rb.html +132 -0
  114. data/doc/files/lib/dnstraverse/decoded_query_cache_rb.html +132 -0
  115. data/doc/files/lib/dnstraverse/decoded_query_rb.html +132 -0
  116. data/doc/files/lib/dnstraverse/fingerprint_rb.html +134 -0
  117. data/doc/files/lib/dnstraverse/fingerprint_rules_rb.html +143 -0
  118. data/doc/files/lib/dnstraverse/info_cache_rb.html +131 -0
  119. data/doc/files/lib/dnstraverse/log_rb.html +131 -0
  120. data/doc/files/lib/dnstraverse/message_utility_rb.html +124 -0
  121. data/doc/files/lib/dnstraverse/referral_rb.html +134 -0
  122. data/doc/files/lib/dnstraverse/response_noglue_rb.html +124 -0
  123. data/doc/files/lib/dnstraverse/response_rb.html +132 -0
  124. data/doc/files/lib/dnstraverse/traverser_rb.html +137 -0
  125. data/doc/files/test/test_fingerprint_rb.html +133 -0
  126. data/doc/fr_class_index.html +43 -0
  127. data/doc/fr_file_index.html +39 -0
  128. data/doc/fr_method_index.html +115 -0
  129. data/doc/index.html +24 -0
  130. data/doc/rdoc-style.css +208 -0
  131. data/lib/dnstraverse/caching_resolver.rb +63 -0
  132. data/lib/dnstraverse/decoded_query.rb +199 -0
  133. data/lib/dnstraverse/decoded_query_cache.rb +53 -0
  134. data/lib/dnstraverse/fingerprint.rb +166 -0
  135. data/lib/dnstraverse/fingerprint_rules.rb +389 -0
  136. data/lib/dnstraverse/info_cache.rb +108 -0
  137. data/lib/dnstraverse/log.rb +55 -0
  138. data/lib/dnstraverse/message_utility.rb +199 -0
  139. data/lib/dnstraverse/referral.rb +463 -0
  140. data/lib/dnstraverse/response.rb +92 -0
  141. data/lib/dnstraverse/response_noglue.rb +54 -0
  142. data/lib/dnstraverse/traverser.rb +291 -0
  143. data/test/test_fingerprint.rb +29 -0
  144. metadata +231 -0
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>txt_ips_verbose (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 33</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">txt_ips_verbose</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-value str">''</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@serverips</span>
16
+ <span class="ruby-identifier">a</span> = <span class="ruby-ivar">@serverips</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ip</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">&quot;%.1f%%=&quot;</span>, <span class="ruby-value">100</span> <span class="ruby-operator">*</span> <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">ip</span>]).<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">ip</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^key:([^:]+(:[^:]*)?)/</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">$1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ip</span>)
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-identifier">a</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>)
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>txt_ips (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 41</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">txt_ips</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-value str">''</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@serverips</span>
16
+ <span class="ruby-ivar">@serverips</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ip</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-identifier">ip</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^key:/</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@stats_resolve</span>[<span class="ruby-identifier">ip</span>][<span class="ruby-identifier">:response</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ip</span>
18
+ }.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>)
19
+ <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>ips_as_array (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 49</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ips_as_array</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">EMPTY_ARRAY</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@serverips</span>
16
+ <span class="ruby-identifier">my_ips</span> = []
17
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">ip</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@serverips</span> <span class="ruby-keyword kw">do</span>
18
+ <span class="ruby-identifier">my_ips</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ip</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ip</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^key:/</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">my_ips</span>
21
+ <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>to_s (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 58</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;#{@refid} [#{@qname}/#{@qclass}/#{@qtype}] server=#{@server} &quot;</span> <span class="ruby-operator">+</span>
16
+ <span class="ruby-node">&quot;server_ips=#{txt_ips()} bailiwick=#{@bailiwick}&quot;</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>referral_resolution? (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 63</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">referral_resolution?</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@referral_resolution</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 82</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>)
15
+ <span class="ruby-ivar">@resolver</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:resolver</span>] <span class="ruby-comment cmt"># Dnsruby::Resolver object</span>
16
+ <span class="ruby-ivar">@qname</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:qname</span>]
17
+ <span class="ruby-ivar">@qclass</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:qclass</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:IN</span>
18
+ <span class="ruby-ivar">@qtype</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:qtype</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:A</span>
19
+ <span class="ruby-ivar">@nsatype</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:nsatype</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:A</span>
20
+ <span class="ruby-ivar">@infocache</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:infocache</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DNSTraverse</span><span class="ruby-operator">::</span><span class="ruby-constant">InfoCache</span>.<span class="ruby-identifier">new</span>
21
+ <span class="ruby-ivar">@roots</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:roots</span>]
22
+ <span class="ruby-ivar">@resolves</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># Array of referral objects for resolving phase</span>
23
+ <span class="ruby-ivar">@refid</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:refid</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
24
+ <span class="ruby-ivar">@server</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># nil for the root-root server</span>
25
+ <span class="ruby-ivar">@serverips</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:serverips</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
26
+ <span class="ruby-ivar">@responses</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># responses/exception for each IP in @serverips</span>
27
+ <span class="ruby-ivar">@children</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># Array of child Referrer objects keyed by IP</span>
28
+ <span class="ruby-ivar">@bailiwick</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:bailiwick</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
29
+ <span class="ruby-ivar">@secure</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:secure</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt"># ensure bailiwick checks</span>
30
+ <span class="ruby-ivar">@parent</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:parent</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># Parent Referral</span>
31
+ <span class="ruby-ivar">@parent_ip</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:parent_ip</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># Parent Referral IP if applicable</span>
32
+ <span class="ruby-ivar">@maxdepth</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:maxdepth</span>] <span class="ruby-operator">||</span> <span class="ruby-value">10</span> <span class="ruby-comment cmt"># maximum depth before error</span>
33
+ <span class="ruby-ivar">@decoded_query_cache</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:decoded_query_cache</span>]
34
+ <span class="ruby-ivar">@referral_resolution</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:referral_resolution</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># flag</span>
35
+ <span class="ruby-ivar">@stats</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># will contain statistics for answers</span>
36
+ <span class="ruby-ivar">@stats_resolve</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># will contain statistics for our resolve (if applic)</span>
37
+ <span class="ruby-ivar">@serverweights</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># key is IP</span>
38
+ <span class="ruby-ivar">@warnings</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># warnings will be placed here</span>
39
+ <span class="ruby-ivar">@processed</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># flag for processed? method</span>
40
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Must pass Resolver&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@resolver</span>
41
+ <span class="ruby-ivar">@infocache</span>.<span class="ruby-identifier">add_hints</span>(<span class="ruby-value str">''</span>, <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:roots</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:roots</span>] <span class="ruby-comment cmt"># add root hints</span>
42
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@decoded_query_cache</span> <span class="ruby-keyword kw">then</span>
43
+ <span class="ruby-identifier">dcq_args</span> = { <span class="ruby-identifier">:resolver</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@resolver</span>}
44
+ <span class="ruby-ivar">@decoded_query_cache</span> = <span class="ruby-constant">DNSTraverse</span><span class="ruby-operator">::</span><span class="ruby-constant">DecodedQueryCache</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dcq_args</span>)
45
+ <span class="ruby-keyword kw">end</span>
46
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">serverips</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt"># we know the server weights - we're not resolving</span>
47
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">ip</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">serverips</span> <span class="ruby-keyword kw">do</span>
48
+ <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">ip</span>] = <span class="ruby-value">1.0</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@serverips</span>.<span class="ruby-identifier">length</span>
49
+ <span class="ruby-keyword kw">end</span>
50
+ <span class="ruby-keyword kw">end</span>
51
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-value str">&quot;New resolver object created: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> }
52
+ <span class="ruby-keyword kw">end</span></pre>
53
+ </body>
54
+ </html>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>showstats (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 122</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">showstats</span>
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
16
+ <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">each_object</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-identifier">s</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">class</span>]<span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
18
+ <span class="ruby-identifier">s</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">class</span>]= <span class="ruby-identifier">s</span>[<span class="ruby-identifier">o</span>.<span class="ruby-identifier">class</span>] <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-identifier">s</span>.<span class="ruby-identifier">sort</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">b</span>[<span class="ruby-value">1</span>]}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">|</span>
21
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{c[1]} #{c[0]}&quot;</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span></pre>
24
+ </body>
25
+ </html>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>cleanup (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 134</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cleanup</span>(<span class="ruby-identifier">args</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;cleaning: #{self}&quot;</span> }
16
+ <span class="ruby-ivar">@infocache</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:infocache</span>]
17
+ <span class="ruby-ivar">@cacheable_good</span> = <span class="ruby-ivar">@cacheable_bad</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:cacheable</span>]
18
+ <span class="ruby-ivar">@starters</span> = <span class="ruby-ivar">@starters_bailiwick</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:starters</span>]
19
+ <span class="ruby-ivar">@auth_ns</span> = <span class="ruby-ivar">@auth_soa</span> = <span class="ruby-ivar">@auth_other</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:auth</span>]
20
+ <span class="ruby-ivar">@children</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:children</span>]
21
+ <span class="ruby-ivar">@resolves</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:resolves</span>]
22
+ <span class="ruby-ivar">@responses</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:responses</span>]
23
+ <span class="ruby-ivar">@decoded_query_cache</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:decoded_query_cache</span>]
24
+ <span class="ruby-ivar">@resolver</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:resolver</span>]
25
+ <span class="ruby-keyword kw">end</span></pre>
26
+ </body>
27
+ </html>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>inside_bailiwick? (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 147</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inside_bailiwick?</span>(<span class="ruby-identifier">name</span>)
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@bailiwick</span>.<span class="ruby-identifier">nil?</span>
16
+ <span class="ruby-identifier">bwend</span> = <span class="ruby-node">&quot;.#{@bailiwick}&quot;</span>
17
+ <span class="ruby-identifier">namestr</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
18
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namestr</span>.<span class="ruby-identifier">casecmp</span>(<span class="ruby-ivar">@bailiwick</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
19
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namestr</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/#{bwend}$/i</span>
20
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
21
+ <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>noglue? (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 156</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">noglue?</span>
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@serverips</span>
16
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">inside_bailiwick?</span>(<span class="ruby-ivar">@server</span>)
17
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
18
+ <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>resolve (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 163</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resolve</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;This Referral object has already been resolved&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resolved?</span>
16
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">noglue?</span> <span class="ruby-keyword kw">then</span>
17
+ <span class="ruby-comment cmt"># foo.net IN NS ns.foo.net - no IP cached &amp; no glue = failure</span>
18
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;Attempt to resolve #{@server} with a bailiwick referral &quot;</span> <span class="ruby-operator">+</span>
19
+ <span class="ruby-node">&quot; of #{bailiwick} - no glue record provided&quot;</span> }
20
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
21
+ <span class="ruby-keyword kw">end</span>
22
+ <span class="ruby-identifier">refid</span> = <span class="ruby-node">&quot;#{@refid}.0&quot;</span>
23
+ <span class="ruby-identifier">child_refid</span> = <span class="ruby-value">1</span>
24
+ <span class="ruby-identifier">starters</span>, <span class="ruby-identifier">newbailiwick</span> = <span class="ruby-ivar">@infocache</span>.<span class="ruby-identifier">get_startservers</span>(<span class="ruby-ivar">@server</span>)
25
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;Resolving #{@server} type #{@nsatype} &quot;</span> }
26
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">starter</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">starters</span> <span class="ruby-keyword kw">do</span>
27
+ <span class="ruby-identifier">r</span> = <span class="ruby-identifier">make_referral</span>(<span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">starter</span>[<span class="ruby-identifier">:name</span>],
28
+ <span class="ruby-identifier">:serverips</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">starter</span>[<span class="ruby-identifier">:ips</span>],
29
+ <span class="ruby-identifier">:referral_resolution</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
30
+ <span class="ruby-identifier">:qname</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@server</span>, <span class="ruby-identifier">:qclass</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'IN'</span>,
31
+ <span class="ruby-identifier">:qtype</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@nsatype</span>, <span class="ruby-identifier">:bailiwick</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">newbailiwick</span>,
32
+ <span class="ruby-identifier">:refid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{refid}.#{child_refid}&quot;</span>)
33
+ (<span class="ruby-ivar">@resolves</span><span class="ruby-operator">||=</span> []) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">r</span>
34
+ <span class="ruby-identifier">child_refid</span><span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
35
+ <span class="ruby-keyword kw">end</span>
36
+ <span class="ruby-comment cmt"># return a set of Referral objects that need to be processed</span>
37
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@resolves</span>
38
+ <span class="ruby-keyword kw">end</span></pre>
39
+ </body>
40
+ </html>
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>resolve_calculate (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 189</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resolve_calculate</span>
15
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;Calculating resolution: #{self}&quot;</span> }
16
+ <span class="ruby-comment cmt"># create stats_resolve containing all the statistics of the resolution</span>
17
+ <span class="ruby-ivar">@stats_resolve</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">noglue?</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt"># in-bailiwick referral without glue</span>
19
+ <span class="ruby-identifier">r</span> = <span class="ruby-constant">DNSTraverse</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span><span class="ruby-operator">::</span><span class="ruby-constant">NoGlue</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:qname</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@qname</span>,
20
+ <span class="ruby-identifier">:qclass</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@qclass</span>,
21
+ <span class="ruby-identifier">:qtype</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@qtype</span>,
22
+ <span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@server</span>,
23
+ <span class="ruby-identifier">:ip</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@parent_ip</span>,
24
+ <span class="ruby-identifier">:bailiwick</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@bailiwick</span>)
25
+ <span class="ruby-ivar">@stats_resolve</span>[<span class="ruby-identifier">r</span>.<span class="ruby-identifier">stats_key</span>] = { <span class="ruby-identifier">:prob</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1.0</span>, <span class="ruby-identifier">:response</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">r</span>,
26
+ <span class="ruby-identifier">:referral</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span> }
27
+ <span class="ruby-keyword kw">else</span>
28
+ <span class="ruby-comment cmt"># normal resolve - combine children's statistics in to @stats_resolve</span>
29
+ <span class="ruby-identifier">stats_calculate_children</span>(<span class="ruby-ivar">@stats_resolve</span>, <span class="ruby-ivar">@resolves</span>, <span class="ruby-value">1.0</span>)
30
+ <span class="ruby-keyword kw">end</span>
31
+ <span class="ruby-comment cmt"># now use this data to work out %age of each IP address returned</span>
32
+ <span class="ruby-ivar">@serverweights</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
33
+ <span class="ruby-ivar">@stats_resolve</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
34
+ <span class="ruby-comment cmt"># key = IP or key:blah, data is hash containing :prob, etc.</span>
35
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:response</span>].<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:answered</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt"># RR records</span>
36
+ <span class="ruby-comment cmt"># there were some answers - so add the probabilities in</span>
37
+ <span class="ruby-identifier">answers</span> = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:response</span>].<span class="ruby-identifier">answers</span> <span class="ruby-comment cmt"># weight RRs evenly</span>
38
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">rr</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">answers</span> <span class="ruby-keyword kw">do</span>
39
+ <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">rr</span>.<span class="ruby-identifier">address</span>.<span class="ruby-identifier">to_s</span>]<span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
40
+ <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">rr</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">:prob</span>] <span class="ruby-operator">/</span> <span class="ruby-identifier">answers</span>.<span class="ruby-identifier">length</span>
41
+ <span class="ruby-keyword kw">end</span>
42
+ <span class="ruby-keyword kw">else</span>
43
+ <span class="ruby-comment cmt"># there were no answers - use the special key and record probabilities</span>
44
+ <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">key</span>]<span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
45
+ <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">key</span>]<span class="ruby-operator">+=</span> <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:prob</span>]
46
+ <span class="ruby-keyword kw">end</span>
47
+ <span class="ruby-keyword kw">end</span>
48
+ <span class="ruby-ivar">@serverips</span> = <span class="ruby-ivar">@serverweights</span>.<span class="ruby-identifier">keys</span>
49
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;Calculating resolution (answer): #{@serverips.join(',')}&quot;</span> }
50
+ <span class="ruby-keyword kw">end</span></pre>
51
+ </body>
52
+ </html>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>stats_calculate_children (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 227</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stats_calculate_children</span>(<span class="ruby-identifier">stats</span>, <span class="ruby-identifier">children</span>, <span class="ruby-identifier">weight</span>)
15
+ <span class="ruby-identifier">percent</span> = (<span class="ruby-value">1.0</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">length</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">weight</span>
16
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">child</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">children</span> <span class="ruby-keyword kw">do</span>
17
+ <span class="ruby-identifier">child</span>.<span class="ruby-identifier">stats</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">stats</span>[<span class="ruby-identifier">key</span>] <span class="ruby-keyword kw">then</span>
19
+ <span class="ruby-comment cmt"># just copy the child's statistics for this key</span>
20
+ <span class="ruby-identifier">stats</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">dup</span>
21
+ <span class="ruby-identifier">stats</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:prob</span>]<span class="ruby-operator">*=</span> <span class="ruby-identifier">percent</span>
22
+ <span class="ruby-keyword kw">else</span>
23
+ <span class="ruby-identifier">stats</span>[<span class="ruby-identifier">key</span>][<span class="ruby-identifier">:prob</span>]<span class="ruby-operator">+=</span> <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:prob</span>] <span class="ruby-operator">*</span> <span class="ruby-identifier">percent</span>
24
+ <span class="ruby-keyword kw">end</span>
25
+ <span class="ruby-keyword kw">end</span>
26
+ <span class="ruby-keyword kw">end</span>
27
+ <span class="ruby-keyword kw">end</span></pre>
28
+ </body>
29
+ </html>
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>answer_calculate (DNSTraverse::Referral)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/dnstraverse/referral.rb, line 242</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">answer_calculate</span>
15
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-node">&quot;Calculating answer: #{self}&quot;</span> }
16
+ <span class="ruby-ivar">@stats</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
17
+
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@server</span> <span class="ruby-keyword kw">then</span>
19
+ <span class="ruby-comment cmt"># special case - rootroot, no actual IPs, just root referrals</span>
20
+ <span class="ruby-identifier">stats_calculate_children</span>(<span class="ruby-ivar">@stats</span>, <span class="ruby-ivar">@children</span>[<span class="ruby-identifier">:rootroot</span>], <span class="ruby-value">1.0</span>)
21
+ <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
22
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-identifier">sprintf</span> <span class="ruby-value str">&quot;Answer: %.2f%% %s\n&quot;</span>, <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:prob</span>] <span class="ruby-operator">*</span> <span class="ruby-value">100</span>, <span class="ruby-identifier">key</span> }
23
+ <span class="ruby-keyword kw">end</span>
24
+ <span class="ruby-keyword kw">return</span>
25
+ <span class="ruby-keyword kw">end</span>
26
+ <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">ip</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@serverips</span> <span class="ruby-keyword kw">do</span>
27
+ <span class="ruby-identifier">serverweight</span> = <span class="ruby-ivar">@serverweights</span>[<span class="ruby-identifier">ip</span>] <span class="ruby-comment cmt"># set at initialize or at resolve</span>
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ip</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^key:/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt"># resolve failed for some reason</span>
29
+ <span class="ruby-comment cmt"># pull out the statistics on the resolution and copy over</span>
30
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;duplicate key found&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stats</span>[<span class="ruby-identifier">ip</span>] <span class="ruby-comment cmt"># assertion</span>
31
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stats_resolve</span>[<span class="ruby-identifier">ip</span>][<span class="ruby-identifier">:prob</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">serverweight</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt"># assertion</span>
32
+ <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{@stats_resolve[ip][:prob]} vs #{serverweight}&quot;</span>
33
+ <span class="ruby-ivar">@stats_resolve</span>[<span class="ruby-identifier">ip</span>].<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
34
+ <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">a</span>
35
+ <span class="ruby-keyword kw">end</span>
36
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;unexpected probability&quot;</span>
37
+ <span class="ruby-keyword kw">end</span>
38
+ <span class="ruby-ivar">@stats</span>[<span class="ruby-identifier">ip</span>] = <span class="ruby-ivar">@stats_resolve</span>[<span class="ruby-identifier">ip</span>].<span class="ruby-identifier">dup</span>
39
+ <span class="ruby-keyword kw">next</span>
40
+ <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@children</span>[<span class="ruby-identifier">ip</span>] <span class="ruby-keyword kw">then</span>
42
+ <span class="ruby-identifier">stats_calculate_children</span>(<span class="ruby-ivar">@stats</span>, <span class="ruby-ivar">@children</span>[<span class="ruby-identifier">ip</span>], <span class="ruby-identifier">serverweight</span>)
43
+ <span class="ruby-keyword kw">else</span>
44
+ <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@responses</span>[<span class="ruby-identifier">ip</span>]
45
+ <span class="ruby-ivar">@stats</span>[<span class="ruby-identifier">response</span>.<span class="ruby-identifier">stats_key</span>] = { <span class="ruby-identifier">:prob</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">serverweight</span>,
46
+ <span class="ruby-identifier">:response</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">response</span>, <span class="ruby-identifier">:referral</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span> }
47
+ <span class="ruby-keyword kw">end</span>
48
+ <span class="ruby-keyword kw">end</span>
49
+ <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
50
+ <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-identifier">sprintf</span> <span class="ruby-value str">&quot;Answer: %.2f%% %s\n&quot;</span>, <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:prob</span>] <span class="ruby-operator">*</span> <span class="ruby-value">100</span>, <span class="ruby-identifier">key</span> }
51
+ <span class="ruby-keyword kw">end</span>
52
+ <span class="ruby-keyword kw">end</span></pre>
53
+ </body>
54
+ </html>