rogue_one 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50bc52be2dec2e0e5c7daf51af82117041d99a1925dc6709ee45c9bfe14feac1
4
- data.tar.gz: 0f08a6005109c20fe4e48b8fbff97375813d4eff7f75259648e8b74614ce1b99
3
+ metadata.gz: a8a159994892e276c84f9854aea0d1bb1ed915da4d1441e362cd3df81967a029
4
+ data.tar.gz: aeb889e5a15df10f85822fc78fb285a55f86268f7a6287e34f604698172ad0b0
5
5
  SHA512:
6
- metadata.gz: 40cda8348091166aa7dd06518596f9f2da42673a28563a91515505f76a851ecda89addb9bf3463f7a4b3732bffcbff991913ee0108e304712fcc06351ea57c46
7
- data.tar.gz: 9c0f43f946d9f5559e5711d557466fea2b41adc706dfa8897e693a01b5327e04e3b5470e123e56a69b266a8bdf396dc8eb680429017a139f23775d7ad184db6d
6
+ metadata.gz: 2d49d2e63096010fae8beb77c5b0ff0eadcb83b350663a7f048a5f2402378b65ee99bd91ba83c6659a0cac87250d91c4a377d0c1a1f5e924e74b7aa4af670472
7
+ data.tar.gz: 52f2ea2c904088b2f3c817653427e4d92ca04e1584a11754163a5ade8ee6a5075d4350e5fde3468cb87dc865caadcc6acc3de3edd98005d89dd5386214ed9505
@@ -4,6 +4,7 @@ require "rogue_one/version"
4
4
 
5
5
  require "rogue_one/resolver"
6
6
  require "rogue_one/detector"
7
+ require "rogue_one/ping"
7
8
  require "rogue_one/cli"
8
9
 
9
10
  module RogueOne
@@ -8,6 +8,8 @@ module RogueOne
8
8
  desc "report [DNS_SERVER]", "Show a report of a given DNS server"
9
9
  def report(dns_server)
10
10
  with_error_handling do
11
+ Ping.pong? dns_server
12
+
11
13
  detector = Detector.new(target: dns_server)
12
14
  puts JSON.pretty_generate(detector.report)
13
15
  end
@@ -17,7 +19,8 @@ module RogueOne
17
19
  def with_error_handling
18
20
  yield
19
21
  rescue StandardError => e
20
- puts "Warning: #{e}"
22
+ message = { error: e.to_s }
23
+ puts JSON.pretty_generate(message)
21
24
  end
22
25
  end
23
26
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RogueOne
4
+ class Ping
5
+ attr_reader :resolver
6
+
7
+ def initialize(nameserver)
8
+ @resolver = Resolver.new(nameserver: nameserver)
9
+ end
10
+
11
+ def pong?
12
+ result = resolver.dig("example.com", "A")
13
+ raise Error, "DNS resolve error: there is no resopnse from #{resolver.nameserver}" unless result
14
+
15
+ true
16
+ end
17
+
18
+ def self.pong?(target)
19
+ new(target).pong?
20
+ end
21
+ end
22
+ end
@@ -20,6 +20,8 @@ module RogueOne
20
20
 
21
21
  def _resolver
22
22
  @_resolver ||= Resolv::DNS.new(nameserver: [nameserver])
23
+ @_resolver.timeouts = 5
24
+ @_resolver
23
25
  end
24
26
 
25
27
  def resource_by_type(type)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RogueOne
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rogue_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-03 00:00:00.000000000 Z
11
+ date: 2019-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,6 +116,7 @@ files:
116
116
  - lib/rogue_one/cli.rb
117
117
  - lib/rogue_one/data/top_100.yml
118
118
  - lib/rogue_one/detector.rb
119
+ - lib/rogue_one/ping.rb
119
120
  - lib/rogue_one/resolver.rb
120
121
  - lib/rogue_one/version.rb
121
122
  - rogue_one.gemspec