net-dns 0.8.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.rspec +1 -0
- data/.travis.yml +9 -16
- data/CHANGELOG.md +37 -13
- data/LICENSE.txt +56 -0
- data/README.md +94 -77
- data/demo/check_soa.rb +27 -38
- data/demo/threads.rb +3 -7
- data/lib/net/dns/header.rb +86 -110
- data/lib/net/dns/names.rb +31 -31
- data/lib/net/dns/packet.rb +148 -158
- data/lib/net/dns/question.rb +41 -42
- data/lib/net/dns/resolver/socks.rb +47 -55
- data/lib/net/dns/resolver/timeouts.rb +19 -30
- data/lib/net/dns/resolver.rb +151 -176
- data/lib/net/dns/rr/a.rb +45 -55
- data/lib/net/dns/rr/aaaa.rb +39 -50
- data/lib/net/dns/rr/classes.rb +32 -37
- data/lib/net/dns/rr/cname.rb +31 -41
- data/lib/net/dns/rr/hinfo.rb +40 -56
- data/lib/net/dns/rr/mr.rb +31 -42
- data/lib/net/dns/rr/mx.rb +35 -47
- data/lib/net/dns/rr/ns.rb +31 -41
- data/lib/net/dns/rr/null.rb +10 -15
- data/lib/net/dns/rr/ptr.rb +16 -24
- data/lib/net/dns/rr/soa.rb +36 -35
- data/lib/net/dns/rr/srv.rb +18 -19
- data/lib/net/dns/rr/txt.rb +11 -16
- data/lib/net/dns/rr/types.rb +118 -109
- data/lib/net/dns/rr.rb +107 -117
- data/lib/net/dns/version.rb +5 -13
- data/lib/net/dns.rb +6 -11
- metadata +18 -83
- data/.gitignore +0 -8
- data/Gemfile +0 -4
- data/Rakefile +0 -71
- data/fixtures/resolv.conf +0 -4
- data/lib/net/dns/core_ext.rb +0 -52
- data/net-dns.gemspec +0 -35
- data/test/header_test.rb +0 -167
- data/test/names_test.rb +0 -21
- data/test/packet_test.rb +0 -49
- data/test/question_test.rb +0 -83
- data/test/resolver/timeouts_test.rb +0 -109
- data/test/resolver_test.rb +0 -117
- data/test/rr/a_test.rb +0 -113
- data/test/rr/aaaa_test.rb +0 -109
- data/test/rr/classes_test.rb +0 -85
- data/test/rr/cname_test.rb +0 -97
- data/test/rr/hinfo_test.rb +0 -117
- data/test/rr/mr_test.rb +0 -105
- data/test/rr/mx_test.rb +0 -112
- data/test/rr/ns_test.rb +0 -86
- data/test/rr/types_test.rb +0 -69
- data/test/rr_test.rb +0 -131
- data/test/test_helper.rb +0 -4
data/lib/net/dns/rr/mr.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
|
-
|
4
3
|
class RR
|
5
|
-
|
6
4
|
#
|
7
5
|
# = Mail Rename Record (MR)
|
8
6
|
#
|
9
7
|
# Class for DNS MR resource records.
|
10
8
|
#
|
11
9
|
class MR < RR
|
12
|
-
|
13
10
|
# Gets the newname value.
|
14
11
|
#
|
15
12
|
# Returns a String.
|
16
|
-
|
17
|
-
@newname
|
18
|
-
end
|
13
|
+
attr_reader :newname
|
19
14
|
|
20
15
|
# Gets the standardized value for this record,
|
21
16
|
# represented by the value of <tt>newname</tt>.
|
@@ -25,55 +20,49 @@ module Net # :nodoc:
|
|
25
20
|
newname.to_s
|
26
21
|
end
|
27
22
|
|
28
|
-
|
29
23
|
private
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
@newname = check_name(options[:newname])
|
34
|
-
else
|
35
|
-
raise ArgumentError, ":newname field is mandatory"
|
36
|
-
end
|
37
|
-
end
|
25
|
+
def subclass_new_from_hash(options)
|
26
|
+
raise ArgumentError, ":newname field is mandatory" unless options.key?(:newname)
|
38
27
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def subclass_new_from_binary(data, offset)
|
44
|
-
@newname = dn_expand(data,offset)
|
45
|
-
offset
|
46
|
-
end
|
28
|
+
@newname = check_name(options[:newname])
|
29
|
+
end
|
47
30
|
|
31
|
+
def subclass_new_from_string(str)
|
32
|
+
@newname = check_name(str)
|
33
|
+
end
|
48
34
|
|
49
|
-
|
50
|
-
|
51
|
-
|
35
|
+
def subclass_new_from_binary(data, offset)
|
36
|
+
@newname = dn_expand(data, offset)
|
37
|
+
offset
|
38
|
+
end
|
52
39
|
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
def set_type
|
41
|
+
@type = Net::DNS::RR::Types.new("MR")
|
42
|
+
end
|
56
43
|
|
44
|
+
def get_inspect
|
45
|
+
value
|
46
|
+
end
|
57
47
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
name
|
48
|
+
def check_name(input)
|
49
|
+
name = input.to_s
|
50
|
+
unless name =~ /(\w\.?)+\s*$/
|
51
|
+
raise ArgumentError, "Invalid Domain Name `#{name}'"
|
64
52
|
end
|
65
53
|
|
66
|
-
|
67
|
-
|
68
|
-
@rdlength = @newname_pack.size
|
69
|
-
end
|
54
|
+
name
|
55
|
+
end
|
70
56
|
|
71
|
-
|
72
|
-
|
73
|
-
|
57
|
+
def build_pack
|
58
|
+
@newname_pack = pack_name(@newname)
|
59
|
+
@rdlength = @newname_pack.size
|
60
|
+
end
|
74
61
|
|
62
|
+
def get_data
|
63
|
+
@newname_pack
|
64
|
+
end
|
75
65
|
end
|
76
|
-
|
77
66
|
end
|
78
67
|
end
|
79
68
|
end
|
data/lib/net/dns/rr/mx.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#
|
6
5
|
# = Mail Exchange Record (MX)
|
7
6
|
#
|
@@ -12,20 +11,15 @@ module Net # :nodoc:
|
|
12
11
|
# The MX RR is used by SMTP (Mail) Agents to route mail for the domain.
|
13
12
|
#
|
14
13
|
class MX < RR
|
15
|
-
|
16
14
|
# Gets the preference value.
|
17
15
|
#
|
18
16
|
# Returns an Integer.
|
19
|
-
|
20
|
-
@preference
|
21
|
-
end
|
17
|
+
attr_reader :preference
|
22
18
|
|
23
19
|
# Gets the exchange value.
|
24
20
|
#
|
25
21
|
# Returns a String.
|
26
|
-
|
27
|
-
@exchange
|
28
|
-
end
|
22
|
+
attr_reader :exchange
|
29
23
|
|
30
24
|
# Gets the standardized value for this record,
|
31
25
|
# represented by the value of <tt>preference</tt> and <tt>exchange</tt>.
|
@@ -35,58 +29,52 @@ module Net # :nodoc:
|
|
35
29
|
"#{preference} #{exchange}"
|
36
30
|
end
|
37
31
|
|
38
|
-
|
39
32
|
private
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
@preference = options[:preference].to_i
|
44
|
-
@exchange = options[:exchange]
|
45
|
-
else
|
46
|
-
raise ArgumentError, ":preference and :exchange fields are mandatory"
|
47
|
-
end
|
48
|
-
end
|
34
|
+
def subclass_new_from_hash(options)
|
35
|
+
raise ArgumentError, ":preference and :exchange fields are mandatory" unless options.key?(:preference) && options.key?(:exchange)
|
49
36
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
def subclass_new_from_binary(data, offset)
|
55
|
-
@preference = data.unpack("@#{offset} n")[0]
|
56
|
-
offset += 2
|
57
|
-
@exchange, offset = dn_expand(data, offset)
|
58
|
-
offset
|
59
|
-
end
|
37
|
+
@preference = options[:preference].to_i
|
38
|
+
@exchange = options[:exchange]
|
39
|
+
end
|
60
40
|
|
41
|
+
def subclass_new_from_string(str)
|
42
|
+
@preference, @exchange = check_mx(str)
|
43
|
+
end
|
61
44
|
|
62
|
-
|
63
|
-
|
64
|
-
|
45
|
+
def subclass_new_from_binary(data, offset)
|
46
|
+
@preference = data.unpack1("@#{offset} n")
|
47
|
+
offset += 2
|
48
|
+
@exchange, offset = dn_expand(data, offset)
|
49
|
+
offset
|
50
|
+
end
|
65
51
|
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
def set_type
|
53
|
+
@type = Net::DNS::RR::Types.new("MX")
|
54
|
+
end
|
69
55
|
|
56
|
+
def get_inspect
|
57
|
+
value
|
58
|
+
end
|
70
59
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
[$1.to_i, $2]
|
60
|
+
def check_mx(input)
|
61
|
+
str = input.to_s
|
62
|
+
unless str.strip =~ /^(\d+)\s+(\S+)$/
|
63
|
+
raise ArgumentError, "Invalid MX section `#{str}'"
|
77
64
|
end
|
78
65
|
|
79
|
-
|
80
|
-
|
81
|
-
@rdlength = @mx_pack.size
|
82
|
-
end
|
66
|
+
[Regexp.last_match(1).to_i, Regexp.last_match(2)]
|
67
|
+
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def build_pack
|
70
|
+
@mx_pack = [@preference].pack("n") + pack_name(@exchange)
|
71
|
+
@rdlength = @mx_pack.size
|
72
|
+
end
|
87
73
|
|
74
|
+
def get_data
|
75
|
+
@mx_pack
|
76
|
+
end
|
88
77
|
end
|
89
|
-
|
90
78
|
end
|
91
79
|
end
|
92
80
|
end
|
data/lib/net/dns/rr/ns.rb
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#
|
6
5
|
# = Name Server Record (NS)
|
7
6
|
#
|
8
7
|
# Class for DNS NS resource records.
|
9
8
|
#
|
10
9
|
class NS < RR
|
11
|
-
|
12
10
|
# Gets the name server value.
|
13
11
|
#
|
14
12
|
# Returns a String.
|
15
|
-
|
16
|
-
@nsdname
|
17
|
-
end
|
13
|
+
attr_reader :nsdname
|
18
14
|
|
19
15
|
# Gets the standardized value for this record,
|
20
16
|
# represented by the value of <tt>nsdname</tt>.
|
@@ -24,55 +20,49 @@ module Net # :nodoc:
|
|
24
20
|
nsdname.to_s
|
25
21
|
end
|
26
22
|
|
27
|
-
|
28
23
|
private
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
@nsdname = check_name(options[:nsdname])
|
33
|
-
else
|
34
|
-
raise ArgumentError, ":nsdname field is mandatory"
|
35
|
-
end
|
36
|
-
end
|
25
|
+
def subclass_new_from_hash(options)
|
26
|
+
raise ArgumentError, ":nsdname field is mandatory" unless options.key?(:nsdname)
|
37
27
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def subclass_new_from_binary(data, offset)
|
43
|
-
@nsdname, offset = dn_expand(data, offset)
|
44
|
-
offset
|
45
|
-
end
|
28
|
+
@nsdname = check_name(options[:nsdname])
|
29
|
+
end
|
46
30
|
|
31
|
+
def subclass_new_from_string(str)
|
32
|
+
@nsdname = check_name(str)
|
33
|
+
end
|
47
34
|
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
def subclass_new_from_binary(data, offset)
|
36
|
+
@nsdname, offset = dn_expand(data, offset)
|
37
|
+
offset
|
38
|
+
end
|
51
39
|
|
52
|
-
|
53
|
-
|
54
|
-
|
40
|
+
def set_type
|
41
|
+
@type = Net::DNS::RR::Types.new("NS")
|
42
|
+
end
|
55
43
|
|
44
|
+
def get_inspect
|
45
|
+
value
|
46
|
+
end
|
56
47
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
name
|
48
|
+
def check_name(input)
|
49
|
+
name = input.to_s
|
50
|
+
unless name =~ /(\w\.?)+\s*$/ && name =~ /[a-zA-Z]/
|
51
|
+
raise ArgumentError, "Invalid Name Server `#{name}'"
|
63
52
|
end
|
64
53
|
|
65
|
-
|
66
|
-
|
67
|
-
@rdlength = @nsdname_pack.size
|
68
|
-
end
|
54
|
+
name
|
55
|
+
end
|
69
56
|
|
70
|
-
|
71
|
-
|
72
|
-
|
57
|
+
def build_pack
|
58
|
+
@nsdname_pack = pack_name(@nsdname)
|
59
|
+
@rdlength = @nsdname_pack.size
|
60
|
+
end
|
73
61
|
|
62
|
+
def get_data
|
63
|
+
@nsdname_pack
|
64
|
+
end
|
74
65
|
end
|
75
|
-
|
76
66
|
end
|
77
67
|
end
|
78
68
|
end
|
data/lib/net/dns/rr/null.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#------------------------------------------------------------
|
6
5
|
# RR type NULL
|
7
6
|
#------------------------------------------------------------
|
@@ -20,34 +19,30 @@ module Net # :nodoc:
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def get_inspect
|
23
|
-
|
22
|
+
@null.to_s
|
24
23
|
end
|
25
24
|
|
26
25
|
def subclass_new_from_hash(args)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
raise ArgumentError, ":null field is mandatory but missing"
|
31
|
-
end
|
26
|
+
raise ArgumentError, ":null field is mandatory but missing" unless args.key? :null
|
27
|
+
|
28
|
+
@null = args[:null]
|
32
29
|
end
|
33
30
|
|
34
31
|
def subclass_new_from_string(str)
|
35
32
|
@null = str.strip
|
36
33
|
end
|
37
34
|
|
38
|
-
def subclass_new_from_binary(data,offset)
|
39
|
-
@null = data[offset..offset
|
40
|
-
|
35
|
+
def subclass_new_from_binary(data, offset)
|
36
|
+
@null = data[offset..offset + @rdlength]
|
37
|
+
offset + @rdlength
|
41
38
|
end
|
42
39
|
|
43
40
|
private
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
def set_type
|
43
|
+
@type = Net::DNS::RR::Types.new("NULL")
|
44
|
+
end
|
49
45
|
end
|
50
|
-
|
51
46
|
end
|
52
47
|
end
|
53
48
|
end
|
data/lib/net/dns/rr/ptr.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
module Net
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#
|
6
5
|
# = Pointer Record (PTR)
|
7
6
|
#
|
8
7
|
# Class for DNS Pointer (PTR) resource records.
|
9
8
|
#
|
10
|
-
# Pointer records are the opposite of A and AAAA RRs
|
9
|
+
# Pointer records are the opposite of A and AAAA RRs
|
11
10
|
# and are used in Reverse Map zone files to map
|
12
11
|
# an IP address (IPv4 or IPv6) to a host name.
|
13
12
|
#
|
14
13
|
class PTR < RR
|
15
|
-
|
16
14
|
# Gets the PTR value.
|
17
15
|
#
|
18
16
|
# Returns a String.
|
@@ -20,7 +18,7 @@ module Net
|
|
20
18
|
@ptrdname.to_s
|
21
19
|
end
|
22
20
|
|
23
|
-
|
21
|
+
alias ptr ptrdname
|
24
22
|
|
25
23
|
# Gets the standardized value for this record,
|
26
24
|
# represented by the value of <tt>ptrdname</tt>.
|
@@ -30,7 +28,6 @@ module Net
|
|
30
28
|
ptrdname.to_s
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
31
|
private
|
35
32
|
|
36
33
|
def build_pack
|
@@ -43,11 +40,9 @@ module Net
|
|
43
40
|
end
|
44
41
|
|
45
42
|
def subclass_new_from_hash(args)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
raise ArgumentError, ":ptrdname or :ptr field is mandatory"
|
50
|
-
end
|
43
|
+
raise ArgumentError, ":ptrdname or :ptr field is mandatory" unless args.key?(:ptrdname) || args.key?(:ptr)
|
44
|
+
|
45
|
+
@ptrdname = args[:ptrdname]
|
51
46
|
end
|
52
47
|
|
53
48
|
def subclass_new_from_string(str)
|
@@ -61,23 +56,20 @@ module Net
|
|
61
56
|
|
62
57
|
private
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def get_inspect
|
69
|
-
value
|
70
|
-
end
|
71
|
-
|
59
|
+
def set_type
|
60
|
+
@type = Net::DNS::RR::Types.new("PTR")
|
61
|
+
end
|
72
62
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
raise ArgumentError, "Invalid PTR Section `#{input}'"
|
77
|
-
end
|
63
|
+
def get_inspect
|
64
|
+
value
|
65
|
+
end
|
78
66
|
|
67
|
+
def check_name(input)
|
68
|
+
IPAddr.new(str)
|
69
|
+
rescue StandardError
|
70
|
+
raise ArgumentError, "Invalid PTR Section `#{input}'"
|
71
|
+
end
|
79
72
|
end
|
80
|
-
|
81
73
|
end
|
82
74
|
end
|
83
75
|
end
|
data/lib/net/dns/rr/soa.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#------------------------------------------------------------
|
6
5
|
# RR type SOA
|
7
6
|
#------------------------------------------------------------
|
8
7
|
class SOA < RR
|
9
|
-
attr_reader :mname
|
10
|
-
|
8
|
+
attr_reader :mname
|
9
|
+
attr_reader :rname
|
10
|
+
attr_reader :serial
|
11
|
+
attr_reader :refresh
|
12
|
+
attr_reader :retry
|
13
|
+
attr_reader :expire
|
14
|
+
attr_reader :minimum
|
15
|
+
|
11
16
|
private
|
12
|
-
|
17
|
+
|
13
18
|
def build_pack
|
14
19
|
@soa_pack = pack_name(@mname)
|
15
20
|
@soa_pack += pack_name(@rname)
|
16
|
-
@soa_pack += [@serial
|
21
|
+
@soa_pack += [@serial, @refresh, @retry, @expire, @minimum].pack("N5")
|
17
22
|
end
|
18
23
|
|
19
24
|
def get_data
|
@@ -21,58 +26,54 @@ module Net # :nodoc:
|
|
21
26
|
end
|
22
27
|
|
23
28
|
def get_inspect
|
24
|
-
"
|
29
|
+
"#{@mname} #{@rname} #{@serial} #{@refresh} #{@retry} #{@expire} #{@minimum}"
|
25
30
|
end
|
26
31
|
|
27
32
|
def subclass_new_from_hash(args)
|
28
|
-
if args.
|
33
|
+
if args.key? :rdata
|
29
34
|
subclass_new_from_string(args[:rdata])
|
30
35
|
else
|
31
|
-
[
|
32
|
-
raise ArgumentError, "Missing field :#{key}" unless args.
|
36
|
+
%i[mname rname serial refresh retry expire minimum].each do |key|
|
37
|
+
raise ArgumentError, "Missing field :#{key}" unless args.key? key
|
33
38
|
end
|
34
|
-
@mname = args[:mname] if valid? args[:mname]
|
39
|
+
@mname = args[:mname] if valid? args[:mname]
|
35
40
|
@rname = args[:rname] if valid? args[:rname]
|
36
|
-
@serial = args[:serial] if number? args[:serial]
|
37
|
-
@refresh = args[:refresh] if number? args[:refresh]
|
38
|
-
@retry = args[:retry] if number? args[:retry]
|
39
|
-
@expire = args[:expire] if number? args[:expire]
|
40
|
-
@minimum = args[:minimum] if number? args[:minimum]
|
41
|
+
@serial = args[:serial] if number? args[:serial]
|
42
|
+
@refresh = args[:refresh] if number? args[:refresh]
|
43
|
+
@retry = args[:retry] if number? args[:retry]
|
44
|
+
@expire = args[:expire] if number? args[:expire]
|
45
|
+
@minimum = args[:minimum] if number? args[:minimum]
|
41
46
|
end
|
42
47
|
end
|
43
|
-
|
48
|
+
|
44
49
|
def number?(num)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
raise ArgumentError, "Wrong format field: #{num} not a number or less than zero"
|
49
|
-
end
|
50
|
+
raise ArgumentError, "Wrong format field: #{num} not a number or less than zero" unless num.is_a?(Integer) && (num > 0)
|
51
|
+
|
52
|
+
true
|
50
53
|
end
|
51
54
|
|
52
55
|
def subclass_new_from_string(str)
|
53
|
-
mname,rname,serial,refresh,ret,expire,minimum = str.strip.split(" ")
|
56
|
+
mname, rname, serial, refresh, ret, expire, minimum = str.strip.split(" ")
|
54
57
|
@mname = mname if valid? mname
|
55
58
|
@rname = rname if valid? rname
|
56
|
-
@serial
|
59
|
+
@serial, @refresh, @retry, @expire, @minimum = [serial, refresh, ret, expire, minimum].collect do |i|
|
57
60
|
i.to_i if valid? i.to_i
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
61
|
-
def subclass_new_from_binary(data,offset)
|
62
|
-
@mname,offset = dn_expand(data,offset)
|
63
|
-
@rname,offset = dn_expand(data,offset)
|
64
|
-
@serial
|
65
|
-
|
64
|
+
def subclass_new_from_binary(data, offset)
|
65
|
+
@mname, offset = dn_expand(data, offset)
|
66
|
+
@rname, offset = dn_expand(data, offset)
|
67
|
+
@serial, @refresh, @retry, @expire, @minimum = data.unpack("@#{offset} N5")
|
68
|
+
offset + (5 * Net::DNS::INT32SZ)
|
66
69
|
end
|
67
|
-
|
70
|
+
|
68
71
|
private
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
|
73
|
+
def set_type
|
74
|
+
@type = Net::DNS::RR::Types.new("SOA")
|
75
|
+
end
|
74
76
|
end
|
75
|
-
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
data/lib/net/dns/rr/srv.rb
CHANGED
@@ -1,45 +1,44 @@
|
|
1
1
|
module Net # :nodoc:
|
2
2
|
module DNS
|
3
3
|
class RR
|
4
|
-
|
5
4
|
#------------------------------------------------------------
|
6
5
|
# RR type SRV
|
7
6
|
#------------------------------------------------------------
|
8
7
|
class SRV < RR
|
9
|
-
|
10
|
-
attr_reader :
|
11
|
-
|
8
|
+
attr_reader :priority
|
9
|
+
attr_reader :weight
|
10
|
+
attr_reader :port
|
11
|
+
attr_reader :host
|
12
|
+
|
12
13
|
private
|
13
|
-
|
14
|
+
|
14
15
|
def build_pack
|
15
16
|
str = ""
|
16
17
|
end
|
17
|
-
|
18
|
-
def subclass_new_from_binary(data,offset)
|
18
|
+
|
19
|
+
def subclass_new_from_binary(data, offset)
|
19
20
|
off_end = offset + @rdlength
|
20
21
|
@priority, @weight, @port = data.unpack("@#{offset} n n n")
|
21
|
-
offset+=6
|
22
|
+
offset += 6
|
22
23
|
|
23
|
-
@host=[]
|
24
|
+
@host = []
|
24
25
|
while offset < off_end
|
25
|
-
len = data.
|
26
|
+
len = data.unpack1("@#{offset} C")
|
26
27
|
offset += 1
|
27
|
-
str = data[offset..offset+len-1]
|
28
|
+
str = data[offset..offset + len - 1]
|
28
29
|
offset += len
|
29
30
|
@host << str
|
30
31
|
end
|
31
|
-
@host
|
32
|
+
@host = @host.join(".")
|
32
33
|
offset
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
private
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
|
38
|
+
def set_type
|
39
|
+
@type = Net::DNS::RR::Types.new("SRV")
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
43
|
end
|
45
44
|
end
|