Sha256: c0496392a9cac97786787ee47ee295dd498582c98f09d5559c5698e8470699f7

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 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.get_resource("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.4.0 lib/rogue_one/ping.rb
rogue_one-0.3.0 lib/rogue_one/ping.rb