Sha256: 00d27766c9a558cc79c78387f4f2022a5712a931be99e34a976e916d0222de89

Contents?: true

Size: 1.07 KB

Versions: 43

Compression:

Stored size: 1.07 KB

Contents

require 'middleman-core/dns_resolver/basic_network_resolver'

module Middleman
  class DnsResolver
    # Use network name server to resolve ips and names
    class NetworkResolver < BasicNetworkResolver
      def initialize(opts={})
        super

        @resolver = opts.fetch(:resolver, Resolv::DNS.new(nameserver_config))
        self.timeouts = timeouts
      end

      private

      # Hosts + Ports for MDNS resolver
      #
      # This looks for MM_MDNSRC in your environment. If you are going to use
      # IPv6-addresses: Make sure you do not forget to add the port at the end.
      #
      # MM_MDNSRC=ip:port ip:port
      #
      # @return [Hash]
      #   Returns the configuration for the nameserver
      #
      # @example
      #   export MM_MDNSRC="224.0.0.251:5353 ff02::fb:5353"
      #
      def nameserver_config
        return unless ENV.key?('MM_DNSRC') && ENV['MM_DNSRC']

        address, port = ENV['MM_DNSRC'].split(/:/)

        {
          nameserver_port: [[address, port.to_i]]
        }
      rescue StandardError
        {}
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 3 rubygems

Version Path
middleman-core-4.5.1 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.5.0 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.4.3 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.4.2 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.4.0 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.11 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.10 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.8 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.7 lib/middleman-core/dns_resolver/network_resolver.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.6 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.5 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.4 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.3 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.2 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.1 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.0 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-with-external-sources-watch-fix-4.1.10 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-with-external-sources-watch-fix-4.1.0 lib/middleman-core/dns_resolver/network_resolver.rb
middleman-core-4.3.0.rc.1 lib/middleman-core/dns_resolver/network_resolver.rb