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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 8 additions & 5 deletions
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

Lines changed: 63 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
getting-started:
2+
order: 0

lib/rubydns.rb

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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"

0 commit comments

Comments
 (0)