Sha256: 88d09908181dbc5c66c67e6293767141ba287fa00a2fb716fc723843a1654537

Contents?: true

Size: 779 Bytes

Versions: 5

Compression:

Stored size: 779 Bytes

Contents

require "logger"

module Invoker

  module Power

    class DNS
      IN = Resolv::DNS::Resource::IN
      def self.server_ports
        [
          [:udp, '127.0.0.1', Invoker::CONFIG.dns_port],
          [:tcp, '127.0.0.1', Invoker::CONFIG.dns_port]
        ]
      end

      def self.run_dns
        RubyDNS::run_server(:listen => server_ports) do
          on(:start) do
            @logger.level = ::Logger::WARN
          end

          # For this exact address record, return an IP address
          match(/.*\.dev/, IN::A) do |transaction|
            transaction.respond!("127.0.0.1")
          end

          # Default DNS handler
          otherwise do |transaction|
            transaction.failure!(:NXDomain)
          end
        end
      end

    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
invoker-1.0.4 lib/invoker/power/dns.rb
invoker-1.0.3 lib/invoker/power/dns.rb
invoker-1.0.2 lib/invoker/power/dns.rb
invoker-1.0.1 lib/invoker/power/dns.rb
invoker-1.0.0 lib/invoker/power/dns.rb