rubydns 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b96c1f2e9752973d51217be442205e95defe642
4
- data.tar.gz: 0200c178cbbffe9429b7ec0997f0bfc407a00868
3
+ metadata.gz: 29d3991adacb8a0b1d03b6fa1a6a4283c13a4c09
4
+ data.tar.gz: 12ac3d2fec1d3e96afcae1ee35d35be91b948c7c
5
5
  SHA512:
6
- metadata.gz: 007c979c79a868f387b0ed0168649c9a8ff7b188c7b9a5e8c63e959c761dfa15b5ce517fac63ecdf7070e18d316f3a6ac48913cf91ac48267a49e4aee002c26a
7
- data.tar.gz: 20287eb57c761aebb9742c9ac563725a5b8dd3a5adb3c4741ca9441d3eceaee5a4422f4e3e70a1028a4c91c7a2d6562d0c325b6f2935c21dfead3a7f1ac82da8
6
+ metadata.gz: 489667f6def732211dac4a3d88bfb5bc4fa250ec4f4873999141a99a32c98b6f69f3c14755449b874c4aaa461dcf2c57892cf40046463c6a0fd95fc0c203d180
7
+ data.tar.gz: a68f53b8e32e2dc3bf25906f0c9dbc17da641bfcf5e32f1f71373dffd5ce17a6aef222dbce991b3ed4fac1d273e06691f89353377d026d018ce139ab7c7cb595
data/.travis.yml CHANGED
@@ -3,10 +3,11 @@ before_install:
3
3
  - sudo apt-get update -qq
4
4
  - sudo apt-get install -y bind9
5
5
  rvm:
6
- - 1.9
7
- - 2.0
6
+ - 2.2
8
7
  - 2.1
8
+ - 2.0.0
9
+ - 1.9.3
9
10
  - rbx-2
10
11
  matrix:
11
12
  allow_failures:
12
- - rvm: rbx-2
13
+ - rvm: rbx-2
data/README.md CHANGED
@@ -17,15 +17,15 @@ For examples and documentation please see the main [project page][2].
17
17
 
18
18
  Add this line to your application's Gemfile:
19
19
 
20
- gem 'rubydns'
20
+ gem 'rubydns'
21
21
 
22
22
  And then execute:
23
23
 
24
- $ bundle
24
+ $ bundle
25
25
 
26
26
  Or install it yourself as:
27
27
 
28
- $ gem install rubydns
28
+ $ gem install rubydns
29
29
 
30
30
  ## Usage
31
31
 
@@ -75,9 +75,13 @@ It is possible to create and integrate your own custom servers.
75
75
  end
76
76
  end
77
77
 
78
- EventMachine.run do
79
- MyServer.new.run
80
- end
78
+ # Use the RubyDNS infrastructure for running the daemon:
79
+ # If asynchronous is true, it will return immediately, otherwise, it will block the current thread until Ctrl-C is pressed (SIGINT).
80
+ RubyDNS::run_server(asynchronous: false, server_class: MyServer)
81
+
82
+ # Directly instantiate the celluloid supervisor:
83
+ supervisor = MyServer.supervise
84
+ supervisor.actors.first.run
81
85
 
82
86
  This is the best way to integrate with other projects.
83
87
 
@@ -180,7 +184,7 @@ Here is a basic example of how to use the new resolver in full. It is important
180
184
  resolver = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
181
185
 
182
186
  EventMachine::run do
183
- resolver.query('google.com', IN::A) do |response|
187
+ resolver.query('google.com', IN::A) do |response|
184
188
  case response
185
189
  when RubyDNS::Message
186
190
  puts "Got response: #{response.answers.first}"
data/lib/rubydns.rb CHANGED
@@ -29,9 +29,9 @@ require_relative 'rubydns/logger'
29
29
  module RubyDNS
30
30
  # Run a server with the given rules.
31
31
  def self.run_server (options = {}, &block)
32
- supervisor_class = options[:supervisor_class] || RuleBasedServer
32
+ server_class = options[:server_class] || RuleBasedServer
33
33
 
