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 CHANGED
@@ -1 +1 @@
1
- 0.1.7
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 : nil
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
 
@@ -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
- self.contents = buffer.to_s
26
- buffer.advance(self.contents.length)
27
+ content_length = buffer.unpack('C')[0]
28
+
29
+ self.contents = buffer.read(content_length)
27
30
 
28
31
  self
29
32
  end
@@ -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.read(rdata_length))
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{redns}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["tadman"]
data/test/helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'test/unit'
3
2
 
4
3
  [ %w[ .. lib ], %w[ . ] ].each do |path|
@@ -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
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - tadman