redns 0.1.5 → 0.1.6

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.5
1
+ 0.1.6
@@ -63,7 +63,17 @@ class ReDNS::Connection < EventMachine::Connection
63
63
  message = ReDNS::Message.new(ReDNS::Buffer.new(data))
64
64
 
65
65
  if (callback = @callback.delete(message.id))
66
- callback[:callback].call(message.answers.collect { |a| a.rdata.to_s })
66
+ answers = message.answers
67
+
68
+ # If the request was made for a specific type of record...
69
+ if (type = callback[:type])
70
+ # ...only include that type of answer in the result set.
71
+ answers = answers.select { |a| a.rtype == type }
72
+ end
73
+
74
+ callback[:callback].call(
75
+ answers.collect { |a| a.rdata.to_s }
76
+ )
67
77
  end
68
78
  end
69
79
 
@@ -81,6 +91,7 @@ class ReDNS::Connection < EventMachine::Connection
81
91
  if (result > 0)
82
92
  @callback[@sequence] = {
83
93
  :callback => callback,
94
+ :type => type,
84
95
  :at => Time.now
85
96
  }
86
97
  else
data/redns.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{redns}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["tadman"]
12
- s.date = %q{2010-08-17}
12
+ s.date = %q{2010-08-18}
13
13
  s.description = %q{ReDNS is a pure Ruby DNS library with drivers for reactor-model engines such as EventMachine}
14
14
  s.email = %q{github@tadman.ca}
15
15
  s.extra_rdoc_files = [
@@ -20,28 +20,39 @@ class TestReDNSConnection < Test::Unit::TestCase
20
20
  address = nil
21
21
  reverse = nil
22
22
  nameservers = nil
23
+ cname = nil
23
24
 
24
25
  EventMachine.run do
25
26
  dns = ReDNS::Connection.instance
26
27
 
27
28
  assert dns.nameservers.length > 0
28
29
 
30
+ # Simple address lookup, one A record
29
31
  dns.resolve('example.com') do |result|
30
32
  address = result
31
33
 
32
- EventMachine.stop_event_loop if (address and reverse and nameservers)
34
+ EventMachine.stop_event_loop if (address and reverse and nameservers and cname)
33
35
  end
34
36
 
37
+ # Simple reverse lookup, one PTR record
35
38
  dns.resolve('192.0.32.10') do |result|
36
39
  reverse = result
37
40
 
38
- EventMachine.stop_event_loop if (address and reverse and nameservers)
41
+ EventMachine.stop_event_loop if (address and reverse and nameservers and cname)
39
42
  end
40
43
 
44
+ # Simple nameserver lookup, multiple NS records
41
45
  dns.resolve('example.com', :ns) do |result|
42
46
  nameservers = result
43
47
 
44
- EventMachine.stop_event_loop if (address and reverse and nameservers)
48
+ EventMachine.stop_event_loop if (address and reverse and nameservers and cname)
49
+ end
50
+
51
+ # Simple address lookup, one CNAME, one A, filtered to one A
52
+ dns.resolve('www.twg.ca', :a) do |result|
53
+ cname = result
54
+
55
+ EventMachine.stop_event_loop if (address and reverse and nameservers and cname)
45
56
  end
46
57
 
47
58
  EventMachine.add_timer(4) do
@@ -52,6 +63,8 @@ class TestReDNSConnection < Test::Unit::TestCase
52
63
  assert_equal %w[ 192.0.32.10 ], address
53
64
  assert_equal %w[ www.example.com. ], reverse
54
65
  assert_equal %w[ a.iana-servers.net. b.iana-servers.net. ], nameservers.sort
66
+ assert_equal %w[ 209.123.234.174 ], cname
67
+
55
68
  end
56
69
 
57
70
  def test_simple_timeout
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - tadman
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-17 00:00:00 -04:00
17
+ date: 2010-08-18 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20