34
- supervisor = supervisor_class.supervise(options, &block)
34
+ supervisor = server_class.supervise(options, &block)
35
35
 
36
36
  supervisor.actors.first.run
37
37
  if options[:asynchronous]
@@ -45,5 +45,41 @@ class Resolv
45
45
  @rd = @rd || other.rd
46
46
  end
47
47
  end
48
+
49
+ class OriginError < ArgumentError
50
+ end
51
+
52
+ class Name
53
+ def to_s
54
+ "#{@labels.join('.')}#{@absolute ? '.' : ''}"
55
+ end
56
+
57
+ def inspect
58
+ "#<#{self.class}: #{self.to_s}>"
59
+ end
60
+
61
+ # Return the name, typically absolute, with the specified origin as a suffix. If the origin is nil, don't change the name, but change it to absolute (as specified).
62
+ def with_origin(origin, absolute = true)
63
+ return self.class.new(@labels, absolute) if origin == nil
64
+
65
+ origin = Label.split(origin) if String === origin
66
+
67
+ return self.class.new(@labels + origin, absolute)
68
+ end
69
+
70
+
71
+ # Return the name, typically relative, without the specified origin suffix. If the origin is nil, don't change the name, but change it to absolute (as specified).
72
+ def without_origin(origin, absolute = false)
73
+ return self.class.new(@labels, absolute) if origin == nil
74
+
75
+ origin = Label.split(origin) if String === origin
76
+
77
+ if @labels.last(origin.length) == origin
78
+ return self.class.new(@labels.first(@labels.length - origin.length), absolute)
79
+ else
80
+ raise OriginError.new("#{self} does not end with #{origin.join('.')}")
81
+ end
82
+ end
83
+ end
48
84
  end
49
85
  end
@@ -44,8 +44,30 @@ module RubyDNS
44
44
 
45
45
  @options = options
46
46
 
47
+ @origin = options[:origin] || nil
48
+
47
49
  @logger = options[:logger] || Celluloid.logger
48
50
  end
51
+
52
+ attr_accessor :origin
53
+
54
+ def fully_qualified_name(name)
55
+ # If we are passed an existing deconstructed name:
56
+ if Resolv::DNS::Name === name
57
+ if name.absolute?
58
+ return name
59
+ else
60
+ return name.with_origin(@origin)
61
+ end
62
+ end
63
+
64
+ # ..else if we have a string, we need to do some basic processing:
65
+ if name.end_with? '.'
66
+ return Resolv::DNS::Name.create(name)
67
+ else
68
+ return Resolv::DNS::Name.create(name).with_origin(@origin)
69
+ end
70
+ end
49
71
 
50
72
  # Provides the next sequence identification number which is used to keep track of DNS messages.
51
73
  def next_id!
@@ -57,28 +79,52 @@ module RubyDNS
57
79
  def query(name, resource_class = Resolv::DNS::Resource::IN::A)
58
80
  message = Resolv::DNS::Message.new(next_id!)
59
81
  message.rd = 1
60
- message.add_question name, resource_class
82
+ message.add_question fully_qualified_name(name), resource_class
61
83
 
62
84
  dispatch_request(message)
63
85
  end
64
86
 
65
87
  # Yields a list of `Resolv::IPv4` and `Resolv::IPv6` addresses for the given `name` and `resource_class`. Raises a ResolutionFailure if no severs respond.
66
88
  def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, options = {})
67
- (options[:retries] || 5).times do
68
- response = query(name, resource_class)
89
+ name = fully_qualified_name(name)
90
+
91
+ cache = options.fetch(:cache, {})
92
+ retries = options.fetch(:retries, 10)
93
+ delay = options.fetch(:delay, 0.01)
94
+
95
+ records = lookup(name, resource_class, cache) do |name, resource_class|
96
+ response = nil
69
97
 
