celluloid-dns 0.0.1 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +0 -2
  3. data/.simplecov +15 -0
  4. data/.travis.yml +13 -7
  5. data/Gemfile +5 -6
  6. data/README.md +118 -41
  7. data/Rakefile +8 -3
  8. data/celluloid-dns.gemspec +29 -18
  9. data/lib/celluloid/dns.rb +30 -7
  10. data/lib/celluloid/dns/chunked.rb +34 -0
  11. data/lib/celluloid/dns/extensions/resolv.rb +136 -0
  12. data/lib/celluloid/dns/extensions/string.rb +28 -0
  13. data/lib/celluloid/dns/handler.rb +198 -0
  14. data/lib/celluloid/dns/logger.rb +31 -0
  15. data/lib/celluloid/dns/message.rb +76 -0
  16. data/lib/celluloid/dns/replace.rb +54 -0
  17. data/lib/celluloid/dns/resolver.rb +288 -0
  18. data/lib/celluloid/dns/server.rb +151 -27
  19. data/lib/celluloid/dns/system.rb +146 -0
  20. data/lib/celluloid/dns/transaction.rb +202 -0
  21. data/lib/celluloid/dns/transport.rb +75 -0
  22. data/lib/celluloid/dns/version.rb +23 -3
  23. data/spec/celluloid/dns/celluloid_bug_spec.rb +92 -0
  24. data/spec/celluloid/dns/hosts.txt +2 -0
  25. data/spec/celluloid/dns/ipv6_spec.rb +70 -0
  26. data/spec/celluloid/dns/message_spec.rb +56 -0
  27. data/spec/celluloid/dns/origin_spec.rb +106 -0
  28. data/spec/celluloid/dns/replace_spec.rb +42 -0
  29. data/spec/celluloid/dns/resolver_performance_spec.rb +110 -0
  30. data/spec/celluloid/dns/resolver_spec.rb +152 -0
  31. data/spec/celluloid/dns/server/bind9/generate-local.rb +25 -0
  32. data/spec/celluloid/dns/server/bind9/local.zone +5014 -0
  33. data/spec/celluloid/dns/server/bind9/named.conf +14 -0
  34. data/spec/celluloid/dns/server/bind9/named.run +0 -0
  35. data/spec/celluloid/dns/server/million.rb +85 -0
  36. data/spec/celluloid/dns/server_performance_spec.rb +139 -0
  37. data/spec/celluloid/dns/slow_server_spec.rb +91 -0
  38. data/spec/celluloid/dns/socket_spec.rb +71 -0
  39. data/spec/celluloid/dns/system_spec.rb +60 -0
  40. data/spec/celluloid/dns/transaction_spec.rb +138 -0
  41. data/spec/celluloid/dns/truncation_spec.rb +62 -0
  42. metadata +124 -56
  43. data/.coveralls.yml +0 -1
  44. data/.gitignore +0 -17
  45. data/CHANGES.md +0 -3
  46. data/LICENSE.txt +0 -22
  47. data/lib/celluloid/dns/request.rb +0 -46
  48. data/spec/celluloid/dns/server_spec.rb +0 -26
  49. data/spec/spec_helper.rb +0 -5
  50. data/tasks/rspec.task +0 -7
