globetrotter 0.0.5 → 0.0.6
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 +4 -4
- data/bin/globetrotter +44 -43
- data/globetrotter.gemspec +1 -1
- data/lib/globetrotter.rb +9 -9
- data/lib/globetrotter/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b888a19dab6e39a83cc3c9dfd9314712c02ae8bf
|
4
|
+
data.tar.gz: bbf71fe7a2b929f648fef841779212f45f6f48f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c74d82d195af4ff99ce60a595e1762168e40c26779d6f139792ed0e8f058279ec0815c28a55b6ae66e949d843589e3e0e2226ec0b3da6a223f339663d4a5d6
|
7
|
+
data.tar.gz: b4d66382e11f283a85722f7b81fe472a9e12873f0d85a9c6cd3232cecb84af62d1231dcfb00d38bc13e042cdd7827987d8ce6bcb120721fb255f0697d1c1482b
|
data/bin/globetrotter
CHANGED
@@ -2,51 +2,52 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), %w{.. lib})
|
4
4
|
require 'globetrotter'
|
5
|
-
require '
|
5
|
+
require 'optparse'
|
6
|
+
require 'ostruct'
|
7
|
+
require 'dnsruby'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
type: Integer,
|
16
|
-
default: 60,
|
17
|
-
short: '-a'
|
18
|
-
opt :query,
|
19
|
-
'Hostname to lookup',
|
20
|
-
type: String,
|
21
|
-
default: 'googleapis.com'
|
22
|
-
opt :timeout_seconds,
|
23
|
-
'Seconds to wait before queries timeout',
|
24
|
-
type: Integer,
|
25
|
-
default: 2,
|
26
|
-
short: '-t'
|
27
|
-
opt :concurrency,
|
28
|
-
'Number of concurrent DNS requests to make',
|
29
|
-
type: Integer,
|
30
|
-
default: 10,
|
31
|
-
short: '-p'
|
32
|
-
end
|
9
|
+
class GlobetrotterOptions
|
10
|
+
def self.parse(args)
|
11
|
+
options = OpenStruct.new
|
12
|
+
options.domain = 'googleapis.com'
|
13
|
+
options.ns_count_to_check = 100
|
14
|
+
options.ns_max_age_minutes = 60
|
15
|
+
options.timeout_seconds = 2
|
16
|
+
options.ns_query_concurrency = 10
|
33
17
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
18
|
+
opt_parser = OptionParser.new do |opts|
|
19
|
+
opts.banner = 'Usage: globetrotter [options] example.org'
|
20
|
+
opts.on('-q googleapis.com', String, 'Domain to look up') do |o|
|
21
|
+
options.domain = o
|
22
|
+
end
|
23
|
+
opts.on('-n 100', Integer, 'Query N name servers') do |o|
|
24
|
+
options.ns_count_to_check = o
|
25
|
+
end
|
26
|
+
opts.on('-t 2', Integer, 'Wait T seconds per request') do |o|
|
27
|
+
options.timeout_seconds = o
|
28
|
+
end
|
29
|
+
opts.on('-p 10', Integer, 'Query P name servers in parallel') do |o|
|
30
|
+
options.ns_query_concurrency = o
|
31
|
+
end
|
32
|
+
opts.on('-a 60', Integer, 'Use name servers checked less than A minutes ago') do |o|
|
33
|
+
options.ns_max_age_minutes = o
|
34
|
+
end
|
35
|
+
opts.on_tail('-h', '--help', 'Display CLI help (this output)') do |o|
|
36
|
+
puts opts.help
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
opts.on_tail('-v', '--version', 'Display Globetrotter version') do |o|
|
40
|
+
puts "Globetrotter #{Globetrotter::VERSION}"
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
end # opt_parser
|
39
44
|
|
40
|
-
|
41
|
-
Trollop.die :ns_max_age_minutes, 'must be positive' if ns_max_age_minutes < 0
|
42
|
-
Trollop.die :timeout_seconds, 'must be positive' if ns_max_age_minutes < 0
|
43
|
-
Trollop.die :concurrency, 'must be positive' if ns_max_age_minutes < 0
|
45
|
+
opt_parser.parse!(args)
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
)
|
47
|
+
options
|
48
|
+
end # parse()
|
49
|
+
end # class Globetrotter Options
|
50
|
+
|
51
|
+
options = GlobetrotterOptions.parse(ARGV)
|
52
|
+
gt = Globetrotter.new(options)
|
52
53
|
gt.run
|
data/globetrotter.gemspec
CHANGED
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
|
24
24
|
spec.add_runtime_dependency 'rubydns', '~> 0.8'
|
25
|
-
spec.add_runtime_dependency '
|
25
|
+
spec.add_runtime_dependency 'dnsruby', '~> 1.54'
|
26
26
|
spec.add_runtime_dependency 'wrest', '~> 1.5'
|
27
27
|
end
|
data/lib/globetrotter.rb
CHANGED
@@ -8,12 +8,12 @@ require 'set'
|
|
8
8
|
require 'ipaddr'
|
9
9
|
|
10
10
|
class Globetrotter
|
11
|
-
def initialize(options
|
12
|
-
@ns_max_age_minutes = options.
|
13
|
-
@ns_count_to_check = options.
|
14
|
-
@timeout_seconds = options.
|
15
|
-
@query = options.
|
16
|
-
@concurrency = options.
|
11
|
+
def initialize(options)
|
12
|
+
@ns_max_age_minutes = options.ns_max_age_minutes
|
13
|
+
@ns_count_to_check = options.ns_count_to_check
|
14
|
+
@timeout_seconds = options.timeout_seconds
|
15
|
+
@query = options.domain
|
16
|
+
@concurrency = options.ns_query_concurrency
|
17
17
|
@ns_ips = fetch_ns_ips
|
18
18
|
end
|
19
19
|
|
@@ -62,7 +62,7 @@ class Globetrotter
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def self.run(options
|
65
|
+
def self.run(options)
|
66
66
|
new(options).run
|
67
67
|
end
|
68
68
|
|
@@ -72,10 +72,10 @@ class Globetrotter
|
|
72
72
|
|
73
73
|
def fetch_ns_ips
|
74
74
|
Wrest.logger = Logger.new(STDERR)
|
75
|
-
uri =
|
75
|
+
uri = "http://public-dns.tk/nameservers.json".to_uri
|
76
76
|
nameservers = uri.get.deserialise.map { |data| Nameserver.new(data) }
|
77
77
|
nameservers.select do |ns|
|
78
|
-
ns.valid? && ns.ipv4? && ns.age_minutes <= ns_max_age_minutes
|
78
|
+
ns.valid? && ns.ipv4? && (ns.age_minutes <= @ns_max_age_minutes)
|
79
79
|
end.map(&:ip)
|
80
80
|
end
|
81
81
|
|
data/lib/globetrotter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globetrotter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Lopez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: dnsruby
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.54'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '1.54'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: wrest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|