70
- if response
71
- # Resolv::DNS::Name doesn't retain the trailing dot.
72
- name = name.sub(/\.$/, '')
98
+ retries.times do |i|
99
+ # Wait 10ms before trying again:
100
+ sleep delay if delay and i > 0
73
101
 
74
- return response.answer.select{|record| record[0].to_s == name}.collect{|record| record[2].address}
102
+ response = query(name, resource_class)
103
+
104
+ break if response
75
105
  end
76
106
 
77
- # Wait 10ms before trying again:
78
- sleep 0.01
107
+ response or abort ResolutionFailure.new("Could not resolve #{name} after #{retries} attempt(s).")
108
+ end
109
+
110
+ addresses = []
111
+
112
+ if records
113
+ records.each do |record|
114
+ if record.respond_to? :address
115
+ addresses << record.address
116
+ else
117
+ # The most common case here is that record.class is IN::CNAME and we need to figure out the address. Usually the upstream DNS server would have replied with this too, and this will be loaded from the response if possible without requesting additional information.
118
+ addresses += addresses_for(record.name, record.class, options.merge(cache: cache))
119
+ end
120
+ end
79
121
  end
80
122
 
81
- abort ResolutionFailure.new("No server replied.")
123
+ if addresses.size > 0
124
+ return addresses
125
+ else
126
+ abort ResolutionFailure.new("Could not find any addresses for #{name}.")
127
+ end
82
128
  end
83
129
 
84
130
  def request_timeout
@@ -90,7 +136,7 @@ module RubyDNS
90
136
  request = Request.new(message, @servers)
91
137
 
92
138
  request.each do |server|
93
- @logger.debug "[#{message.id}] Sending request to server #{server.inspect}" if @logger
139
+ @logger.debug "[#{message.id}] Sending request #{message.question.inspect} to server #{server.inspect}" if @logger
94
140
 
95
141
  begin
96
142
  response = nil
@@ -121,6 +167,21 @@ module RubyDNS
121
167
 
122
168
  private
123
169
 
170
+ # Lookup a name/resource_class record but use the records cache if possible reather than making a new request if possible.
171
+ def lookup(name, resource_class = Resolv::DNS::Resource::IN::A, records = {})
172
+ records.fetch(name) do
173
+ response = yield(name, resource_class)
174
+
175
+ if response
176
+ response.answer.each do |name, ttl, record|
177
+ (records[name] ||= []) << record
178
+ end
179
+ end
180
+
181
+ records[name]
182
+ end
183
+ end
184
+
124
185
  def try_server(request, server)
125
186
  case server[0]
126
187
  when :udp
@@ -139,7 +200,7 @@ module RubyDNS
139
200
  @logger.warn "[#{message.id}] Received response with incorrect message id: #{response.id}!" if @logger
140
201
  else
141
202
  @logger.debug "[#{message.id}] Received valid response with #{response.answer.count} answer(s)." if @logger
142
-
203
+
143
204
  return true
144
205
  end
145
206
 
@@ -57,8 +57,13 @@ module RubyDNS
57
57
 
58
58
  @logger = options[:logger] || Celluloid.logger
59
59
  @interfaces = options[:listen] || DEFAULT_INTERFACES
60
+
61
+ @origin = options[:origin] || '.'
60
62
  end
61
63
 
64
+ # Records are relative to this origin:
65
+ attr_accessor :origin
66
+
62
67
  attr_accessor :logger
63
68
 
64
69
  # Fire the named event as part of running the server.
@@ -91,11 +96,18 @@ module RubyDNS
91
96
 
92
97
  begin
93
98
  query.question.each do |question, resource_class|
94
- @logger.debug {"<#{query.id}> Processing question #{question} #{resource_class}..."}
95
-
96
- transaction = Transaction.new(self, query, question, resource_class, response, options)
97
-
98
- transaction.process
99
+ begin
100
+ question = question.without_origin(@origin)
101
+
102
+ @logger.debug {"<#{query.id}> Processing question #{question} #{resource_class}..."}
103
+
104
+ transaction = Transaction.new(self, query, question, resource_class, response, options)
105
+
106
+ transaction.process
107
+ rescue Resolv::DNS::OriginError
108
+ # This is triggered if the question is not part of the specified @origin:
109
+ @logger.debug {"<#{query.id}> Skipping question #{question} #{resource_class} because #{$!}"}
110
+ end
99
111
  end
