async-dns 1.2.1 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/dns/extensions/resolv.rb +1 -2
- data/lib/async/dns/handler.rb +11 -9
- data/lib/async/dns/resolver.rb +6 -4
- data/lib/async/dns/server.rb +1 -1
- data/lib/async/dns/transport.rb +27 -51
- data/lib/async/dns/version.rb +1 -1
- metadata +50 -75
- data/.editorconfig +0 -6
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -27
- data/Gemfile +0 -18
- data/README.md +0 -148
- data/Rakefile +0 -32
- data/async-dns.gemspec +0 -31
- data/examples/cloudflare.rb +0 -24
- data/spec/async/dns/handler_spec.rb +0 -60
- data/spec/async/dns/hosts.txt +0 -2
- data/spec/async/dns/ipv6_spec.rb +0 -78
- data/spec/async/dns/junk_server_context.rb +0 -62
- data/spec/async/dns/message_spec.rb +0 -56
- data/spec/async/dns/origin_spec.rb +0 -106
- data/spec/async/dns/replace_spec.rb +0 -44
- data/spec/async/dns/resolver_performance_spec.rb +0 -108
- data/spec/async/dns/resolver_spec.rb +0 -104
- data/spec/async/dns/server/bind9/generate-local.rb +0 -25
- data/spec/async/dns/server/bind9/local.zone +0 -5014
- data/spec/async/dns/server/bind9/named.conf +0 -14
- data/spec/async/dns/server/bind9/named.run +0 -0
- data/spec/async/dns/server/million.rb +0 -83
- data/spec/async/dns/server_performance_spec.rb +0 -159
- data/spec/async/dns/slow_server_spec.rb +0 -97
- data/spec/async/dns/socket_spec.rb +0 -72
- data/spec/async/dns/system_spec.rb +0 -57
- data/spec/async/dns/transaction_spec.rb +0 -140
- data/spec/async/dns/truncation_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -57
@@ -1,140 +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 'async/dns'
|
24
|
-
require 'yaml'
|
25
|
-
|
26
|
-
module Async::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 Async::DNS::Transaction do
|
31
|
-
let(:server) { Async::DNS::Server.new }
|
32
|
-
let(:query) { Async::DNS::Message.new(0) }
|
33
|
-
let(:question) { Resolv::DNS::Name.create("www.google.com.") }
|
34
|
-
let(:response) { Async::DNS::Message.new(0) }
|
35
|
-
let(:resolver) { Async::DNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])}
|
36
|
-
|
37
|
-
include_context Async::RSpec::Reactor
|
38
|
-
|
39
|
-
it "should append an address" do
|
40
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::A, response)
|
41
|
-
|
42
|
-
transaction.respond!("1.2.3.4")
|
43
|
-
|
44
|
-
expect(transaction.response.answer[0][0]).to be == question
|
45
|
-
expect(transaction.response.answer[0][2].address.to_s).to be == "1.2.3.4"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should passthrough the request" do
|
49
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::A, response)
|
50
|
-
|
51
|
-
expect(transaction.response.answer.size).to be 0
|
52
|
-
|
53
|
-
transaction.passthrough!(resolver)
|
54
|
-
|
55
|
-
expect(transaction.response.answer.size).to be > 0
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should return a response on passthrough" do
|
59
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::A, response)
|
60
|
-
|
61
|
-
expect(transaction.response.answer.size).to be 0
|
62
|
-
|
63
|
-
response = transaction.passthrough(resolver)
|
64
|
-
|
65
|
-
expect(response.answer.length).to be > 0
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should call the block with the response when invoking passthrough!" do
|
69
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::A, response)
|
70
|
-
|
71
|
-
expect(transaction.response.answer.size).to be 0
|
72
|
-
|
73
|
-
passthrough_response = nil
|
74
|
-
|
75
|
-
transaction.passthrough!(resolver) do |response|
|
76
|
-
passthrough_response = response
|
77
|
-
end
|
78
|
-
|
79
|
-
expect(passthrough_response.answer.length).to be > 0
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should fail the request" do
|
83
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::A, response)
|
84
|
-
|
85
|
-
transaction.fail! :NXDomain
|
86
|
-
|
87
|
-
expect(transaction.response.rcode).to be Resolv::DNS::RCode::NXDomain
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should return AAAA record" do
|
91
|
-
transaction = Async::DNS::Transaction.new(server, query, question, IN::AAAA, response)
|
92
|
-
|
93
|
-
expect(transaction.response.answer.size).to be 0
|
94
|
-
|
95
|
-
transaction.passthrough!(resolver)
|
96
|
-
|
97
|
-
expect(transaction.response.answer.first[2]).to be_kind_of IN::AAAA
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should return MX record" do
|
101
|
-
transaction = Async::DNS::Transaction.new(server,query,"google.com",IN::MX, response)
|
102
|
-
|
103
|
-
expect(transaction.response.answer.size).to be 0
|
104
|
-
|
105
|
-
transaction.passthrough!(resolver)
|
106
|
-
|
107
|
-
expect(transaction.response.answer.first[2]).to be_kind_of IN::MX
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should return NS record" do
|
111
|
-
transaction = Async::DNS::Transaction.new(server, query, "google.com", IN::NS, response)
|
112
|
-
|
113
|
-
expect(transaction.response.answer.size).to be 0
|
114
|
-
|
115
|
-
transaction.passthrough!(resolver)
|
116
|
-
|
117
|
-
expect(transaction.response.answer.first[2]).to be_kind_of IN::NS
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should return PTR record" do
|
121
|
-
transaction = Async::DNS::Transaction.new(server, query, "8.8.8.8.in-addr.arpa", IN::PTR, response)
|
122
|
-
|
123
|
-
expect(transaction.response.answer.size).to be 0
|
124
|
-
|
125
|
-
transaction.passthrough!(resolver)
|
126
|
-
|
127
|
-
expect(transaction.response.answer.first[2]).to be_kind_of IN::PTR
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should return SOA record" do
|
131
|
-
transaction = Async::DNS::Transaction.new(server, query, "google.com", IN::SOA, response)
|
132
|
-
|
133
|
-
expect(transaction.response.answer.size).to be 0
|
134
|
-
|
135
|
-
transaction.passthrough!(resolver)
|
136
|
-
|
137
|
-
expect(transaction.response.answer.first[2]).to be_kind_of IN::SOA
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,61 +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 'async/dns'
|
24
|
-
require 'async/dns/extensions/string'
|
25
|
-
|
26
|
-
module Async::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 < Async::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 "Async::DNS Truncation Server" do
|
43
|
-
include_context Async::RSpec::Reactor
|
44
|
-
|
45
|
-
let(:server) {TestServer.new(SERVER_PORTS)}
|
46
|
-
|
47
|
-
it "should use tcp because of large response" do
|
48
|
-
task = server.run
|
49
|
-
|
50
|
-
resolver = Async::DNS::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
|
-
|
58
|
-
task.stop
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
if ENV['COVERAGE'] || ENV['TRAVIS']
|
3
|
-
begin
|
4
|
-
require 'simplecov'
|
5
|
-
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter "/spec/"
|
8
|
-
end
|
9
|
-
|
10
|
-
# Work correctly across forks:
|
11
|
-
pid = Process.pid
|
12
|
-
SimpleCov.at_exit do
|
13
|
-
SimpleCov.result.format! if Process.pid == pid
|
14
|
-
end
|
15
|
-
|
16
|
-
if ENV['TRAVIS']
|
17
|
-
require 'coveralls'
|
18
|
-
Coveralls.wear!
|
19
|
-
end
|
20
|
-
rescue LoadError
|
21
|
-
warn "Could not load simplecov: #{$!}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
require "bundler/setup"
|
26
|
-
require "async/rspec"
|
27
|
-
require "async/dns"
|
28
|
-
|
29
|
-
begin
|
30
|
-
require 'ruby-prof'
|
31
|
-
|
32
|
-
RSpec.shared_context "profile" do
|
33
|
-
around(:each) do |example|
|
34
|
-
profile = RubyProf.profile(merge_fibers: true) do
|
35
|
-
example.run
|
36
|
-
end
|
37
|
-
|
38
|
-
printer = RubyProf::FlatPrinter.new(profile)
|
39
|
-
printer.print(STDOUT)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
rescue LoadError
|
43
|
-
RSpec.shared_context "profile" do
|
44
|
-
before(:all) do
|
45
|
-
puts "Profiling not supported on this platform."
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
RSpec.configure do |config|
|
51
|
-
# Enable flags like --only-failures and --next-failure
|
52
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
53
|
-
|
54
|
-
config.expect_with :rspec do |c|
|
55
|
-
c.syntax = :expect
|
56
|
-
end
|
57
|
-
end
|