examples/geoip-dns.rb in rubydns-0.9.1 vs examples/geoip-dns.rb in rubydns-0.9.2
- old
+ new
@@ -56,10 +56,12 @@
Name = Resolv::DNS::Name
IN = Resolv::DNS::Resource::IN
def startup
RubyDNS.run_server(listen: INTERFACES) do
+ fallback_resolver_supervisor =
+ RubyDNS::Resolver.supervise(RubyDNS::System.nameservers)
match(//, IN::A) do |transaction|
logger.debug 'In block'
# The IP Address of the peer is stored in the transaction options
# with the key :peer
@@ -80,16 +82,12 @@
end
# Default DNS handler
otherwise do |transaction|
logger.debug 'In otherwise'
- transaction.passthrough!(GeoIPDNS.fallback_resolver)
+ transaction.passthrough!(fallback_resolver_supervisor.actors.first)
end
end
- end
-
- def self.fallback_resolver
- @resolver ||= RubyDNS::Resolver.new(RubyDNS::System.nameservers)
end
# Maps each continent code to a fixed IP address for the response.
# A simple mapper to demonstrate the behavior.
def self.answer_for_continent_code(code)