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.
- checksums.yaml +7 -0
- data/.rspec +0 -2
- data/.simplecov +15 -0
- data/.travis.yml +13 -7
- data/Gemfile +5 -6
- data/README.md +118 -41
- data/Rakefile +8 -3
- data/celluloid-dns.gemspec +29 -18
- data/lib/celluloid/dns.rb +30 -7
- data/lib/celluloid/dns/chunked.rb +34 -0
- data/lib/celluloid/dns/extensions/resolv.rb +136 -0
- data/lib/celluloid/dns/extensions/string.rb +28 -0
- data/lib/celluloid/dns/handler.rb +198 -0
- data/lib/celluloid/dns/logger.rb +31 -0
- data/lib/celluloid/dns/message.rb +76 -0
- data/lib/celluloid/dns/replace.rb +54 -0
- data/lib/celluloid/dns/resolver.rb +288 -0
- data/lib/celluloid/dns/server.rb +151 -27
- data/lib/celluloid/dns/system.rb +146 -0
- data/lib/celluloid/dns/transaction.rb +202 -0
- data/lib/celluloid/dns/transport.rb +75 -0
- data/lib/celluloid/dns/version.rb +23 -3
- data/spec/celluloid/dns/celluloid_bug_spec.rb +92 -0
- data/spec/celluloid/dns/hosts.txt +2 -0
- data/spec/celluloid/dns/ipv6_spec.rb +70 -0
- data/spec/celluloid/dns/message_spec.rb +56 -0
- data/spec/celluloid/dns/origin_spec.rb +106 -0
- data/spec/celluloid/dns/replace_spec.rb +42 -0
- data/spec/celluloid/dns/resolver_performance_spec.rb +110 -0
- data/spec/celluloid/dns/resolver_spec.rb +152 -0
- data/spec/celluloid/dns/server/bind9/generate-local.rb +25 -0
- data/spec/celluloid/dns/server/bind9/local.zone +5014 -0
- data/spec/celluloid/dns/server/bind9/named.conf +14 -0
- data/spec/celluloid/dns/server/bind9/named.run +0 -0
- data/spec/celluloid/dns/server/million.rb +85 -0
- data/spec/celluloid/dns/server_performance_spec.rb +139 -0
- data/spec/celluloid/dns/slow_server_spec.rb +91 -0
- data/spec/celluloid/dns/socket_spec.rb +71 -0
- data/spec/celluloid/dns/system_spec.rb +60 -0
- data/spec/celluloid/dns/transaction_spec.rb +138 -0
- data/spec/celluloid/dns/truncation_spec.rb +62 -0
- metadata +124 -56
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -17
- data/CHANGES.md +0 -3
- data/LICENSE.txt +0 -22
- data/lib/celluloid/dns/request.rb +0 -46
- data/spec/celluloid/dns/server_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -5
- data/tasks/rspec.task +0 -7
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service-name: travis-pro
|
data/.gitignore
DELETED
data/CHANGES.md
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Tony Arcieri
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'resolv'
|
2
|
-
|
3
|
-
module Celluloid
|
4
|
-
module DNS
|
5
|
-
class Request
|
6
|
-
attr_reader :questions
|
7
|
-
|
8
|
-
def initialize(addr, port, socket, data)
|
9
|
-
@addr, @port, @socket = addr, port, socket
|
10
|
-
@message = Resolv::DNS::Message.decode(data)
|
11
|
-
@questions = @message.question.map { |question, resource| Question.new(question, resource) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def answer(responses)
|
15
|
-
response_message = Resolv::DNS::Message.new @message.id
|
16
|
-
response_message.qr = 1
|
17
|
-
response_message.opcode = @message.opcode
|
18
|
-
response_message.aa = 1
|
19
|
-
response_message.rd = @message.rd
|
20
|
-
response_message.ra = 0
|
21
|
-
response_message.rcode = 0
|
22
|
-
|
23
|
-
responses.each do |question, response|
|
24
|
-
response_object = question.resource.new(response)
|
25
|
-
response_message.add_answer question.name, DEFAULT_TTL, response_object
|
26
|
-
end
|
27
|
-
|
28
|
-
@socket.send response_message.encode, 0, @addr, @port
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Question
|
33
|
-
attr_reader :resource
|
34
|
-
|
35
|
-
def initialize(question, resource)
|
36
|
-
@question, @resource = question, resource
|
37
|
-
end
|
38
|
-
|
39
|
-
# Obtain the name being queried
|
40
|
-
def name
|
41
|
-
raise TypeError, "not a name query" unless @question.is_a? Resolv::DNS::Name
|
42
|
-
@question.to_s
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'resolv'
|
3
|
-
|
4
|
-
describe Celluloid::DNS::Server do
|
5
|
-
let(:example_host) { '127.0.0.1' }
|
6
|
-
let(:example_port) { 54321 }
|
7
|
-
let(:example_name) { 'example.com' }
|
8
|
-
let(:example_ip) { '1.2.3.4' }
|
9
|
-
|
10
|
-
it "answers DNS requests" do
|
11
|
-
server = Celluloid::DNS::Server.new(example_host, example_port) do |request|
|
12
|
-
question = request.questions.first
|
13
|
-
|
14
|
-
question.name.should == example_name
|
15
|
-
request.answer(question => example_ip)
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
Resolv::DNS.open(nameserver_port: [[example_host, example_port]]) do |resolv|
|
20
|
-
resolv.getaddress(example_name).to_s.should eq example_ip
|
21
|
-
end
|
22
|
-
ensure
|
23
|
-
server.terminate
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/spec_helper.rb
DELETED