100
112
  rescue Celluloid::ResumableError
101
113
  raise
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module RubyDNS
22
- VERSION = "0.9.3"
22
+ VERSION = "0.9.4"
23
23
  end
@@ -75,12 +75,14 @@ describe "RubyDNS Daemonized Server" do
75
75
  it "should resolve local domain correctly" do
76
76
  expect(BasicTestServer.status).to be == :running
77
77
 
78
- resolver = RubyDNS::Resolver.new(BasicTestServer::SERVER_PORTS)
78
+ resolver = RubyDNS::Resolver.new(BasicTestServer::SERVER_PORTS, search_domain: '')
79
79
 
80
80
  response = resolver.query("test.local")
81
+ puts "Response: #{response.inspect}"
82
+
81
83
  answer = response.answer.first
82
84
 
83
- expect(answer[0].to_s).to be == "test.local"
85
+ expect(answer[0].to_s).to be == "test.local."
84
86
  expect(answer[2].address.to_s).to be == "192.168.1.1"
85
87
  end
86
88
 
@@ -92,7 +94,7 @@ describe "RubyDNS Daemonized Server" do
92
94
  response = resolver.query("foobar")
93
95
  answer = response.answer.first
94
96
 
95
- expect(answer[0].to_s).to be == "foobar"
97
+ expect(answer[0]).to be == resolver.fully_qualified_name("foobar")
96
98
  expect(answer[2].address.to_s).to be == "192.168.1.2"
97
99
  end
98
100
 
@@ -39,7 +39,7 @@ module RubyDNS::InjectedSupervisorSpec
39
39
  Celluloid.boot
40
40
 
41
41
  # Start the RubyDNS server
42
- RubyDNS::run_server(listen: SERVER_PORTS, supervisor_class: TestServer, asynchronous: true) do
42
+ RubyDNS::run_server(listen: SERVER_PORTS, server_class: TestServer, asynchronous: true) do
43
43
  match("test_message", IN::TXT) do |transaction|
44
44
  transaction.respond!(*test_message.chunked)
