dnsruby 1.55 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +96 -0
- data/Rakefile +30 -29
- data/demo/axfr.rb +93 -93
- data/demo/check_soa.rb +99 -99
- data/demo/check_zone.rb +59 -59
- data/demo/digdlv.rb +43 -43
- data/demo/digroot.rb +34 -34
- data/demo/example_recurse.rb +14 -14
- data/demo/mresolv.rb +30 -30
- data/demo/mx.rb +31 -31
- data/demo/rubydig.rb +37 -37
- data/demo/to_resolve.txt +3088 -3088
- data/demo/trace_dns.rb +46 -46
- data/lib/dnsruby.rb +161 -526
- data/lib/dnsruby/DNS.rb +305 -0
- data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
- data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
- data/lib/dnsruby/code_mappers.rb +295 -0
- data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
- data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
- data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
- data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
- data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
- data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
- data/lib/dnsruby/message/decoder.rb +164 -0
- data/lib/dnsruby/message/encoder.rb +75 -0
- data/lib/dnsruby/message/header.rb +249 -0
- data/lib/dnsruby/message/message.rb +629 -0
- data/lib/dnsruby/message/question.rb +86 -0
- data/lib/dnsruby/message/section.rb +96 -0
- data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
- data/lib/dnsruby/packet_sender.rb +661 -0
- data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
- data/lib/dnsruby/resolv.rb +113 -0
- data/lib/dnsruby/resolver.rb +1192 -0
- data/lib/dnsruby/resource/A.rb +56 -0
- data/lib/dnsruby/resource/AAAA.rb +54 -0
- data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
- data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
- data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
- data/lib/dnsruby/resource/DLV.rb +27 -0
- data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
- data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
- data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
- data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
- data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
- data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
- data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
- data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
- data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
- data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
- data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
- data/lib/dnsruby/resource/NSEC.rb +275 -0
- data/lib/dnsruby/resource/NSEC3.rb +332 -0
- data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
- data/lib/dnsruby/resource/OPT.rb +272 -0
- data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
- data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
- data/lib/dnsruby/resource/RR.rb +421 -0
- data/lib/dnsruby/resource/RRSIG.rb +275 -0
- data/lib/dnsruby/resource/RRSet.rb +190 -0
- data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
- data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
- data/lib/dnsruby/resource/SPF.rb +29 -0
- data/lib/dnsruby/resource/SRV.rb +112 -0
- data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
- data/lib/dnsruby/resource/TKEY.rb +163 -0
- data/lib/dnsruby/resource/TSIG.rb +593 -0
- data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
- data/lib/dnsruby/resource/X25.rb +55 -0
- data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
- data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
- data/lib/dnsruby/resource/resource.rb +25 -0
- data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
- data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
- data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
- data/lib/dnsruby/the_log.rb +44 -0
- data/lib/dnsruby/update.rb +278 -0
- data/lib/dnsruby/validator_thread.rb +124 -0
- data/lib/dnsruby/version.rb +3 -0
- data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
- data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
- data/test/spec_helper.rb +16 -0
- data/test/tc_axfr.rb +31 -34
- data/test/tc_cache.rb +32 -32
- data/test/tc_dlv.rb +28 -28
- data/test/tc_dns.rb +73 -76
- data/test/tc_dnskey.rb +31 -32
- data/test/tc_dnsruby.rb +50 -44
- data/test/tc_ds.rb +36 -36
- data/test/tc_escapedchars.rb +252 -255
- data/test/tc_hash.rb +17 -21
- data/test/tc_header.rb +48 -57
- data/test/tc_hip.rb +19 -22
- data/test/tc_ipseckey.rb +18 -21
- data/test/tc_keith.rb +300 -0
- data/test/tc_message.rb +87 -0
- data/test/tc_misc.rb +83 -87
- data/test/tc_name.rb +81 -84
- data/test/tc_naptr.rb +18 -21
- data/test/tc_nsec.rb +55 -55
- data/test/tc_nsec3.rb +23 -24
- data/test/tc_nsec3param.rb +20 -21
- data/test/tc_packet.rb +90 -93
- data/test/tc_packet_unique_push.rb +48 -51
- data/test/tc_question.rb +30 -33
- data/test/tc_queue.rb +16 -17
- data/test/tc_recur.rb +16 -17
- data/test/tc_res_config.rb +38 -41
- data/test/tc_res_env.rb +29 -32
- data/test/tc_res_file.rb +26 -29
- data/test/tc_res_opt.rb +62 -65
- data/test/tc_resolver.rb +287 -242
- data/test/tc_rr-opt.rb +70 -63
- data/test/tc_rr-txt.rb +68 -71
- data/test/tc_rr-unknown.rb +45 -48
- data/test/tc_rr.rb +76 -70
- data/test/tc_rrset.rb +21 -22
- data/test/tc_rrsig.rb +19 -20
- data/test/tc_single_resolver.rb +294 -297
- data/test/tc_soak.rb +199 -202
- data/test/tc_soak_base.rb +29 -34
- data/test/tc_sshfp.rb +20 -23
- data/test/tc_tcp.rb +32 -35
- data/test/tc_tkey.rb +41 -44
- data/test/tc_tsig.rb +81 -84
- data/test/tc_update.rb +108 -111
- data/test/tc_validator.rb +29 -29
- data/test/tc_verifier.rb +81 -82
- data/test/ts_dnsruby.rb +16 -15
- data/test/ts_offline.rb +62 -63
- data/test/ts_online.rb +115 -115
- metadata +155 -90
- data/README +0 -59
- data/lib/Dnsruby/DNS.rb +0 -305
- data/lib/Dnsruby/PacketSender.rb +0 -656
- data/lib/Dnsruby/Resolver.rb +0 -1189
- data/lib/Dnsruby/TheLog.rb +0 -44
- data/lib/Dnsruby/message.rb +0 -1230
- data/lib/Dnsruby/resource/A.rb +0 -56
- data/lib/Dnsruby/resource/AAAA.rb +0 -54
- data/lib/Dnsruby/resource/DLV.rb +0 -27
- data/lib/Dnsruby/resource/NSEC.rb +0 -298
- data/lib/Dnsruby/resource/NSEC3.rb +0 -340
- data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
- data/lib/Dnsruby/resource/OPT.rb +0 -213
- data/lib/Dnsruby/resource/RRSIG.rb +0 -275
- data/lib/Dnsruby/resource/SPF.rb +0 -29
- data/lib/Dnsruby/resource/SRV.rb +0 -112
- data/lib/Dnsruby/resource/TKEY.rb +0 -163
- data/lib/Dnsruby/resource/TSIG.rb +0 -593
- data/lib/Dnsruby/resource/X25.rb +0 -55
- data/lib/Dnsruby/resource/resource.rb +0 -678
- data/lib/Dnsruby/update.rb +0 -278
- data/lib/Dnsruby/validator_thread.rb +0 -124
data/demo/check_soa.rb
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
|
2
|
-
#Copyright 2007 Nominet UK
|
3
|
-
#
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
#you may not use this file except in compliance with the License.
|
6
|
-
#You may obtain a copy of the License at
|
7
|
-
#
|
1
|
+
# --
|
2
|
+
# Copyright 2007 Nominet UK
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
#See the License for the specific language governing permissions and
|
14
|
-
#limitations under the License.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
#check_soa - Check a domain's nameservers
|
21
|
-
#
|
22
|
-
|
23
|
-
#
|
24
|
-
#check_soa domain
|
25
|
-
#
|
26
|
-
|
27
|
-
#
|
28
|
-
#check_soa queries each of a domain's nameservers for the Start
|
29
|
-
#of Authority (SOA) record and prints the serial number. Errors
|
30
|
-
#are printed for nameservers that couldn't be reached or didn't
|
31
|
-
#answer authoritatively.
|
32
|
-
#
|
33
|
-
|
34
|
-
#
|
35
|
-
#The original Bourne Shell and C versions were printed in
|
36
|
-
#"DNS and BIND" by Paul Albitz & Cricket Liu.
|
37
|
-
#
|
38
|
-
#This Perl version was written by Michael Fuhr <mike@fuhr.org>.
|
39
|
-
#
|
40
|
-
|
41
|
-
#
|
42
|
-
#axfr, check_zone, mresolv, mx, perldig, Net::DNS
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
17
|
+
|
18
|
+
# = NAME
|
19
|
+
#
|
20
|
+
# check_soa - Check a domain's nameservers
|
21
|
+
#
|
22
|
+
# = SYNOPSIS
|
23
|
+
#
|
24
|
+
# check_soa domain
|
25
|
+
#
|
26
|
+
# = DESCRIPTION
|
27
|
+
#
|
28
|
+
# check_soa queries each of a domain's nameservers for the Start
|
29
|
+
# of Authority (SOA) record and prints the serial number. Errors
|
30
|
+
# are printed for nameservers that couldn't be reached or didn't
|
31
|
+
# answer authoritatively.
|
32
|
+
#
|
33
|
+
# = AUTHOR
|
34
|
+
#
|
35
|
+
# The original Bourne Shell and C versions were printed in
|
36
|
+
# "DNS and BIND" by Paul Albitz & Cricket Liu.
|
37
|
+
#
|
38
|
+
# This Perl version was written by Michael Fuhr <mike@fuhr.org>.
|
39
|
+
#
|
40
|
+
# = SEE ALSO
|
41
|
+
#
|
42
|
+
# axfr, check_zone, mresolv, mx, perldig, Net::DNS
|
43
43
|
|
44
44
|
require 'dnsruby'
|
45
45
|
|
46
|
-
|
46
|
+
# ------------------------------------------------------------------------------
|
47
47
|
# Get the domain from the command line.
|
48
|
-
|
48
|
+
# ------------------------------------------------------------------------------
|
49
49
|
|
50
|
-
if ARGV.length ==1
|
50
|
+
if ARGV.length ==1
|
51
51
|
domain = ARGV[0]
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
52
|
+
|
53
|
+
# ------------------------------------------------------------------------------
|
54
|
+
# Find all the nameservers for the domain.
|
55
|
+
# ------------------------------------------------------------------------------
|
56
|
+
|
57
57
|
res = Dnsruby::Resolver.new
|
58
|
-
|
59
|
-
#
|
58
|
+
|
59
|
+
# res.defnames=(0)
|
60
60
|
res.retry_times=(2)
|
61
61
|
ns_req = nil
|
62
62
|
begin
|
@@ -68,27 +68,27 @@ if ARGV.length ==1
|
|
68
68
|
if (ns_req.header.ancount == 0)
|
69
69
|
print "No nameservers found for #{domain}\n"
|
70
70
|
return
|
71
|
-
end
|
72
|
-
|
73
|
-
#
|
71
|
+
end
|
72
|
+
|
73
|
+
# Send out non-recursive queries
|
74
74
|
res.recurse=(0)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
|
80
|
-
|
75
|
+
|
76
|
+
|
77
|
+
# ------------------------------------------------------------------------------
|
78
|
+
# Check the SOA record on each nameserver.
|
79
|
+
# ------------------------------------------------------------------------------
|
80
|
+
|
81
81
|
(ns_req.answer.select {|r| r.type == "NS"}).each do |nsrr|
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
|
82
|
+
|
83
|
+
# ----------------------------------------------------------------------
|
84
|
+
# Set the resolver to query this nameserver.
|
85
|
+
# ----------------------------------------------------------------------
|
86
86
|
ns = nsrr.domainname
|
87
|
-
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
87
|
+
|
88
|
+
# In order to lookup the IP(s) of the nameserver, we need a Resolver
|
89
|
+
# object that is set to our local, recursive nameserver. So we create
|
90
|
+
# a new object just to do that.
|
91
|
+
|
92
92
|
local_res = Dnsruby::Resolver.new
|
93
93
|
a_req=nil
|
94
94
|
begin
|
@@ -97,20 +97,20 @@ if ARGV.length ==1
|
|
97
97
|
print "Can not find address for #{ns}: #{e}\n"
|
98
98
|
next
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
(a_req.answer.select {|r| r.type == 'A'}).each do |r|
|
102
102
|
ip = r.address
|
103
|
-
|
104
|
-
#
|
105
|
-
|
106
|
-
|
103
|
+
# ----------------------------------------------------------------------
|
104
|
+
# Ask this IP.
|
105
|
+
# ----------------------------------------------------------------------
|
106
|
+
|
107
107
|
res.nameserver=(ip.to_s)
|
108
|
-
|
108
|
+
|
109
109
|
print "#{ns} (#{ip}): "
|
110
|
-
|
111
|
-
|
112
|
-
#
|
113
|
-
|
110
|
+
|
111
|
+
# ----------------------------------------------------------------------
|
112
|
+
# Get the SOA record.
|
113
|
+
# ----------------------------------------------------------------------
|
114
114
|
soa_req=nil
|
115
115
|
begin
|
116
116
|
soa_req = res.query(domain, 'SOA', 'IN')
|
@@ -118,38 +118,38 @@ if ARGV.length ==1
|
|
118
118
|
print "Error : #{e}\n"
|
119
119
|
next
|
120
120
|
end
|
121
|
-
|
122
|
-
|
123
|
-
#
|
124
|
-
|
125
|
-
|
121
|
+
|
122
|
+
# ----------------------------------------------------------------------
|
123
|
+
# Is this nameserver authoritative for the domain?
|
124
|
+
# ----------------------------------------------------------------------
|
125
|
+
|
126
126
|
unless (soa_req.header.aa)
|
127
127
|
print "isn't authoritative for #{domain}\n"
|
128
128
|
next
|
129
129
|
end
|
130
|
-
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
|
130
|
+
|
131
|
+
# ----------------------------------------------------------------------
|
132
|
+
# We should have received exactly one answer.
|
133
|
+
# ----------------------------------------------------------------------
|
134
|
+
|
135
135
|
unless (soa_req.header.ancount == 1)
|
136
136
|
print "expected 1 answer, got ", soa_req.header.ancount, "\n"
|
137
137
|
next
|
138
138
|
end
|
139
|
-
|
140
|
-
|
141
|
-
#
|
142
|
-
|
143
|
-
|
139
|
+
|
140
|
+
# ----------------------------------------------------------------------
|
141
|
+
# Did we receive an SOA record?
|
142
|
+
# ----------------------------------------------------------------------
|
143
|
+
|
144
144
|
unless ((soa_req.answer)[0].type == "SOA")
|
145
145
|
print "expected SOA, got ", (soa_req.answer)[0].type, "\n"
|
146
146
|
next
|
147
147
|
end
|
148
|
-
|
149
|
-
|
150
|
-
#
|
151
|
-
|
152
|
-
|
148
|
+
|
149
|
+
# ----------------------------------------------------------------------
|
150
|
+
# Print the serial number.
|
151
|
+
# ----------------------------------------------------------------------
|
152
|
+
|
153
153
|
print "has serial number ", (soa_req.answer)[0].serial, "\n"
|
154
154
|
end
|
155
155
|
end
|
data/demo/check_zone.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
|
2
|
-
#Copyright 2007 Nominet UK
|
3
|
-
#
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
#you may not use this file except in compliance with the License.
|
6
|
-
#You may obtain a copy of the License at
|
7
|
-
#
|
1
|
+
# --
|
2
|
+
# Copyright 2007 Nominet UK
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
#See the License for the specific language governing permissions and
|
14
|
-
#limitations under the License.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
#check_zone - Check a DNS zone for errors
|
20
|
-
#
|
21
|
-
|
22
|
-
#
|
23
|
-
#check_zone [ -r ] <domain>
|
24
|
-
#
|
25
|
-
|
26
|
-
#
|
27
|
-
#Checks a DNS zone for errors. Current checks are:
|
28
|
-
#
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
#A records.
|
33
|
-
#
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
#
|
38
|
-
|
39
|
-
#
|
40
|
-
#Michael Fuhr <mike@fuhr.org>
|
41
|
-
#(Ruby version AlexD, Nominet UK)
|
42
|
-
#
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
17
|
+
# = NAME
|
18
|
+
#
|
19
|
+
# check_zone - Check a DNS zone for errors
|
20
|
+
#
|
21
|
+
# = SYNOPSIS
|
22
|
+
#
|
23
|
+
# check_zone [ -r ] <domain>
|
24
|
+
#
|
25
|
+
# = DESCRIPTION
|
26
|
+
#
|
27
|
+
# Checks a DNS zone for errors. Current checks are:
|
28
|
+
#
|
29
|
+
# * Checks that all A records have corresponding PTR records.
|
30
|
+
#
|
31
|
+
# * Checks that hosts listed in NS, MX, and CNAME records have
|
32
|
+
# A records.
|
33
|
+
#
|
34
|
+
# = OPTIONS
|
35
|
+
#
|
36
|
+
# * -r Perform a recursive check on subdomains.
|
37
|
+
#
|
38
|
+
# = AUTHOR
|
39
|
+
#
|
40
|
+
# Michael Fuhr <mike@fuhr.org>
|
41
|
+
# (Ruby version AlexD, Nominet UK)
|
42
|
+
#
|
43
43
|
|
44
44
|
|
45
45
|
require 'dnsruby'
|
@@ -48,13 +48,13 @@ require 'getoptLong'
|
|
48
48
|
def check_domain(args)
|
49
49
|
domain = args[0]
|
50
50
|
klass = "IN"
|
51
|
-
if (args.length > 1)
|
51
|
+
if (args.length > 1)
|
52
52
|
klass = args[1]
|
53
53
|
end
|
54
54
|
print "----------------------------------------------------------------------\n"
|
55
55
|
print "#{domain} (class #{klass}\n"
|
56
56
|
print "\n"
|
57
|
-
|
57
|
+
|
58
58
|
res = Dnsruby::Resolver.new
|
59
59
|
res.retry_times=(2)
|
60
60
|
nspack = nil
|
@@ -64,16 +64,16 @@ def check_domain(args)
|
|
64
64
|
print "Couldn't find nameservers for #{domain}: #{e}\n"
|
65
65
|
return
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
print "nameservers (will request zone from first available):\n"
|
69
69
|
ns=""
|
70
70
|
(nspack.answer.select {|r| r.type == "NS"}).each do |ns|
|
71
71
|
print "\t", ns.domainname, "\n"
|
72
72
|
end
|
73
73
|
print "\n"
|
74
|
-
|
74
|
+
|
75
75
|
res.nameserver= (nspack.answer.select {|i| i.type == "NS"}).collect {|i| i.domainname.to_s}
|
76
|
-
|
76
|
+
|
77
77
|
zt = Dnsruby::ZoneTransfer.new
|
78
78
|
zt.server=(nspack.answer.select {|i| i.type == "NS"}).collect {|i| i.domainname.to_s}
|
79
79
|
zone = zt.transfer(domain) # , klass)
|
@@ -81,31 +81,31 @@ def check_domain(args)
|
|
81
81
|
print "Zone transfer failed: ", res.errorstring, "\n"
|
82
82
|
return
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
print "checking PTR records\n"
|
86
86
|
check_ptr(domain, klass, zone)
|
87
87
|
print "\n"
|
88
|
-
|
88
|
+
|
89
89
|
print "checking NS records\n"
|
90
90
|
check_ns(domain, klass, zone)
|
91
91
|
print "\n"
|
92
|
-
|
92
|
+
|
93
93
|
print "checking MX records\n"
|
94
94
|
check_mx(domain, klass, zone)
|
95
95
|
print "\n"
|
96
|
-
|
96
|
+
|
97
97
|
print "checking CNAME records\n"
|
98
98
|
check_cname(domain, klass, zone)
|
99
99
|
print "\n"
|
100
|
-
|
100
|
+
|
101
101
|
if (@recurse)
|
102
102
|
print "checking subdomains\n\n"
|
103
103
|
subdomains = Hash.new
|
104
|
-
#
|
104
|
+
# foreach (grep { $_->type eq "NS" and $_->name ne $domain } @zone) {
|
105
105
|
(zone.select {|i| i.type == "NS" && i.name != domain}).each do |z|
|
106
106
|
subdomains[z.name] = 1
|
107
107
|
end
|
108
|
-
#
|
108
|
+
# foreach (sort keys %subdomains) {
|
109
109
|
subdomains.keys.sort.each do |k|
|
110
110
|
check_domain(k, klass)
|
111
111
|
end
|
@@ -114,7 +114,7 @@ end
|
|
114
114
|
|
115
115
|
def check_ptr(domain, klass, zone)
|
116
116
|
res = Dnsruby::Resolver.new
|
117
|
-
#
|
117
|
+
# foreach $rr (grep { $_->type eq "A" } @zone) {
|
118
118
|
(zone.select {|z| z.type == "A"}).each do |rr|
|
119
119
|
host = rr.name
|
120
120
|
addr = rr.address
|
@@ -130,7 +130,7 @@ end
|
|
130
130
|
|
131
131
|
def check_ns(domain, klass, zone)
|
132
132
|
res = Dnsruby::Resolver.new
|
133
|
-
#
|
133
|
+
# foreach $rr (grep { $_->type eq "NS" } @zone) {
|
134
134
|
(zone.select { |z| z.type == "NS" }).each do |rr|
|
135
135
|
ans = res.query(rr.nsdname, "A", klass)
|
136
136
|
print "\t", rr.nsdname, " has no A record\n" if (ans.header.ancount < 1)
|
@@ -139,7 +139,7 @@ end
|
|
139
139
|
|
140
140
|
def check_mx(domain, klass, zone)
|
141
141
|
res = Dnsruby::Resolver.new
|
142
|
-
#
|
142
|
+
# foreach $rr (grep { $_->type eq "MX" } @zone) {
|
143
143
|
zone.select {|z| z.type == "MX"}.each do |rr|
|
144
144
|
ans = res.query(rr.exchange, "A", klass)
|
145
145
|
print "\t", rr.exchange, " has no A record\n" if (ans.header.ancount < 1)
|
@@ -148,7 +148,7 @@ end
|
|
148
148
|
|
149
149
|
def check_cname(domain, klass, zone)
|
150
150
|
res = Dnsruby::Resolver.new
|
151
|
-
#
|
151
|
+
# foreach $rr (grep { $_->type eq "CNAME" } @zone)
|
152
152
|
zone.select {|z| z.type == "CNAME"}.each do |rr|
|
153
153
|
ans = res.query(rr.cname, "A", klass)
|
154
154
|
print "\t", rr.cname, " has no A record\n" if (ans.header.ancount < 1)
|
@@ -165,9 +165,9 @@ opts.each do |opt, arg|
|
|
165
165
|
end
|
166
166
|
|
167
167
|
if (ARGV.length >=1 && ARGV.length <=2)
|
168
|
-
|
168
|
+
|
169
169
|
check_domain(ARGV)
|
170
170
|
exit
|
171
|
-
else
|
171
|
+
else
|
172
172
|
print "Usage: #{$0} [ -r ] domain [ class ]\n"
|
173
173
|
end
|