async-dns 1.2.5 → 1.2.6

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/Rakefile DELETED
@@ -1,32 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:test)
5
-
6
- task :default => :test
7
-
8
- task :console do
9
- require 'pry'
10
-
11
- require_relative 'lib/async/dns'
12
-
13
- Pry.start
14
- end
15
-
16
- task :server do
17
- require_relative 'lib/async/dns'
18
-
19
- class TestServer < Async::DNS::Server
20
- def process(name, resource_class, transaction)
21
- @resolver ||= Async::DNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
22
-
23
- transaction.passthrough!(@resolver)
24
- end
25
- end
26
-
27
- server = TestServer.new([[:udp, '127.0.0.1', 2346]])
28
-
29
- Async::Reactor.run do
30
- server.run
31
- end
32
- end
data/async-dns.gemspec DELETED
@@ -1,31 +0,0 @@
1
-
2
- require_relative 'lib/async/dns/version'
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = "async-dns"
6
- spec.version = Async::DNS::VERSION
7
- spec.authors = ["Samuel Williams"]
8
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
9
- spec.description = <<-EOF
10
- Async::DNS provides a high-performance DNS client resolver and server
11
- which can be easily integrated into other projects or used as a stand-alone
12
- daemon.
13
- EOF
14
- spec.summary = "An easy to use DNS client resolver and server for Ruby."
15
- spec.homepage = "https://github.com/socketry/async-dns"
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files`.split($/)
19
- spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_dependency("async-io", "~> 1.15")
24
-
25
- spec.add_development_dependency "async-rspec", "~> 1.0"
26
- spec.add_development_dependency "process-daemon", "~> 1.0"
27
-
28
- spec.add_development_dependency "bundler"
29
- spec.add_development_dependency "rspec", "~> 3.6"
30
- spec.add_development_dependency "rake"
31
- end
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- gem 'async'
4
- gem 'async-http'
5
- gem 'trenni'
6
-
7
- require 'async/reactor'
8
- require 'async/http/client'
9
- require 'async/http/url_endpoint'
10
-
11
- require 'trenni/uri'
12
-
13
- endpoint = Async::HTTP::URLEndpoint.parse("https://cloudflare-dns.com/dns-query")
14
- client = Async::HTTP::Client.new(endpoint)
15
-
16
- Async::Reactor.run do |task|
17
- request_uri = Trenni::URI(endpoint.url.request_uri, ct: "application/dns-json", name: "microsoft.com", type: "MX")
18
-
19
- puts "GET #{request_uri}"
20
- response = client.get(request_uri.to_s, {})
21
-
22
- puts "#{response.status} #{response.version} #{response.headers.inspect}"
23
- puts response.read.inspect
24
- end
@@ -1,60 +0,0 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require 'async/dns'
22
- require 'async/dns/system'
23
-
24
- describe Async::DNS::StreamHandler do
25
- include_context Async::RSpec::Reactor
26
-
27
- let(:server) {Async::DNS::Server.new}
28
- let(:endpoint) {Async::IO::Endpoint.tcp('127.0.0.1', 6666, reuse_port: true)}
29
-
30
- it "can rebind port" do
31
- 2.times do
32
- task = reactor.async do
33
- endpoint.bind do |socket|
34
- described_class.new(server, socket).run
35
- end
36
- end
37
-
38
- task.stop
39
- end
40
- end
41
- end
42
-
43
- describe Async::DNS::DatagramHandler do
44
- include_context Async::RSpec::Reactor
45
-
46
- let(:server) {Async::DNS::Server.new}
47
- let(:endpoint) {Async::IO::Endpoint.udp('127.0.0.1', 6666)}
48
-
49
- it "can rebind port" do
50
- 2.times do
51
- task = reactor.async do
52
- endpoint.bind do |socket|
53
- described_class.new(server, socket).run
54
- end
55
- end
56
-
57
- task.stop
58
- end
59
- end
60
- end
@@ -1,2 +0,0 @@
1
- # A testing host:
2
- 1.2.3.4 testing apples
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env ruby
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 'async/dns'
24
- require 'async/dns/system'
25
-
26
- module Async::DNS::IPv6Spec
27
- IN = Resolv::DNS::Resource::IN
28
-
29
- class TestServer < Async::DNS::Server
30
- def process(name, resource_class, transaction)
31
- @resolver ||= Async::DNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
32
-
33
- transaction.passthrough!(@resolver)
34
- end
35
- end
36
-
37
- describe Async::DNS::StreamHandler do
38
- include_context Async::RSpec::Reactor
39
-
40
- let(:server_interfaces) {[[:tcp, '::', 2004]]}
41
- let(:server) {TestServer.new(server_interfaces)}
42
-
43
- it "should connect to the server using TCP via IPv6" do
44
- task = server.run
45
-
46
- resolver = Async::DNS::Resolver.new([[:tcp, '::1', 2004]])
47
-
48
- response = resolver.query('google.com')
49
-
50
- expect(response.class).to be == Async::DNS::Message
51
- expect(response.rcode).to be == 0
52
- expect(response.answer).to_not be_empty
53
-
54
- task.stop
55
- end
56
- end
57
-
58
- describe Async::DNS::DatagramHandler do
59
- include_context Async::RSpec::Reactor
60
-
61
- let(:server_interfaces) {[[:udp, '::', 2006]]}
62
- let(:server) {TestServer.new(server_interfaces)}
63
-
64
- it "should connect to the server using UDP via IPv6" do
65
- task = server.run
66
-
67
- resolver = Async::DNS::Resolver.new([[:udp, '::1', 2006]])
68
-
69
- response = resolver.query('google.com')
70
-
71
- expect(response.class).to be == Async::DNS::Message
72
- expect(response.rcode).to be == 0
73
- expect(response.answer).to_not be_empty
74
-
75
- task.stop
76
- end
77
- end
78
- end
@@ -1,62 +0,0 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- RSpec.shared_context "Junk UDP Server" do
22
- let(:server_endpoint) {Async::IO::Endpoint.udp('0.0.0.0', 6060, reuse_port: true)}
23
-
24
- let!(:server_task) do
25
- reactor.async do
26
- server_endpoint.bind do |socket|
27
- begin
28
- while true
29
- data, address = socket.recvfrom(1024)
30
- socket.send("foobar", 0, address)
31
- end
32
- rescue
33
- socket.close
34
- end
35
- end
36
- end
37
- end
38
-
39
- after(:each) do
40
- server_task.stop
41
- end
42
- end
43
-
44
- RSpec.shared_context "Junk TCP Server" do
45
- let(:server_endpoint) {Async::IO::Endpoint.tcp('0.0.0.0', 6060, reuse_port: true)}
46
-
47
- let!(:server_task) do
48
- reactor.async do
49
- server_endpoint.accept do |socket|
50
- begin
51
- socket.write("f\0\0bar")
52
- rescue
53
- socket.close
54
- end
55
- end
56
- end
57
- end
58
-
59
- after(:each) do
60
- server_task.stop
61
- end
62
- end
@@ -1,56 +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 'base64'
25
-
26
- module Async::DNS::MessageSpec
27
- describe Async::DNS::Message do
28
- it "should be decoded correctly" do
29
- data = Base64.decode64(<<-EOF)
30
- HQCBgAABAAgAAAABA3d3dwV5YWhvbwNjb20AAAEAAcAMAAUAAQAAASwADwZm
31
- ZC1mcDMDd2cxAWLAEMArAAUAAQAAASwACQZkcy1mcDPAMsBGAAUAAQAAADwA
32
- FQ5kcy1hbnktZnAzLWxmYgN3YTHANsBbAAUAAQAAASwAEg9kcy1hbnktZnAz
33
- LXJlYWzAasB8AAEAAQAAADwABGKK/B7AfAABAAEAAAA8AARii7SVwHwAAQAB
34
- AAAAPAAEYou3GMB8AAEAAQAAADwABGKK/W0AACkQAAAAAAAAAA==
35
- EOF
36
-
37
- message = Async::DNS::decode_message(data)
38
- expect(message.class).to be == Async::DNS::Message
39
- expect(message.id).to be == 0x1d00
40
-
41
- expect(message.question.size).to be == 1
42
- expect(message.answer.size).to be == 8
43
- expect(message.authority.size).to be == 0
44
- expect(message.additional.size).to be == 1
45
- end
46
-
47
- it "should fail to decode due to bad AAAA length" do
48
- data = Base64.decode64(<<-EOF)
49
- 6p6BgAABAAEAAAABCGJhaWNhaWNuA2NvbQAAHAABwAwAHAABAAABHgAEMhd7
50
- dwAAKRAAAAAAAAAA
51
- EOF
52
-
53
- expect{Async::DNS::decode_message(data)}.to raise_error(Async::DNS::DecodeError)
54
- end
55
- end
56
- end
@@ -1,106 +0,0 @@
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 'async/dns'
24
-
25
- module Async::DNS::OriginSpec
26
- describe Async::DNS::Resolver do
27
- it "should generate fully qualified domain name with specified origin" do
28
- resolver = Async::DNS::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