From c7981f3c0d378502335a4936c3a65873df2afd69 Mon Sep 17 00:00:00 2001 From: soh_cah_toa Date: Tue, 7 May 2013 22:40:26 -0400 Subject: [PATCH] Demoted UPSTREAM from constant to local variable. Minimizes scope. --- extensions/dns/dns.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/extensions/dns/dns.rb b/extensions/dns/dns.rb index c13270b7d..78b2983f2 100644 --- a/extensions/dns/dns.rb +++ b/extensions/dns/dns.rb @@ -11,20 +11,15 @@ module DNS include Singleton - UPSTREAM = RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]) - - #def initialize(address, port) - #@address = address - #@port = port - - #EventMachine::next_tick { run_server } - #end + #UPSTREAM = RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]) def run_server(address, port) EventMachine::next_tick do RubyDNS::run_server(:listen => [[:udp, address, port]]) do + upstream = RubyDNS::Resolver.new([[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]) + otherwise do |transaction| - transaction.passthrough!(UPSTREAM) + transaction.passthrough!(upstream) end end end