Sha256: 8745a020c5ecb6f24ed1b78a16e81c7889758f47cf898c074da9e0c9daa1abdc

Contents?: true

Size: 859 Bytes

Versions: 10

Compression:

Stored size: 859 Bytes

Contents

require "logger"
require 'rubydns'

module Invoker
  module Power
    class DNS < RubyDNS::Server
      def self.server_ports
        [
          [:udp, '127.0.0.1', Invoker.config.dns_port],
          [:tcp, '127.0.0.1', Invoker.config.dns_port]
        ]
      end

      def initialize
        @logger = ::Logger.new($stderr)
        @logger.level = ::Logger::FATAL
      end

      def process(name, resource_class, transaction)
        if name_matches?(name) && resource_class_matches?(resource_class)
          transaction.respond!("127.0.0.1")
        else
          transaction.fail!(:NXDomain)
        end
      end

      private

      def resource_class_matches?(resource_class)
        resource_class == Resolv::DNS::Resource::IN::A
      end

      def name_matches?(name)
        name =~ /.*\.#{Invoker.config.tld}/
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
itrg-invoker-1.6.1 lib/invoker/power/dns.rb
itrg-invoker-1.6.0 lib/invoker/power/dns.rb
invoker-1.5.8 lib/invoker/power/dns.rb
invoker-1.5.7 lib/invoker/power/dns.rb
invoker-1.5.6 lib/invoker/power/dns.rb
invoker-1.5.5 lib/invoker/power/dns.rb
invoker-1.5.4 lib/invoker/power/dns.rb
invoker-1.5.3 lib/invoker/power/dns.rb
meepo-1.5.2 lib/invoker/power/dns.rb
invoker-1.5.1 lib/invoker/power/dns.rb