rubydns 1.0.3 → 2.0.0.pre.rc1

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +4 -0
  3. data/.travis.yml +9 -12
  4. data/Gemfile +4 -1
  5. data/README.md +49 -151
  6. data/Rakefile +2 -7
  7. data/examples/basic-dns.rb +24 -0
  8. data/examples/cname.rb +25 -0
  9. data/examples/flakey-dns.rb +2 -2
  10. data/examples/simple.rb +25 -0
  11. data/examples/soa-dns.rb +82 -0
  12. data/examples/test-dns-1.rb +83 -0
  13. data/examples/test-dns-2.rb +83 -0
  14. data/examples/wikipedia-dns.rb +4 -18
  15. data/lib/rubydns.rb +9 -23
  16. data/lib/rubydns/{server.rb → rule_based_server.rb} +2 -160
  17. data/lib/rubydns/version.rb +1 -1
  18. data/rubydns.gemspec +3 -6
  19. data/spec/rubydns/daemon_spec.rb +26 -22
  20. data/spec/rubydns/injected_supervisor_spec.rb +10 -7
  21. data/spec/rubydns/passthrough_spec.rb +31 -24
  22. data/spec/spec_helper.rb +43 -0
  23. metadata +21 -100
  24. data/lib/rubydns/chunked.rb +0 -34
  25. data/lib/rubydns/extensions/resolv.rb +0 -85
  26. data/lib/rubydns/extensions/string.rb +0 -28
  27. data/lib/rubydns/handler.rb +0 -188
  28. data/lib/rubydns/logger.rb +0 -31
  29. data/lib/rubydns/message.rb +0 -76
  30. data/lib/rubydns/resolver.rb +0 -294
  31. data/lib/rubydns/system.rb +0 -146
  32. data/lib/rubydns/transaction.rb +0 -204
  33. data/lib/rubydns/transport.rb +0 -75
  34. data/spec/rubydns/celluloid_bug_spec.rb +0 -92
  35. data/spec/rubydns/ipv6_spec.rb +0 -70
  36. data/spec/rubydns/message_spec.rb +0 -56
  37. data/spec/rubydns/origin_spec.rb +0 -106
  38. data/spec/rubydns/resolver_performance_spec.rb +0 -110
  39. data/spec/rubydns/resolver_spec.rb +0 -152
  40. data/spec/rubydns/server/bind9/generate-local.rb +0 -25
  41. data/spec/rubydns/server/bind9/local.zone +0 -5014
  42. data/spec/rubydns/server/bind9/named.conf +0 -14
  43. data/spec/rubydns/server/bind9/named.run +0 -0
  44. data/spec/rubydns/server/million.rb +0 -85
  45. data/spec/rubydns/server/rubydns.stackprof +0 -0
  46. data/spec/rubydns/server_performance_spec.rb +0 -136
  47. data/spec/rubydns/slow_server_spec.rb +0 -89
  48. data/spec/rubydns/socket_spec.rb +0 -77
  49. data/spec/rubydns/system_spec.rb +0 -60
  50. data/spec/rubydns/transaction_spec.rb +0 -138
  51. data/spec/rubydns/truncation_spec.rb +0 -59
@@ -1,138 +0,0 @@
1
- #!/usr/bin/env rspec
2
-
3
- # Copyright, 2012, 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
- require 'yaml'
25
-
26
- module RubyDNS::TransactionSpec
27
- SERVER_PORTS = [[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]
28
- IN = Resolv::DNS::Resource::IN
29
-
30
- describe RubyDNS::Transaction do
31
- let(:server) { RubyDNS::Server.new }
32
- let(:query) { RubyDNS::Message.new(0) }
33
- let(:question) { Resolv::DNS::Name.create("www.google.com.") }
34
- let(:response) { RubyDNS::Message.new(0) }
35
- let(:resolver) { RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])}
36
-
37
- it "should append an address" do
38
- transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response)
39
-
40
- transaction.respond!("1.2.3.4")
41
-
42
- expect(transaction.response.answer[0][0]).to be == question
43
- expect(transaction.response.answer[0][2].address.to_s).to be == "1.2.3.4"
44
- end
45
-
46
- it "should passthrough the request" do
47
- transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response)
48
-
49
- expect(transaction.response.answer.size).to be 0
50
-
51
- transaction.passthrough!(resolver)
52
-
53
- expect(transaction.response.answer.size).to be > 0
54
- end
55
-
56
- it "should return a response on passthrough" do
57
- transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response)
58
-
59
- expect(transaction.response.answer.size).to be 0
60
-
61
- response = transaction.passthrough(resolver)
62
-
63
- expect(response.answer.length).to be > 0
64
- end
65
-
66
- it "should call the block with the response when invoking passthrough!" do
67
- transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response)
68
-
69
- expect(transaction.response.answer.size).to be 0
70
-
71
- passthrough_response = nil
72
-
73
- transaction.passthrough!(resolver) do |response|
74
- passthrough_response = response
75
- end
76
-
77
- expect(passthrough_response.answer.length).to be > 0
78
- end
79
-
80
- it "should fail the request" do
81
- transaction = RubyDNS::Transaction.new(server, query, question, IN::A, response)
82
-
83
- transaction.fail! :NXDomain
84
-
85
- expect(transaction.response.rcode).to be Resolv::DNS::RCode::NXDomain
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
137
- end
138
- end
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Copyright, 2012, 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
- require 'rubydns/extensions/string'
25
-
26
- module RubyDNS::TruncationSpec
27
- SERVER_PORTS = [[:udp, '127.0.0.1', 5520], [:tcp, '127.0.0.1', 5520]]
28
- IN = Resolv::DNS::Resource::IN
29
-
30
- describe "RubyDNS Truncation Server" do
31
- before(:all) do
32
- Celluloid.shutdown
33
- Celluloid.boot
34
-
35
- # Start the RubyDNS server
36
- RubyDNS::run_server(:listen => SERVER_PORTS, asynchronous: true) do
37
- match("truncation", IN::TXT) do |transaction|
38
- text = "Hello World! " * 100
39
- transaction.respond!(*text.chunked)
40
- end
41
-
42
- # Default DNS handler
43
- otherwise do |transaction|
44
- transaction.fail!(:NXDomain)
45
- end
46
- end
47
- end
48
-
49
- it "should use tcp because of large response" do
50
- resolver = RubyDNS::Resolver.new(SERVER_PORTS)
51
-
52
- response = resolver.query("truncation", IN::TXT)
53
-
54
- text = response.answer.first
55
-
56
- expect(text[2].strings.join).to be == ("Hello World! " * 100)
57
- end
58
- end
59
- end