Sha256: 58c9c084b36d6cc06c20c8326276a9cab3782f17e35bb0a1892f0fe8752c2e17

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require 'dns_mock'
require 'json'

TEST_DNS_RECORDS = {
  # Malicious
  '149.210.164.47' => {
    ptr: %w[malicious.spam.co]
  },

  # Ahrefs
  'ip-54-36-148-0.a.ahrefs.com' => {
    a: %w[54.36.148.0]
  },
  '54.36.148.0' => {
    ptr: %w[ip-54-36-148-0.a.ahrefs.com]
  },

  # Alexa
  '52.86.176.3' => {
    ptr: %w[crawl-52-86-176-3.alexa.com]
  },

  # Amazon
  'crawler-54-166-7-90.amazonadbot.com' => {
    a: %w[54.166.7.90]
  },
  '54.166.7.90' => {
    ptr: %w[crawler-54-166-7-90.amazonadbot.com]
  },

  # Apple
  '17-58-98-60.applebot.apple.com' => {
    a: %w[17.58.98.60]
  },
  '17.58.98.60' => {
    ptr: %w[17-58-98-60.applebot.apple.com]
  },

  # Google
  'crawl-66-249-64-141.googlebot.com' => {
    a: %w[66.249.64.141]
  },
  '66.249.64.141' => {
    ptr: %w[crawl-66-249-64-141.googlebot.com]
  },

  # Petalbot
  'petalbot-114-119-134-10.petalsearch.com' => {
    a: %w[114.119.134.10]
  },
  '114.119.134.10' => {
    ptr: %w[petalbot-114-119-134-10.petalsearch.com]
  },

  # Pinterest
  'crawl-54-236-1-11.pinterest.com' => {
    a: %w[54.236.1.11]
  },
  '54.236.1.11' => {
    ptr: %w[crawl-54-236-1-11.pinterest.com]
  }
}.freeze

class DnsServer
  class << self
    attr_accessor :mock
  end

  @mock = DnsMock.start_server records: TEST_DNS_RECORDS
end

module DnsServerMock
  def before_all
    super

    Legitbot.resolver_config = {
      nameserver: 'localhost',
      nameserver_port: [['localhost', DnsServer.mock.port]]
    }
  end

  def after_all
    Legitbot.resolver_config = nil

    super
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
legitbot-1.10.6 test/lib/dns_server_mock.rb
legitbot-1.10.5 test/lib/dns_server_mock.rb
legitbot-1.10.4 test/lib/dns_server_mock.rb
legitbot-1.10.3 test/lib/dns_server_mock.rb
legitbot-1.10.1 test/lib/dns_server_mock.rb
legitbot-1.10.0 test/lib/dns_server_mock.rb
legitbot-1.9.4 test/lib/dns_server_mock.rb
legitbot-1.9.3 test/lib/dns_server_mock.rb
legitbot-1.9.2 test/lib/dns_server_mock.rb
legitbot-1.9.1 test/lib/dns_server_mock.rb
legitbot-1.9.0 test/lib/dns_server_mock.rb
legitbot-1.8.0 test/lib/dns_server_mock.rb
legitbot-1.7.3 test/lib/dns_server_mock.rb
legitbot-1.7.2 test/lib/dns_server_mock.rb
legitbot-1.7.1 test/lib/dns_server_mock.rb
legitbot-1.7.0 test/lib/dns_server_mock.rb
legitbot-1.6.1 test/lib/dns_server_mock.rb
legitbot-1.6.0 test/lib/dns_server_mock.rb