Sha256: bf7f129b2dd3b31418d0f96b0d93e98f0e44966e6d57eee5c6e39d7d373bb190

Contents?: true

Size: 437 Bytes

Versions: 2

Compression:

Stored size: 437 Bytes

Contents

# frozen_string_literal: true

module RogueOne
  class Ping
    attr_reader :resolver

    def initialize(nameserver)
      @resolver = Resolver.new(nameserver: nameserver)
    end

    def pong?
      result = resolver.dig("example.com", "A")
      raise Error, "DNS resolve error: there is no resopnse from #{resolver.nameserver}" unless result

      true
    end

    def self.pong?(target)
      new(target).pong?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rogue_one-0.2.0 lib/rogue_one/ping.rb
rogue_one-0.1.4 lib/rogue_one/ping.rb