Skip to content

Commit 2e55c84

Browse files
committed
Endpoints is now first argument of server class.
1 parent a7b5cd0 commit 2e55c84

15 files changed

+22
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ IN = Resolv::DNS::Resource::IN
4747
UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
4848

4949
# Start the RubyDNS server
50-
RubyDNS::run_server(:listen => INTERFACES) do
50+
RubyDNS::run_server(INTERFACES) do
5151
match(%r{test.local}, IN::A) do |transaction|
5252
transaction.respond!("10.0.0.80")
5353
end

examples/basic-dns.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
1313

1414
# Start the RubyDNS server
15-
RubyDNS::run_server(:listen => INTERFACES) do
15+
RubyDNS::run_server(INTERFACES) do
1616
match(%r{test.local}, IN::A) do |transaction|
1717
transaction.respond!("10.0.0.80")
1818
end

examples/cname.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
UPSTREAM = RubyDNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])
1515

16-
RubyDNS::run_server(:listen => INTERFACES) do
16+
RubyDNS::run_server(INTERFACES) do
1717
# How to respond to something other than what was requested.
1818
match(//, IN::A) do |transaction|
1919
transaction.respond!(Name.create('foo.bar'), resource_class: IN::CNAME)

examples/flakey-dns.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FlakeyDNS < Process::Daemon
3838
IN = Resolv::DNS::Resource::IN
3939

4040
def startup
41-
RubyDNS.run_server(listen: INTERFACES) do
41+
RubyDNS.run_server(INTERFACES) do
4242
# Use a Celluloid supervisor so the system recovers if the actor dies
4343
fallback_resolver_supervisor =
4444
RubyDNS::Resolver.supervise(RubyDNS::System.nameservers)

examples/geoip-dns.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GeoIPDNS < Process::Daemon
5757
IN = Resolv::DNS::Resource::IN
5858

5959
def startup
60-
RubyDNS.run_server(listen: INTERFACES) do
60+
RubyDNS.run_server(INTERFACES) do
6161
fallback_resolver_supervisor = RubyDNS::Resolver.supervise(RubyDNS::System.nameservers)
6262

6363
match(//, IN::A) do |transaction|

examples/simple.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
UPSTREAM = RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]])
1414

1515
# Start the RubyDNS server
16-
RubyDNS.run_server(listen: INTERFACES) do
16+
RubyDNS.run_server(INTERFACES) do
1717
match(/test.mydomain.org/, IN::A) do |transaction|
1818
transaction.respond!('10.0.0.80')
1919
end

examples/soa-dns.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Name = Resolv::DNS::Name
2828
IN = Resolv::DNS::Resource::IN
2929

30-
RubyDNS.run_server(listen: [[:udp, '0.0.0.0', 5400]]) do
30+
RubyDNS.run_server([[:udp, '0.0.0.0', 5400]]) do
3131
# SOA Record
3232
# dig @localhost -p 5400 SOA mydomain.org
3333
match('mydomain.org', IN::SOA) do |transaction|

examples/test-dns-1.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# [:tcp, '::0', 5300],
3838
]
3939

40-
RubyDNS.run_server(listen: INTERFACES) do
40+
RubyDNS.run_server(INTERFACES) do
4141
# % dig +nocmd +noall +answer @localhost ANY dev.mydomain.org
4242
# dev.mydomain.org. 16000 IN A 10.0.0.80
4343
# dev.mydomain.org. 16000 IN MX 10 mail.mydomain.org.

examples/test-dns-2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def startup
6161
$stderr.sync = true
6262

6363
# Start the RubyDNS server
64-
RubyDNS.run_server(listen: INTERFACES) do
64+
RubyDNS.run_server(INTERFACES) do
6565
on(:start) do
6666
RExec.change_user(RUN_AS)
6767
end

lib/rubydns.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ module RubyDNS
2828
Resolver = Async::DNS::Resolver
2929

3030
# Run a server with the given rules.
31-
def self.run_server (server_class: RuleBasedServer, **options, &block)
32-
server = server_class.new(**options, &block)
31+
def self.run_server (*args, server_class: RuleBasedServer, **options, &block)
32+
if listen = options.delete(:listen)
33+
warn "Using `listen:` option is deprecated, please pass as the first argument."
34+
args.unshift(listen)
35+
end
36+
37+
server = server_class.new(*args, **options, &block)
3338

3439
server.run
3540
end

0 commit comments

Comments
 (0)