redns 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/redns/buffer.rb +10 -1
- data/lib/redns/record/null.rb +5 -2
- data/lib/redns/resource.rb +1 -1
- data/redns.gemspec +1 -1
- data/test/helper.rb +0 -1
- data/test/test_redns_resolver.rb +11 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/lib/redns/buffer.rb
CHANGED
@@ -31,7 +31,7 @@ class ReDNS::Buffer < String
|
|
31
31
|
super(contents || '')
|
32
32
|
|
33
33
|
@offset = offset ? offset.to_i : 0
|
34
|
-
@size = size ? size.to_i :
|
34
|
+
@size = size ? size.to_i : total_length
|
35
35
|
end
|
36
36
|
|
37
37
|
advance(0)
|
@@ -54,6 +54,15 @@ class ReDNS::Buffer < String
|
|
54
54
|
append(contents.pack(format))
|
55
55
|
end
|
56
56
|
|
57
|
+
def slice(chars = 1)
|
58
|
+
return if (@offset + chars > total_length)
|
59
|
+
|
60
|
+
result = to_str[@offset, chars]
|
61
|
+
advance(chars)
|
62
|
+
|
63
|
+
self.class.new(result)
|
64
|
+
end
|
65
|
+
|
57
66
|
def read(chars = 1)
|
58
67
|
return if (@offset + chars > total_length)
|
59
68
|
|
data/lib/redns/record/null.rb
CHANGED
@@ -16,14 +16,17 @@ class ReDNS::Record::Null < ReDNS::Fragment
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def serialize(buffer = ReDNS::Buffer.new)
|
19
|
+
buffer.pack('C', self.contents.length)
|
20
|
+
|
19
21
|
buffer.append(self.contents)
|
20
22
|
|
21
23
|
buffer
|
22
24
|
end
|
23
25
|
|
24
26
|
def deserialize(buffer)
|
25
|
-
|
26
|
-
|
27
|
+
content_length = buffer.unpack('C')[0]
|
28
|
+
|
29
|
+
self.contents = buffer.read(content_length)
|
27
30
|
|
28
31
|
self
|
29
32
|
end
|
data/lib/redns/resource.rb
CHANGED
@@ -73,7 +73,7 @@ class ReDNS::Resource < ReDNS::Fragment
|
|
73
73
|
when :soa
|
74
74
|
self.rdata = ReDNS::Record::SOA.new(buffer)
|
75
75
|
when :txt, :null
|
76
|
-
self.rdata = ReDNS::Record::Null.new(buffer.
|
76
|
+
self.rdata = ReDNS::Record::Null.new(buffer.slice(rdata_length))
|
77
77
|
when :mx
|
78
78
|
self.rdata = ReDNS::Record::MX.new(buffer)
|
79
79
|
else
|
data/redns.gemspec
CHANGED
data/test/helper.rb
CHANGED
data/test/test_redns_resolver.rb
CHANGED
@@ -39,6 +39,17 @@ class TestReReDNSResolver < Test::Unit::TestCase
|
|
39
39
|
assert_equal 'www.example.com.', r[0].rdata.to_s
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_simple_txt_query
|
43
|
+
res = ReDNS::Resolver.new
|
44
|
+
|
45
|
+
r = res.simple_query(:txt, 'gmail.com')
|
46
|
+
|
47
|
+
assert_equal 1, r.size
|
48
|
+
|
49
|
+
assert_equal :txt, r[0].rtype
|
50
|
+
assert_equal 'v=spf1 redirect=_spf.google.com', r[0].rdata.to_s
|
51
|
+
end
|
52
|
+
|
42
53
|
def test_query
|
43
54
|
res = ReDNS::Resolver.new
|
44
55
|
|