rubydns 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in rubydns.gemspec
3
+ # Specify your gem's dependencies in trenni.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem "rake"
8
+ end
data/README.md CHANGED
@@ -27,103 +27,113 @@ Or install it yourself as:
27
27
  ## Usage
28
28
 
29
29
  This is copied from `test/examples/test-dns-2.rb`. It has been simplified slightly.
30
-
31
- require 'rubydns'
32
-
33
- Name = Resolv::DNS::Name
34
- IN = Resolv::DNS::Resource::IN
35
-
36
- # Use upstream DNS for name resolution.
37
- UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
38
-
39
- def self.run
40
- # Start the RubyDNS server
41
- RubyDNS::run_server(:listen => INTERFACES) do
42
- match("test.mydomain.org", IN::A) do |transaction|
43
- transaction.respond!("10.0.0.80")
44
- end
45
-
46
- # Default DNS handler
47
- otherwise do |transaction|
48
- transaction.passthrough!(UPSTREAM)
49
- end
50
- end
51
- end
52
-
53
- After starting this server you can test it using dig:
54
-
55
- dig @localhost test1.mydomain.org
56
- dig @localhost dev.mydomain.org
57
- dig @localhost google.com
30
+ ```ruby
31
+ #!/usr/bin/env ruby
32
+ require 'rubydns'
33
+
34
+ INTERFACES = [
35
+ [:udp, "0.0.0.0", 53],
36
+ [:tcp, "0.0.0.0", 53]
37
+ ]
38
+ Name = Resolv::DNS::Name
39
+ IN = Resolv::DNS::Resource::IN
40
+
41
+ # Use upstream DNS for name resolution.
42
+ UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
43
+
44
+ def self.run
45
+ # Start the RubyDNS server
46
+ RubyDNS::run_server(:listen => INTERFACES) do
47
+ match(/test.mydomain.org/, IN::A) do |_host, transaction|
48
+ transaction.respond!("10.0.0.80")
49
+ end
50
+
51
+ # Default DNS handler
52
+ otherwise do |transaction|
53
+ transaction.passthrough!(UPSTREAM)
54
+ end
55
+ end
56
+ end
57
+ run
58
+ ```
59
+ Start the server using `rvmsudo ./test.rb`. You can then test it using dig:
60
+ ```
61
+ $ dig @localhost test1.mydomain.org
62
+ $ dig @localhost dev.mydomain.org
63
+ $ dig @localhost google.com
64
+ ```
58
65
 
59
66
  ## Compatibility
60
67
 
61
68
  ### Migrating from RubyDNS 0.3.x to 0.4.x ###
62
69
 
63
70
  Due to changes in `resolv.rb`, superficial parts of RubyDNS have changed. Rather than using `:A` to specify A-records, one must now use the class name.
64
-
65
- match(..., :A)
66
-
71
+ ```ruby
72
+ match(..., :A)
73
+ ```
67
74
  becomes
68
-
69
- IN = Resolv::DNS::Resource::IN
70
- match(..., IN::A)
71
-
75
+ ```ruby
76
+ IN = Resolv::DNS::Resource::IN
77
+ match(..., IN::A)
78
+ ```
72
79
  ### Migrating from RubyDNS 0.4.x to 0.5.x ###
73
80
 
74
81
  The system standard resolver was synchronous, and this could stall the server when making upstream requests to other DNS servers. A new resolver `RubyDNS::Resolver` now provides an asynchronous interface and the `Transaction::passthrough` makes exclusive use of this to provide high performance asynchonous resolution.
75
82
 
76
83
  Here is a basic example of how to use the new resolver in full. It is important to provide both `:udp` and `:tcp` connection specifications, so that large requests will be handled correctly:
