rubydns 0.6.0 → 2.0.0
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.
- checksums.yaml +6 -14
- data/.gitignore +23 -14
- data/.rspec +4 -0
- data/.simplecov +15 -0
- data/.travis.yml +9 -5
- data/.yardopts +1 -0
- data/Gemfile +6 -2
- data/README.md +82 -92
- data/Rakefile +2 -5
- data/bin/rubydns-check +374 -0
- data/examples/Gemfile +7 -0
- data/examples/README.md +137 -0
- data/examples/basic-dns.rb +24 -0
- data/examples/cname.rb +25 -0
- data/{test/examples/dropping-dns.rb → examples/flakey-dns.rb} +28 -31
- data/{test/examples → examples}/fortune-dns.rb +42 -46
- data/examples/geoip-dns.rb +115 -0
- data/examples/simple.rb +25 -0
- data/{test/examples → examples}/soa-dns.rb +27 -27
- data/{test/examples → examples}/test-dns-1.rb +26 -20
- data/{test/examples → examples}/test-dns-2.rb +17 -19
- data/examples/wikipedia-dns.rb +107 -0
- data/lib/rubydns/rule_based_server.rb +180 -0
- data/lib/rubydns/version.rb +1 -1
- data/lib/rubydns.rb +13 -63
- data/rubydns.gemspec +29 -23
- data/spec/rubydns/daemon_spec.rb +114 -0
- data/{test/test_system.rb → spec/rubydns/injected_supervisor_spec.rb} +32 -25
- data/spec/rubydns/passthrough_spec.rb +85 -0
- data/spec/rubydns/rules_spec.rb +74 -0
- data/spec/spec_helper.rb +30 -0
- metadata +101 -78
- data/bin/rd-dns-check +0 -374
- data/bin/rd-resolve-test +0 -160
- data/lib/rubydns/chunked.rb +0 -34
- data/lib/rubydns/extensions/hexdump.rb +0 -38
- data/lib/rubydns/extensions/logger.rb +0 -30
- data/lib/rubydns/extensions/resolv.rb +0 -53
- data/lib/rubydns/extensions/string-1.8.rb +0 -35
- data/lib/rubydns/extensions/string-1.9.2.rb +0 -29
- data/lib/rubydns/extensions/string-1.9.3.rb +0 -31
- data/lib/rubydns/extensions/string.rb +0 -27
- data/lib/rubydns/handler.rb +0 -140
- data/lib/rubydns/message.rb +0 -41
- data/lib/rubydns/resolver.rb +0 -239
- data/lib/rubydns/server.rb +0 -241
- data/lib/rubydns/system.rb +0 -146
- data/lib/rubydns/transaction.rb +0 -250
- data/test/examples/geoip-dns.rb +0 -86
- data/test/helper.rb +0 -9
- data/test/test_daemon.rb +0 -100
- data/test/test_domains.txt +0 -185
- data/test/test_passthrough.rb +0 -80
- data/test/test_resolver.rb +0 -105
- data/test/test_rules.rb +0 -74
- data/test/test_slow_server.rb +0 -98
- data/test/test_truncation.rb +0 -78
- /data/{test → spec/rubydns}/hosts.txt +0 -0
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
metadata.gz: !binary |-
|
|
9
|
-
MWZiMTBlY2YxYjdiYzIzMDU0OTBhMzBkN2RiZjY4OWZlNGFjNzM2ZGUxZTUx
|
|
10
|
-
NDE0MzdiMjFiZTg5OTM2NmVhNjcwMmY0NjE1MzNlN2JmZWM4MTIxMjQwYjk2
|
|
11
|
-
MjVjOTViMDNkYzQ0NTBlZTdlODIzM2IyZDg3NjEwZjNhMDBlNTM=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
NzJiNGE4YjhjY2Q4MjQ3MWU0ODgwOTk4NWJlM2YwYmQ4OWZlNDdkYTIxOTU2
|
|
14
|
-
Y2FjN2UwZjZhNGYzMzc5NDY2NDYyNDFmMmVkMDZkYjg4Zjk2MWQyZjA3YzEw
|
|
15
|
-
NTRlYzZjM2JkYTFjNzUyZDYyNGMwODUxZDdiNjc5NTllZjhmODM=
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: bac5139eae169f981088495e6dc4bde5d13fa966
|
|
4
|
+
data.tar.gz: 0ee8216c43d6600fb811ee83d708ac984d2807df
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: caa862959c454afebceddbf387e5722ff6a013a6c1c6012f5cb5acf1ec4d6c9422ea1c641fb3b776ecd270ec9278640e6b7088b64cbcea9ce8e8783c579f45a1
|
|
7
|
+
data.tar.gz: 136467f2543e9eb1ae01b158cca987ec1757d01bd2aa10c695249a204a68a8e88137b39cc907f4bf9cc544c9046a94848542fddde3578f6bf553459e1c81c9bf
|
data/.gitignore
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
*.gem
|
|
2
2
|
*.rbc
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
doc/
|
|
11
|
-
lib/bundler/man
|
|
12
|
-
pkg
|
|
13
|
-
rdoc
|
|
14
|
-
spec/reports
|
|
15
|
-
test/tmp
|
|
16
|
-
test/version_tmp
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/test/tmp/
|
|
9
|
+
/test/version_tmp/
|
|
17
10
|
tmp
|
|
11
|
+
|
|
12
|
+
/.yardoc/
|
|
13
|
+
/_yardoc/
|
|
14
|
+
/doc/
|
|
15
|
+
/rdoc/
|
|
16
|
+
|
|
17
|
+
/.bundle/
|
|
18
|
+
/lib/bundler/man/
|
|
19
|
+
|
|
20
|
+
Gemfile.lock
|
|
21
|
+
.ruby-version
|
|
22
|
+
.ruby-gemset
|
|
23
|
+
|
|
24
|
+
/examples/log
|
|
25
|
+
/examples/run
|
|
26
|
+
/spec/rubydns/server/bind9/log/
|
data/.rspec
ADDED
data/.simplecov
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
SimpleCov.start do
|
|
3
|
+
add_filter "/spec/"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
# Work correctly across forks:
|
|
7
|
+
pid = Process.pid
|
|
8
|
+
SimpleCov.at_exit do
|
|
9
|
+
SimpleCov.result.format! if Process.pid == pid
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if ENV['TRAVIS']
|
|
13
|
+
require 'coveralls'
|
|
14
|
+
Coveralls.wear!
|
|
15
|
+
end
|
data/.travis.yml
CHANGED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--markup=markdown
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,144 +1,125 @@
|
|
|
1
1
|
# RubyDNS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://gitter.im/ioquatix/rubydns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
RubyDNS is a high-performance DNS server which can be easily integrated into other projects or used as a stand-alone daemon. By default it uses rule-based pattern matching. Results can be hard-coded, computed, fetched from a remote DNS server or fetched from a local cache, depending on requirements.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[](https://travis-ci.org/ioquatix/rubydns)
|
|
8
|
+
[](https://codeclimate.com/github/ioquatix/rubydns)
|
|
9
|
+
[](https://coveralls.io/r/ioquatix/rubydns)
|
|
8
10
|
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
[](http://travis-ci.org/ioquatix/rubydns)
|
|
11
|
+
[](https://www.youtube.com/watch?v=B9ygq0xh3HQ&feature=youtu.be&hd=1 "RubyDNS Introduction")
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
Add this line to your application's Gemfile:
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
gem 'rubydns'
|
|
18
18
|
|
|
19
19
|
And then execute:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
$ bundle
|
|
22
22
|
|
|
23
23
|
Or install it yourself as:
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
$ gem install rubydns
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
There are [lots of examples available](examples/README.md) in the `examples/` directory.
|
|
30
|
+
|
|
31
|
+
### Basic DNS Server
|
|
32
|
+
|
|
33
|
+
Here is the code from `examples/basic-dns.rb`:
|
|
34
|
+
|
|
30
35
|
```ruby
|
|
31
36
|
#!/usr/bin/env ruby
|
|
32
37
|
require 'rubydns'
|
|
33
38
|
|
|
34
39
|
INTERFACES = [
|
|
35
|
-
[:udp, "0.0.0.0",
|
|
36
|
-
[:tcp, "0.0.0.0",
|
|
40
|
+
[:udp, "0.0.0.0", 5300],
|
|
41
|
+
[:tcp, "0.0.0.0", 5300],
|
|
37
42
|
]
|
|
38
|
-
|
|
43
|
+
|
|
39
44
|
IN = Resolv::DNS::Resource::IN
|
|
40
45
|
|
|
41
46
|
# Use upstream DNS for name resolution.
|
|
42
47
|
UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
end
|
|
49
|
+
# Start the RubyDNS server
|
|
50
|
+
RubyDNS::run_server(INTERFACES) do
|
|
51
|
+
match(%r{test.local}, IN::A) do |transaction|
|
|
52
|
+
transaction.respond!("10.0.0.80")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Default DNS handler
|
|
56
|
+
otherwise do |transaction|
|
|
57
|
+
transaction.passthrough!(UPSTREAM)
|
|
58
|
+
end
|
|
56
59
|
end
|
|
57
|
-
run
|
|
58
|
-
```
|
|
59
|
-
Start the server using `rvmsudo ./test.rb`. You can then test it using dig:
|
|
60
|
-
```
|
|
61
|
-
$ dig @localhost test1.mydomain.org
|
|
62
|
-
$ dig @localhost dev.mydomain.org
|
|
63
|
-
$ dig @localhost google.com
|
|
64
60
|
```
|
|
65
61
|
|
|
66
|
-
|
|
62
|
+
Start the server using `RUBYOPT=-w ./examples/basic-dns.rb`. You can then test it using dig:
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
$ dig @localhost -p 5300 test.local
|
|
65
|
+
$ dig @localhost -p 5300 google.com
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
### File Handle Limitations
|
|
71
68
|
|
|
72
|
-
|
|
69
|
+
On some platforms (e.g. Mac OS X) the number of file descriptors is relatively low by default and should be increased by calling `ulimit -n 10000` before running tests or even before starting a server which expects a large number of concurrent incoming connections.
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
```ruby
|
|
76
|
-
match(..., :A)
|
|
77
|
-
```
|
|
78
|
-
becomes
|
|
79
|
-
```ruby
|
|
80
|
-
IN = Resolv::DNS::Resource::IN
|
|
81
|
-
match(..., IN::A)
|
|
82
|
-
```
|
|
83
|
-
### Migrating from RubyDNS 0.4.x to 0.5.x ###
|
|
71
|
+
### Custom Servers
|
|
84
72
|
|
|
85
|
-
|
|
73
|
+
It is possible to create and integrate your own custom servers, however this functionality has now moved to [`Async::DNS::Server`](https://github.com/socketry/async-dns).
|
|
86
74
|
|
|
87
|
-
Here is a basic example of how to use the new resolver in full. It is important to provide both `:udp` and `:tcp` connection specifications, so that large requests will be handled correctly:
|
|
88
75
|
```ruby
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
resolver.query('google.com', IN::A) do |response|
|
|
93
|
-
case response
|
|
94
|
-
when RubyDNS::Message
|
|
95
|
-
puts "Got response: #{response.answers.first}"
|
|
96
|
-
else
|
|
97
|
-
# Response is of class RubyDNS::ResolutionFailure
|
|
98
|
-
puts "Failed: #{response.message}"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
EventMachine::stop
|
|
76
|
+
class MyServer < Async::DNS::Server
|
|
77
|
+
def process(name, resource_class, transaction)
|
|
78
|
+
transaction.fail!(:NXDomain)
|
|
102
79
|
end
|
|
103
80
|
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
|
|
82
|
+
Async::Reactor.run do
|
|
83
|
+
task = MyServer.run
|
|
84
|
+
|
|
85
|
+
# ... do other things
|
|
109
86
|
|
|
110
|
-
#
|
|
111
|
-
|
|
87
|
+
# Shut down the server:
|
|
88
|
+
task.stop
|
|
89
|
+
end
|
|
112
90
|
```
|
|
113
|
-
Everything else in the server can remain the same. You can see a complete example in `test/test_resolver.rb`.
|
|
114
91
|
|
|
115
|
-
|
|
92
|
+
This is the best way to integrate with other projects.
|
|
116
93
|
|
|
117
|
-
|
|
94
|
+
## Performance
|
|
118
95
|
|
|
119
|
-
|
|
120
|
-
transaction.defer!
|
|
121
|
-
```
|
|
96
|
+
**Due to changes in the underlying code, there have been some very minor performance regressions. The numbers below will be updated in due course.**
|
|
122
97
|
|
|
123
|
-
|
|
124
|
-
```ruby
|
|
125
|
-
RubyDNS::run_server(:listen => SERVER_PORTS) do
|
|
126
|
-
match(/\.*.com/, IN::A) do |transaction|
|
|
127
|
-
transaction.defer!
|
|
128
|
-
|
|
129
|
-
# No domain exists, after 5 seconds:
|
|
130
|
-
EventMachine::Timer.new(5) do
|
|
131
|
-
transaction.failure!(:NXDomain)
|
|
132
|
-
end
|
|
133
|
-
end
|
|
98
|
+
We welcome additional benchmarks and feedback regarding RubyDNS performance. To check the current performance results, consult the [travis build job output](https://travis-ci.org/ioquatix/rubydns).
|
|
134
99
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
100
|
+
### Server
|
|
101
|
+
|
|
102
|
+
The performance is on the same magnitude as `bind9`. Some basic benchmarks resolving 1000 names concurrently, repeated 5 times, using `RubyDNS::Resolver` gives the following:
|
|
103
|
+
|
|
104
|
+
user system total real
|
|
105
|
+
RubyDNS::Server 4.280000 0.450000 4.730000 ( 4.854862)
|
|
106
|
+
Bind9 4.970000 0.520000 5.490000 ( 5.541213)
|
|
140
107
|
|
|
141
|
-
|
|
108
|
+
These benchmarks are included in the unit tests. To test bind9 performance, it must be installed and `which named` must return the executable.
|
|
109
|
+
|
|
110
|
+
### Resolver
|
|
111
|
+
|
|
112
|
+
The `RubyDNS::Resolver` is highly concurrent and can resolve individual names as fast as the built in `Resolv::DNS` resolver. Because the resolver is asynchronous, when dealing with multiple names, it can work more efficiently:
|
|
113
|
+
|
|
114
|
+
user system total real
|
|
115
|
+
RubyDNS::Resolver 0.020000 0.010000 0.030000 ( 0.030507)
|
|
116
|
+
Resolv::DNS 0.070000 0.010000 0.080000 ( 1.465975)
|
|
117
|
+
|
|
118
|
+
These benchmarks are included in the unit tests.
|
|
119
|
+
|
|
120
|
+
### DNSSEC support
|
|
121
|
+
|
|
122
|
+
DNSSEC is currently not supported and is [unlikely to be supported in the future](http://sockpuppet.org/blog/2015/01/15/against-dnssec/).
|
|
142
123
|
|
|
143
124
|
## Contributing
|
|
144
125
|
|
|
@@ -152,12 +133,21 @@ You can see a complete example in `test/test_slow_server.rb`.
|
|
|
152
133
|
|
|
153
134
|
* Support for more features of DNS such as zone transfer.
|
|
154
135
|
* Support reverse records more easily.
|
|
136
|
+
* Some kind of system level integration, e.g. registering a DNS server with the currently running system resolver.
|
|
137
|
+
|
|
138
|
+
## See Also
|
|
139
|
+
|
|
140
|
+
The majority of this gem is now implemented by `async-dns`.
|
|
141
|
+
|
|
142
|
+
- [async-io](https://github.com/socketry/async-io) — Asynchronous networking and sockets.
|
|
143
|
+
- [async-dns](https://github.com/socketry/async-dns) — Asynchronous DNS resolver and server.
|
|
144
|
+
- [async-rspec](https://github.com/socketry/async-rspec) — Shared contexts for running async specs.
|
|
155
145
|
|
|
156
146
|
## License
|
|
157
147
|
|
|
158
148
|
Released under the MIT license.
|
|
159
149
|
|
|
160
|
-
Copyright,
|
|
150
|
+
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
|
161
151
|
|
|
162
152
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
163
153
|
of this software and associated documentation files (the "Software"), to deal
|