-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
103 lines (82 loc) · 1.57 KB
/
test.rb
File metadata and controls
103 lines (82 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /usr/bin/ruby
$:.unshift File.join(File.dirname( __FILE__), 'lib')
require 'dnstest'
require 'pp'
class Log
def debug(str)
puts str
end
def info(str)
puts str
end
def notice(str)
puts str
end
def warn(str)
puts str
end
def error(str)
puts str
end
def crit(str)
puts str
end
end
#class Log
#
# def initialize
# @text = ''
# end
#
# def debug(str)
# @text << str
# end
#
# def info(str)
# @text << str
# end
#
# def to_s
# @text
# end
#end
def filter_trace(trace)
trace[:found_authorities].each do |auth_name,auth_addrs|
auth_addrs.each do |auth_addr,auth_protos|
auth_protos.each do |auth_proto,auth|
auth[:soa_packet].instance_eval do
def pretty_print(pp)
pp.text '<Filtered...>'
end
end
end
end
end
trace[:found_serials].each do |soa_serial,q|
q[:response].instance_eval do
def pretty_print(pp)
pp.text '<Filtered...>'
end
end
if q[:sub]
filter_trace(q[:sub])
end
end
end
log = Log.new
a = DnsTest::Tester.new(:log => log, :include_packets => false, :include_packets_text => false)
a.tcp = false
#a.run_test("news.uli.it.", "A")
a.run_test("www.voismart.it.", "A")
puts "############# Result ##########"
require 'json'
File.open('ggg', 'w') do |f|
f.write a.trace.to_json(:max_nesting => 100)
end
#filter_trace a.trace
pp a.trace
puts "############# Answer ##########"
puts a.find_answer_in_trace
#puts "############# Authorities #########"
#pp a.zones
puts "###############################"