77
-
78
- resolver = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
79
-
80
- EventMachine::run do
81
- resolver.query('google.com', IN::A) do |response|
82
- case response
83
- when RubyDNS::Message
84
- puts "Got response: #{response.answers.first}"
85
- else
86
- # Response is of class RubyDNS::ResolutionFailure
87
- puts "Failed: #{response.message}"
88
- end
89
-
90
- EventMachine::stop
84
+ ```ruby
85
+ resolver = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
86
+
87
+ EventMachine::run do
88
+ resolver.query('google.com', IN::A) do |response|
89
+ case response
90
+ when RubyDNS::Message
91
+ puts "Got response: #{response.answers.first}"
92
+ else
93
+ # Response is of class RubyDNS::ResolutionFailure
94
+ puts "Failed: #{response.message}"
91
95
  end
92
- end
93
96
 
97
+ EventMachine::stop
98
+ end
99
+ end
100
+ ```
94
101
  Existing code that uses `Resolv::DNS` as a resolver will need to be updated:
95
-
96
- # 1/ Add this at the top of your file; Host specific system information:
97
- require 'rubydns/system'
102
+ ```ruby
103
+ # 1/ Add this at the top of your file; Host specific system information:
104
+ require 'rubydns/system'
98
105
 
99
- # 2/ Change from R = Resolv::DNS.new to:
100
- R = RubyDNS::Resolver.new(RubyDNS::System::nameservers)
101
-
106
+ # 2/ Change from R = Resolv::DNS.new to:
107
+ R = RubyDNS::Resolver.new(RubyDNS::System::nameservers)
108
+ ```
102
109
  Everything else in the server can remain the same. You can see a complete example in `test/test_resolver.rb`.
103
110
 
104
111
  #### Deferred Transactions ####
105
112
 
106
113
  The implementation of the above depends on a new feature which was added in 0.5.0:
107
114
 
108
- transaction.defer!
115
+ ```ruby
116
+ transaction.defer!
117
+ ```
109
118
 
110
119
  Once you call this, the transaction won't complete until you call either `transaction.succeed` or `transaction.fail`.
111
-
112
- RubyDNS::run_server(:listen => SERVER_PORTS) do
113
- match(/\.*.com/, IN::A) do |match, transaction|
114
- transaction.defer!
115
-
116
- # No domain exists, after 5 seconds:
117
- EventMachine::Timer.new(5) do
118
- transaction.failure!(:NXDomain)
119
- end
120
- end
120
+ ```ruby
121
+ RubyDNS::run_server(:listen => SERVER_PORTS) do
122
+ match(/\.*.com/, IN::A) do |match, transaction|
123
+ transaction.defer!
121
124
 
122
- otherwise do
125
+ # No domain exists, after 5 seconds:
126
+ EventMachine::Timer.new(5) do
123
127
  transaction.failure!(:NXDomain)
124
128
  end
125
129
  end
126
130
 
131
+ otherwise do
132
+ transaction.failure!(:NXDomain)
133
+ end
134
+ end
135
+ ```
136
+
127
137
  You can see a complete example in `test/test_slow_server.rb`.
128
138
 
129
139
  ## Contributing
@@ -121,7 +121,7 @@ module RubyDNS
121
121
 
122
122
  try_next_server!
123
123
  elsif response.id != @message.id
124
- @logger.warn "[#{@message.id}] Received response with incorrect message id: #{response.id}" if @request.logger
124
+ @logger.warn "[#{@message.id}] Received response with incorrect message id: #{response.id}" if @logger
125
125
 
126
126
  try_next_server!
127
127
  else
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module RubyDNS
22
- VERSION = "0.5.3"
22
+ VERSION = "0.5.4"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-31 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rexec
@@ -110,12 +110,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  - - ! '>='
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
+ segments:
114
+ - 0
115
+ hash: 4471214807073304118
113
116
  required_rubygems_version: !ruby/object:Gem::Requirement
114
117
  none: false
115
118
  requirements:
116
119
  - - ! '>='
117
120
  - !ruby/object:Gem::Version
118
121
  version: '0'
122
+ segments:
123
+ - 0
124
+ hash: 4471214807073304118
119
125
  requirements: []
120
126
  rubyforge_project:
121
127
  rubygems_version: 1.8.24