45
45
  end
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'rubydns'
24
+
25
+ module RubyDNS::OriginSpec
26
+ describe RubyDNS::Resolver do
27
+ it "should generate fully qualified domain name with specified origin" do
28
+ resolver = RubyDNS::Resolver.new([], origin: "foo.bar.")
29
+
30
+ fully_qualified_name = resolver.fully_qualified_name("baz")
31
+
32
+ expect(fully_qualified_name).to be_absolute
33
+ expect(fully_qualified_name.to_s).to be == "baz.foo.bar."
34
+ end
35
+ end
36
+
37
+ describe Resolv::DNS::Name do
38
+ let(:name) {Resolv::DNS::Name.create("foo.bar")}
39
+
40
+ it "should be relative" do
41
+ expect(name).to_not be_absolute
42
+ expect(name.to_s).to be == "foo.bar"
43
+ end
44
+
45
+ it "should add the specified origin" do
46
+ fully_qualified_name = name.with_origin("org")
47
+
48
+ expect(fully_qualified_name.to_a.size).to be 3
49
+ expect(fully_qualified_name).to be_absolute
50
+ expect(fully_qualified_name.to_s).to be == "foo.bar.org."
51
+ end
52
+
53
+ it "should handle nil origin as absolute" do
54
+ fully_qualified_name = name.with_origin(nil)
55
+
56
+ expect(fully_qualified_name.to_a.size).to be 2
57
+ expect(fully_qualified_name).to be_absolute
58
+ expect(fully_qualified_name.to_s).to be == "foo.bar."
59
+ end
60
+
61
+ it "should handle empty origin as absolute" do
62
+ fully_qualified_name = name.with_origin('')
63
+
64
+ expect(fully_qualified_name.to_a.size).to be 2
65
+ expect(fully_qualified_name).to be_absolute
66
+ expect(fully_qualified_name.to_s).to be == "foo.bar."
67
+ end
68
+ end
69
+
70
+ describe Resolv::DNS::Name do
71
+ let(:name) {Resolv::DNS::Name.create("foo.bar.")}
72
+
73
+ it "should be absolute" do
74
+ expect(name).to be_absolute
75
+ expect(name.to_s).to be == "foo.bar."
76
+ end
77
+
78
+ it "should remove the specified origin" do
79
+ relative_name = name.without_origin("bar")
80
+
81
+ expect(relative_name.to_a.size).to be 1
82
+ expect(relative_name).to_not be_absolute
83
+ expect(relative_name.to_s).to be == "foo"
84
+ end
85
+
86
+ it "should not remove nil origin but become relative" do
87
+ relative_name = name.without_origin(nil)
88
+
89
+ expect(relative_name.to_a.size).to be 2
90
+ expect(relative_name).to_not be_absolute
91
+ expect(relative_name.to_s).to be == "foo.bar"
92
+ end
93
+
94
+ it "should not remove empty string origin but become relative" do
95
+ relative_name = name.without_origin('')
96
+
97
+ expect(relative_name.to_a.size).to be 2
98
+ expect(relative_name).to_not be_absolute
99
+ expect(relative_name.to_s).to be == "foo.bar"
100
+ end
101
+
102
+ it "should not raise an exception when origin isn't valid" do
103
+ expect{name.without_origin('bob')}.to raise_exception(Resolv::DNS::OriginError)
104
+ end
105
+ end
106
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env rspec
2
2
 
3
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
4
  #
@@ -140,5 +140,13 @@ module RubyDNS::ResolverSpec
140
140
  expect(address).to be_kind_of(Resolv::IPv4) | be_kind_of(Resolv::IPv6)
141
141
  end
142
142
  end
143
+
144
+ it "should recursively resolve CNAME records" do
145
+ resolver = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
146
+
147
+ addresses = resolver.addresses_for('www.baidu.com')
148
+
149
+ expect(addresses.size).to be > 0
150
+ end
143
151
  end
144
152
  end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env rspec
2
2
 
3
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
4
  #
@@ -30,7 +30,7 @@ module RubyDNS::TransactionSpec
30
30
  describe RubyDNS::Transaction do
31
31
  let(:server) { RubyDNS::Server.new }
32
32
  let(:query) { RubyDNS::Message.new(0) }
33
- let(:question) { Resolv::DNS::Name.create("www.google.com") }
33
+ let(:question) { Resolv::DNS::Name.create("www.google.com.") }
34
34
  let(:response) { RubyDNS::Message.new(0) }
35
35
  let(:resolver) { RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])}
36
36
 
@@ -39,7 +39,7 @@ module RubyDNS::TransactionSpec
39
39
 
40
40
  transaction.respond!("1.2.3.4")
41
41
 
42
- expect(transaction.response.answer[0][0].to_s).to be == question.to_s
42
+ expect(transaction.response.answer[0][0]).to be == question
43
43
  expect(transaction.response.answer[0][2].address.to_s).to be == "1.2.3.4"
44
44
  end
45
45
 
@@ -84,5 +84,55 @@ module RubyDNS::TransactionSpec
84
84
 
85
85
  expect(transaction.response.rcode).to be Resolv::DNS::RCode::NXDomain
86
86
  end