@@ -0,0 +1,138 @@
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 'celluloid/dns'
24
+ require 'yaml'
25
+
26
+ module Celluloid::DNS::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 Celluloid::DNS::Transaction do
31
+ let(:server) { Celluloid::DNS::Server.new }
32
+ let(:query) { Celluloid::DNS::Message.new(0) }
33
+ let(:question) { Resolv::DNS::Name.create("www.google.com.") }
34
+ let(:response) { Celluloid::DNS::Message.new(0) }
35
+ let(:resolver) { Celluloid::DNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])}
36
+
37
+ it "should append an address" do
38
+ transaction = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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 = Celluloid::DNS::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
@@ -0,0 +1,62 @@
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 'celluloid/dns'
24
+ require 'celluloid/dns/extensions/string'
25
+
26
+ module Celluloid::DNS::TruncationSpec
27
+ SERVER_PORTS = [[:udp, '127.0.0.1', 5520], [:tcp, '127.0.0.1', 5520]]
28
+ IN = Resolv::DNS::Resource::IN
29
+
30
+ class TestServer < Celluloid::DNS::Server
31
+ def process(name, resource_class, transaction)
32
+ case [name, resource_class]
33
+ when ["truncation", IN::TXT]
34
+ text = "Hello World! " * 100
35
+ transaction.respond!(*text.chunked)
36
+ else
37
+ transaction.fail!(:NXDomain)
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "Celluloid::DNS Truncation Server" do
43
+ before(:all) do
44
+ @test_server = TestServer.new(listen: SERVER_PORTS)
45
+ @test_server.run
46
+ end
47
+
48
+ after(:all) do
49
+ @test_server.terminate
50
+ end
51
+
52
+ it "should use tcp because of large response" do
53
+ resolver = Celluloid::DNS::Resolver.new(SERVER_PORTS)
54
+
55
+ response = resolver.query("truncation", IN::TXT)
56
+
57
+ text = response.answer.first
58
+
59
+ expect(text[2].strings.join).to be == ("Hello World! " * 100)
60
+ end
61
+ end
62
+ end
metadata CHANGED
@@ -1,135 +1,203 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.17.3
6
5
  platform: ruby
7
6
  authors:
8
- - Tony Arcieri
7
+ - Samuel Williams
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: celluloid
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 0.11.0
19
+ version: 0.17.3
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 0.11.0
26
+ version: 0.17.3
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: celluloid-io
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 0.11.0
33
+ version: 0.17.3
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 0.11.0
40
+ version: 0.17.3
46
41
  - !ruby/object:Gem::Dependency
47
- name: rake
42
+ name: timers
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 4.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: '0'
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: process-daemon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0
62
83
  - !ruby/object:Gem::Dependency
63
84
  name: rspec
64
85
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
86
  requirements:
67
- - - ! '>='
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.4.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.4.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
68
102
  - !ruby/object:Gem::Version
69
103
  version: '0'
70
104
  type: :development
71
105
  prerelease: false
72
106
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
107
  requirements:
75
- - - ! '>='
108
+ - - ">="
76
109
  - !ruby/object:Gem::Version
77
110
  version: '0'
78
- description: Celluloid::IO-powered DNS server
111
+ description: "\t\tCelluloid::DNS provides a high-performance DNS client resolver and
112
+ server\n\t\twhich can be easily integrated into other projects or used as a stand-alone\n\t\tdaemon.\n"
79
113
  email:
80
- - tony.arcieri@gmail.com
114
+ - samuel.williams@oriontransfer.co.nz
81
115
  executables: []
82
116
  extensions: []
83
117
  extra_rdoc_files: []
84
118
  files:
85
- - .coveralls.yml
86
- - .gitignore
87
- - .rspec
88
- - .travis.yml
89
- - CHANGES.md
119
+ - ".rspec"
120
+ - ".simplecov"
121
+ - ".travis.yml"
90
122
  - Gemfile
91
- - LICENSE.txt
92
123
  - README.md
93
124
  - Rakefile
94
125
  - celluloid-dns.gemspec
95
126
  - lib/celluloid/dns.rb
96
- - lib/celluloid/dns/request.rb
127
+ - lib/celluloid/dns/chunked.rb
128
+ - lib/celluloid/dns/extensions/resolv.rb
129
+ - lib/celluloid/dns/extensions/string.rb
130
+ - lib/celluloid/dns/handler.rb
131
+ - lib/celluloid/dns/logger.rb
132
+ - lib/celluloid/dns/message.rb
133
+ - lib/celluloid/dns/replace.rb
134
+ - lib/celluloid/dns/resolver.rb
97
135
  - lib/celluloid/dns/server.rb
136
+ - lib/celluloid/dns/system.rb
137
+ - lib/celluloid/dns/transaction.rb
138
+ - lib/celluloid/dns/transport.rb
98
139
  - lib/celluloid/dns/version.rb
