diff --git a/extensions/dns/api.rb b/extensions/dns/api.rb index ca0accd456..60c9d3927e 100644 --- a/extensions/dns/api.rb +++ b/extensions/dns/api.rb @@ -49,7 +49,7 @@ def self.pre_http_start(http_hook_server) end end - Thread.new { EventMachine.next_tick { dns.run(:upstream => servers, :listen => interfaces) } } + dns.run(:upstream => servers, :listen => interfaces) print_info "DNS Server: #{address}:#{port} (#{protocol})" print_more upstream_servers diff --git a/extensions/dns/dns.rb b/extensions/dns/dns.rb index e01271cdde..177414c5db 100644 --- a/extensions/dns/dns.rb +++ b/extensions/dns/dns.rb @@ -113,15 +113,19 @@ def remove_ruleset! # @option options [Array] :listen local interfaces to listen on def run(options = {}) @lock.synchronize do - upstream = options[:upstream] - listen = options[:listen] + Thread.new do + EventMachine.next_tick do + upstream = options[:upstream] || nil + listen = options[:listen] || nil + + if upstream + resolver = RubyDNS::Resolver.new(upstream) + @otherwise = Proc.new { |t| t.passthrough!(resolver) } + end - unless upstream.nil? || upstream.empty? - resolver = RubyDNS::Resolver.new(upstream) - @otherwise = Proc.new { |t| t.passthrough!(resolver) } + super(:listen => listen) + end end - - super(:listen => listen) end end