flareon 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 780a8714275b28d2b85a206696431bd385140413dd511136a4246591b9e6b6b1
4
- data.tar.gz: 8291b1380ec0208f07eed5633c582362c86efe6212c7a7cbdbd4b6a9479a2662
3
+ metadata.gz: b970bf527f07452b45e7eeb735be404fb02989c8215d411eb7741bd14f6f575f
4
+ data.tar.gz: ebdda28eec28f8f1240f2e0b544547bc7418ff9a3bef99c6d98d4909133e83e3
5
5
  SHA512:
6
- metadata.gz: a43a377047cd222eca87fbfe8e186e6cdc5e634ffecc8f769ad86ae6e80838f75a866ceab2819c2edf139b8aa092b04f4c1a7f1f76a6c5e5b4d16582fe86e14f
7
- data.tar.gz: c924bf9ade4e696978db40c77067b2ef5c8b18a8cce82d0bd4ba062e18f809a40bfe32d31d08d98fa7916dde1c23ffe5b37d428ae8c0305618dfdd78b2fa783e
6
+ metadata.gz: ab40f5247fad6358e975a964cbb81846be7849708ead9e47003486306b465da35f085b11364df6415cfb7aa92cc65846a9cff32871acf5d18b6fd04115636bfd
7
+ data.tar.gz: 696eec57564396b3c236e8ffda048672b6545f66e3aa01e16515d05c1c3e10aafe8945a871915924984980c0b18a7d39600de905ab9cae1d3ce79f711814f0e2
@@ -1,18 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flareon (1.0.2)
4
+ flareon (1.0.3)
5
+ command_lion (= 2.0.1)
5
6
  httparty (~> 0.16.2)
6
7
  parallel (~> 1.12.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
12
+ coderay (1.1.2)
13
+ command_lion (2.0.1)
11
14
  diff-lcs (1.3)
12
15
  httparty (0.16.2)
13
16
  multi_xml (>= 0.5.2)
17
+ method_source (0.9.0)
14
18
  multi_xml (0.6.0)
15
19
  parallel (1.12.1)
20
+ pry (0.11.3)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.9.0)
16
23
  rake (10.5.0)
17
24
  rspec (3.7.0)
18
25
  rspec-core (~> 3.7.0)
@@ -34,6 +41,7 @@ PLATFORMS
34
41
  DEPENDENCIES
35
42
  bundler (~> 1.16)
36
43
  flareon!
44
+ pry
37
45
  rake (~> 10.0)
38
46
  rspec (~> 3.0)
39
47
 
data/README.md CHANGED
@@ -28,6 +28,20 @@ Flareon.query("google.com")
28
28
  # }
29
29
  ```
30
30
 
31
+ Single-threaded DNS query (IPv6) over HTTPs for multiple domains:
32
+ ```ruby
33
+ domains = ["google.com", "github.com", "microsoft.com", "apple.com"]
34
+
35
+ results = Flareon.batch_query(domains, type: "AAAA")
36
+ ```
37
+
38
+ Multi-threaded DNS query (IPv4) over HTTPs for multiple domains:
39
+ ```ruby
40
+ domains = ["google.com", "github.com", "microsoft.com", "apple.com"]
41
+
42
+ results = Flareon.batch_query_multithreaded(domains, threads: 4)
43
+ ```
44
+
31
45
  Get the raw JSON response:
32
46
  ```ruby