87
+
88
+ it "should return AAAA record" do
89
+ transaction = RubyDNS::Transaction.new(server, query, question, IN::AAAA, response)
90
+
91
+ expect(transaction.response.answer.size).to be 0
92
+
93
+ transaction.passthrough!(resolver)
94
+
95
+ expect(transaction.response.answer.first[2]).to be_kind_of IN::AAAA
96
+ end
97
+
98
+ it "should return MX record" do
99
+ transaction = RubyDNS::Transaction.new(server,query,"google.com",IN::MX, response)
100
+
101
+ expect(transaction.response.answer.size).to be 0
102
+
103
+ transaction.passthrough!(resolver)
104
+
105
+ expect(transaction.response.answer.first[2]).to be_kind_of IN::MX
106
+ end
107
+
108
+ it "should return NS record" do
109
+ transaction = RubyDNS::Transaction.new(server, query, "google.com", IN::NS, response)
110
+
111
+ expect(transaction.response.answer.size).to be 0
112
+
113
+ transaction.passthrough!(resolver)
114
+
115
+ expect(transaction.response.answer.first[2]).to be_kind_of IN::NS
116
+ end
117
+
118
+ it "should return PTR record" do
119
+ transaction = RubyDNS::Transaction.new(server, query, "8.8.8.8.in-addr.arpa", IN::PTR, response)
120
+
121
+ expect(transaction.response.answer.size).to be 0
122
+
123
+ transaction.passthrough!(resolver)
124
+
125
+ expect(transaction.response.answer.first[2]).to be_kind_of IN::PTR
126
+ end
127
+
128
+ it "should return SOA record" do
129
+ transaction = RubyDNS::Transaction.new(server, query, "google.com", IN::SOA, response)
130
+
131
+ expect(transaction.response.answer.size).to be 0
132
+
133
+ transaction.passthrough!(resolver)
134
+
135
+ expect(transaction.response.answer.first[2]).to be_kind_of IN::SOA
136
+ end
87
137
  end
88
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-26 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -155,11 +155,11 @@ files:
155
155
  - spec/rubydns/injected_supervisor_spec.rb
156
156
  - spec/rubydns/ipv6_spec.rb
157
157
  - spec/rubydns/message_spec.rb
158
+ - spec/rubydns/origin_spec.rb
158
159
  - spec/rubydns/passthrough_spec.rb
159
160
  - spec/rubydns/resolver_performance_spec.rb
160
161
  - spec/rubydns/resolver_spec.rb
161
162
  - spec/rubydns/rules_spec.rb
162
- - spec/rubydns/server/benchmark.rb
163
163
  - spec/rubydns/server/bind9/generate-local.rb
164
164
  - spec/rubydns/server/bind9/local.zone
165
165
  - spec/rubydns/server/bind9/named.conf
@@ -203,11 +203,11 @@ test_files:
203
203
  - spec/rubydns/injected_supervisor_spec.rb
204
204
  - spec/rubydns/ipv6_spec.rb
205
205
  - spec/rubydns/message_spec.rb
206
+ - spec/rubydns/origin_spec.rb
206
207
  - spec/rubydns/passthrough_spec.rb
207
208
  - spec/rubydns/resolver_performance_spec.rb
208
209
  - spec/rubydns/resolver_spec.rb
209
210
  - spec/rubydns/rules_spec.rb
210
- - spec/rubydns/server/benchmark.rb
211
211
  - spec/rubydns/server/bind9/generate-local.rb
212
212
  - spec/rubydns/server/bind9/local.zone
213
213
  - spec/rubydns/server/bind9/named.conf
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'benchmark'
4
- require 'rubydns'
5
-
6
- Benchmark.bm(20) do |x|
7
- DOMAINS = (1..1000).collect do |i|
8
- "domain#{i}.local"
9
- end
10
-
11
- resolved = {}
12
-
13
- x.report("RubyDNS::Resolver") do
14
- resolver = RubyDNS::Resolver.new([[:udp, '127.0.0.1', 5300]])
15
-
16
- # Number of requests remaining since this is an asynchronous event loop:
17
- pending = DOMAINS.size
18
-
19
- EventMachine::run do
20
- DOMAINS.each do |domain|
21
- resolver.addresses_for(domain) do |addresses|
22
- resolved[domain] = addresses
23
-
24
- EventMachine::stop if (pending -= 1) == 0
25
- end
26
- end
27
- end
28
- end
29
- end