Skip to content

Commit c5e8ab2

Browse files
committed
Modernize gem + documentation.
1 parent 4b30cec commit c5e8ab2

File tree

15 files changed

+96
-77
lines changed

15 files changed

+96
-77
lines changed

config/sus.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2024, by Samuel Williams.
4+
# Copyright, 2025, by Samuel Williams.
55

66
require "covered/sus"
77
include Covered::Sus

examples/fortune/server.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# frozen_string_literal: true
33

44
# Released under the MIT License.
5-
# Copyright, 2014, by Samuel Williams.
5+
# Copyright, 2014-2025, by Samuel Williams.
66
# Copyright, 2014, by Peter M. Goldstein.
77

88
require "rubydns"

examples/wikipedia/server.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env ruby
22
# encoding: utf-8
3-
# frozen_string_literal: true
3+
4+
# Released under the MIT License.
5+
# Copyright, 2014-2025, by Samuel Williams.
6+
# Copyright, 2014, by Peter M. Goldstein.
47

58
# Released under the MIT License.
69
# Copyright, 2014-2022, by Samuel Williams.

gems.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2012-2025, by Samuel Williams.
5+
26
source "https://rubygems.org"
37

48
gemspec
59

610
group :maintenance, optional: true do
11+
gem "bake-gem"
712
gem "bake-modernize"
8-
end
9-
10-
group :development do
11-
gem "process-daemon"
12-
gem "nio4r"
13+
gem "bake-releases"
14+
15+
gem "utopia-project"
1316
end
1417

1518
group :test do

guides/getting-started/readme.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Getting Started
2+
3+
This guide explains how to get started running your own DNS server with RubyDNS.
4+
5+
## Installation
6+
7+
Create a new directory for your project, with a gemfile, and then add the gem to your project:
8+
9+
~~~ bash
10+
$ bundle add rubydns
11+
~~~
12+
13+
## Usage
14+
15+
### Simple DNS Server
16+
17+
This example demonstrates how to create a simple DNS server that responds to `test.local A` and forwards all other requests to the system default resolver.
18+
19+
``` ruby
20+
#!/usr/bin/env ruby
21+
require 'rubydns'
22+
23+
# Use the system default resolver for upstream queries:
24+
upstream = Async::DNS::Resolver.default
25+
26+
# We will use port 5300 so we don't need to run the server as root:
27+
endpoint = Async::DNS::Endpoint.for("localhost", port: 5300)
28+
29+
# Start the RubyDNS server:
30+
RubyDNS.run(endpoint) do
31+
match(%r{test.local}, Resolv::DNS::Resource::IN::A) do |transaction|
32+
transaction.respond!("10.0.0.80")
33+
end
34+
35+
# Default DNS handler
36+
otherwise do |transaction|
37+
transaction.passthrough!(upstream)
38+
end
39+
end
40+
```
41+
42+
### Custom Servers
43+
44+
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).
45+
46+
``` ruby
47+
class MyServer < Async::DNS::Server
48+
def process(name, resource_class, transaction)
49+
transaction.fail!(:NXDomain)
50+
end
51+
end
52+
53+
Async do
54+
task = MyServer.new.run
55+
56+
# ... do other things, e.g. run specs/tests
57+
58+
# Shut down the server manually if required, otherwise it will run indefinitely.
59+
# task.stop
60+
end
61+
```
62+
63+
This is the best way to integrate with other projects.

guides/links.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
getting-started:
2+
order: 0

lib/rubydns.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2009-2017, by Samuel Williams.
4+
# Copyright, 2009-2025, by Samuel Williams.
55
# Copyright, 2014, by Peter M. Goldstein.
66

77
require "async/dns"

lib/rubydns/rule.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2009-2017, by Samuel Williams.
4+
# Copyright, 2009-2025, by Samuel Williams.
55
# Copyright, 2011, by Genki Sugawara.
66
# Copyright, 2014, by Zac Sprackett.
77
# Copyright, 2015, by Michal Cichra.

lib/rubydns/server.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2009-2017, by Samuel Williams.
4+
# Copyright, 2009-2025, by Samuel Williams.
55
# Copyright, 2011, by Genki Sugawara.
66
# Copyright, 2014, by Zac Sprackett.
77
# Copyright, 2015, by Michal Cichra.