33
47
  json = Flareon.query("google.com", json: true)
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "command_lion"
5
+ require "flareon"
6
+ require "yaml"
7
+
8
+ CommandLion::App.run do
9
+ name "flareon"
10
+ version Flareon::VERSION
11
+ description "A cloudflare DNS over HTTPs resolver command-line client."
12
+
13
+ command :query do
14
+ description "Query cloudflare's DNS over HTTPs resolver for the given domain(s)."
15
+ type :strings
16
+ action do
17
+ threads = options[:threads].argument
18
+ type = options[:type].argument
19
+ json = options[:json].given? ? true : false
20
+ stream = options[:stream].given? ? true : false
21
+
22
+ if stream
23
+ Flareon.batch_query_multithreaded(arguments, type: type, threads: threads) do |result|
24
+ if json
25
+ puts result.to_json
26
+ else
27
+ puts result.to_yaml
28
+ end
29
+ end
30
+ else
31
+ if json
32
+ puts Flareon.batch_query_multithreaded(arguments, type: type, threads: threads).to_json
33
+ else
34
+ puts Flareon.batch_query_multithreaded(arguments, type: type, threads: threads).to_yaml
35
+ end
36
+ end
37
+ end
38
+
39
+ option :type do
40
+ description "specify the type of record to query for (A, AAAA, MX, ect)"
41
+ flag "--type"
42
+ type :string
43
+ default "A"
44
+ end
45
+
46
+ option :threads do
47
+ description "specify the number of threads to use"
48
+ flag "--threads"
49
+ type :integer
50
+ default 1
51
+ end
52
+
53
+ option :json do
54
+ description "use json output instead of YAML"
55
+ flag "--json"
56
+ end
57
+
58
+ option :stream do
59
+ description "stream results to STDOUT as they are available"
60
+ flag "--stream"
61
+ end
62
+ end
63
+
64
+ command :resolve do
65
+ description "Resolve a given domain to an IPv4 ( or IPv6 ) address."
66
+ type :strings
67
+
68
+ action do
69
+ type = options[:ipv6].given? ? "AAAA" : "A"
70
+ all = options[:all].given? ? true : false
71
+ json = options[:json].given? ? true : false
72
+ stream = options[:stream].given? ? true : false
73
+
74
+ if stream
75
+ arguments.each do |argument|
76
+ result = {}
77
+ result[argument] = Flareon.resolve(argument, type: type)
78
+ if json
79
+ puts result.to_json
80
+ else
81
+ puts result.to_yaml
82
+ end
83
+ end
84
+ else
85
+ results = {}
86
+ arguments.each do |argument|
87
+ results[argument] = Flareon.resolve(argument, type: type)
88
+ end
89
+ if json
90
+ puts results.to_json
91
+ else
92
+ puts results.to_yaml
93
+ end
94
+ end
95
+ end
96
+
97
+ option :ipv6 do
98
+ description "specify only ipv6"
99
+ flag "--ipv6"
100
+ end
101
+
102
+ option :all do
103
+ description "resolve all possible IP addresses (both ipv4 and ipv6)"
104
+ flag "--all"
105
+ end
106
+
107
+ option :json do
108
+ description "use json output instead of YAML"
109
+ flag "--json"
110
+ end
111
+
112
+ option :stream do
113
+ description "stream results to STDOUT as they are available"
114
+ flag "--stream"
115
+ end
116
+ end
117
+ end
@@ -23,8 +23,10 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'httparty', "~> 0.16.2"
25
25
  spec.add_dependency 'parallel', "~> 1.12.1"
26
+ spec.add_dependency 'command_lion', "2.0.1"
26
27
 
27
28
  spec.add_development_dependency "bundler", "~> 1.16"
28
29
  spec.add_development_dependency "rake", "~> 10.0"
29
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency "pry"
30
32
  end
@@ -8,7 +8,7 @@ module Flareon
8
8
  # Special *ct* value to add to every query.
9
9
  CT = "application/dns-json".freeze
10
10
  # Header sent in every query.
11
- HEADER = {'Content-Type': 'application/json'}
11
+ HEADER = { "Content-Type": "application/json" }.freeze
12
12
 
13
13
  # Query the DNS over HTTPs endpoint.
14
14
  #
@@ -73,6 +73,7 @@ module Flareon
73
73
  end
74
74
  resp = Flareon.query(name, type: type)
75
75
  if resp["Status"] == 0
76
+ return nil unless resp.has_key? "Answer"
76
77
  return resp["Answer"][0]["data"]
77
78
  else
78
79
  raise resp
@@ -1,3 +1,3 @@
1
1
  module Flareon
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flareon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent 'picat' Gruber
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2018-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.12.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: command_lion
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description:
84
112
  email:
85
113
  - kgruber1@emich.edu
@@ -96,8 +124,7 @@ files:
96
124
  - LICENSE.txt
97
125
  - README.md
98
126
  - Rakefile
99
- - bin/console
100
- - bin/setup
127
+ - bin/flareon
101
128
  - examples/debug.rb
102
129
  - flareon.gemspec
103
130
  - flareon.png
@@ -123,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
150
  version: '0'
124
151
  requirements: []
125
152
  rubyforge_project:
126
- rubygems_version: 2.7.3
153
+ rubygems_version: 2.7.6
127
154
  signing_key:
128
155
  specification_version: 4
129
156
  summary: A cloudflare DNS resolver client library.
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "flareon"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here