99
140
  - logo.png
100
- - spec/celluloid/dns/server_spec.rb
101
- - spec/spec_helper.rb
102
- - tasks/rspec.task
141
+ - spec/celluloid/dns/celluloid_bug_spec.rb
142
+ - spec/celluloid/dns/hosts.txt
143
+ - spec/celluloid/dns/ipv6_spec.rb
144
+ - spec/celluloid/dns/message_spec.rb
145
+ - spec/celluloid/dns/origin_spec.rb
146
+ - spec/celluloid/dns/replace_spec.rb
147
+ - spec/celluloid/dns/resolver_performance_spec.rb
148
+ - spec/celluloid/dns/resolver_spec.rb
149
+ - spec/celluloid/dns/server/bind9/generate-local.rb
150
+ - spec/celluloid/dns/server/bind9/local.zone
151
+ - spec/celluloid/dns/server/bind9/named.conf
152
+ - spec/celluloid/dns/server/bind9/named.run
153
+ - spec/celluloid/dns/server/million.rb
154
+ - spec/celluloid/dns/server_performance_spec.rb
155
+ - spec/celluloid/dns/slow_server_spec.rb
156
+ - spec/celluloid/dns/socket_spec.rb
157
+ - spec/celluloid/dns/system_spec.rb
158
+ - spec/celluloid/dns/transaction_spec.rb
159
+ - spec/celluloid/dns/truncation_spec.rb
103
160
  homepage: https://github.com/celluloid/celluloid-dns
104
- licenses: []
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
105
164
  post_install_message:
106
165
  rdoc_options: []
107
166
  require_paths:
108
167
  - lib
109
168
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
169
  requirements:
112
- - - ! '>='
170
+ - - ">="
113
171
  - !ruby/object:Gem::Version
114
- version: '0'
115
- segments:
116
- - 0
117
- hash: -4517379908652224173
172
+ version: 2.0.0
118
173
  required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
174
  requirements:
121
- - - ! '>='
175
+ - - ">="
122
176
  - !ruby/object:Gem::Version
123
177
  version: '0'
124
- segments:
125
- - 0
126
- hash: -4517379908652224173
127
178
  requirements: []
128
179
  rubyforge_project:
129
- rubygems_version: 1.8.23
180
+ rubygems_version: 2.5.1
130
181
  signing_key:
131
- specification_version: 3
132
- summary: Celluloid::DNS provides a DNS server implemented as a Celluloid cell
182
+ specification_version: 4
183
+ summary: An easy to use DNS client resolver and server for Ruby.
133
184
  test_files:
134
- - spec/celluloid/dns/server_spec.rb
135
- - spec/spec_helper.rb
185
+ - spec/celluloid/dns/celluloid_bug_spec.rb
186
+ - spec/celluloid/dns/hosts.txt
187
+ - spec/celluloid/dns/ipv6_spec.rb
188
+ - spec/celluloid/dns/message_spec.rb
189
+ - spec/celluloid/dns/origin_spec.rb
190
+ - spec/celluloid/dns/replace_spec.rb
191
+ - spec/celluloid/dns/resolver_performance_spec.rb
192
+ - spec/celluloid/dns/resolver_spec.rb
193
+ - spec/celluloid/dns/server/bind9/generate-local.rb
194
+ - spec/celluloid/dns/server/bind9/local.zone
195
+ - spec/celluloid/dns/server/bind9/named.conf
196
+ - spec/celluloid/dns/server/bind9/named.run
197
+ - spec/celluloid/dns/server/million.rb
198
+ - spec/celluloid/dns/server_performance_spec.rb
199
+ - spec/celluloid/dns/slow_server_spec.rb
200
+ - spec/celluloid/dns/socket_spec.rb
201
+ - spec/celluloid/dns/system_spec.rb
202
+ - spec/celluloid/dns/transaction_spec.rb
203
+ - spec/celluloid/dns/truncation_spec.rb