lib/rubydns/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2009-2018, by Samuel Williams.
4+
# Copyright, 2009-2025, by Samuel Williams.
55

66
module RubyDNS
77
VERSION = "2.0.2"

license.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright, 2009-2022, by Samuel Williams.
3+
Copyright, 2009-2025, by Samuel Williams.
44
Copyright, 2011, by Genki Sugawara.
55
Copyright, 2012, by Satoshi Takada.
66
Copyright, 2013, by Erran Carey.

readme.md

-62
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,10 @@ RubyDNS is a high-performance DNS server which can be easily integrated into oth
44

55
[![Development Status](https://github.com/socketry/rubydns/workflows/Test/badge.svg)](https://github.com/socketry/rubydns/actions?workflow=Test)
66

7-
## Installation
8-
9-
Add the gem to your project:
10-
11-
~~~ bash
12-
$ bundle add rubydns
13-
~~~
14-
157
## Usage
168

179
There are examples in the `examples` directory which demonstrate how to use RubyDNS.
1810

19-
### Simple DNS Server
20-
21-
This example demonstrates how to create a simple DNS server that responds to `test.local A` and forwards all other requests to the system default resolver.
22-
23-
``` ruby
24-
#!/usr/bin/env ruby
25-
require 'rubydns'
26-
27-
# Use the system default resolver for upstream queries:
28-
upstream = Async::DNS::Resolver.default
29-
30-
# We will use port 5300 so we don't need to run the server as root:
31-
endpoint = Async::DNS::Endpoint.for("localhost", port: 5300)
32-
33-
# Start the RubyDNS server:
34-
RubyDNS.run(endpoint) do
35-
match(%r{test.local}, Resolv::DNS::Resource::IN::A) do |transaction|
36-
transaction.respond!("10.0.0.80")
37-
end
38-
39-
# Default DNS handler
40-
otherwise do |transaction|
41-
transaction.passthrough!(upstream)
42-
end
43-
end
44-
```
45-
46-
### Custom Servers
47-
48-
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).
49-
50-
``` ruby
51-
class MyServer < Async::DNS::Server
52-
def process(name, resource_class, transaction)
53-
transaction.fail!(:NXDomain)
54-
end
55-
end
56-
57-
Async do
58-
task = MyServer.new.run
59-
60-
# ... do other things, e.g. run specs/tests
61-
62-
# Shut down the server manually if required, otherwise it will run indefinitely.
63-
# task.stop
64-
end
65-
```
66-
67-
This is the best way to integrate with other projects.
68-
69-
### DNSSEC support
70-
71-
DNSSEC is currently not supported and is [unlikely to be supported in the future](http://sockpuppet.org/blog/2015/01/15/against-dnssec/).
72-
7311
## See Also
7412

7513
The majority of this gem is now implemented by `async-dns`.

releases.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Releases
2+
3+
## Unreleased
4+
5+
- Introduce `RubyDNS.run` as a slightly more modern way to run a server.
6+
- Move `RubyDNS::RuleBasedServer` to `RubyDNS::Server`.
7+
- Move `RubyDNS::RuleBasedServer::Rule` to `RubyDNS::Rule`.
8+
- Remove usage of `@logger`.

rubydns.gemspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ Gem::Specification.new do |spec|
1616
spec.homepage = "https://github.com/socketry/rubydns"
1717

1818
spec.metadata = {
19+
"documentation_uri" => "https://github.io/socketry/rubydns/",
20+
"funding_uri" => "https://github.com/sponsors/ioquatix/",
1921
"source_code_uri" => "https://github.com/socketry/rubydns.git",
2022
}
2123

22-
spec.files = Dir.glob(["{bin,examples,lib,spec}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__)
24+
spec.files = Dir.glob(["{lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__)
2325

2426
spec.executables = ["rubydns-check"]
2527

test/rubydns/rules.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# frozen_string_literal: true
33

44
# Released under the MIT License.
5-
# Copyright, 2012-2020, by Samuel Williams.
5+
# Copyright, 2012-2025, by Samuel Williams.
66

77
require "rubydns"
88

0 commit comments

Comments
 (0)