dnslookup 0.1.5 → 0.1.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 +5 -5
- data/bin/dnslookup +1 -1
- data/lib/dnslookup.rb +66 -77
- metadata +17 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c301630601684995c07ec014d4b8dfc49658edf92db6caf229ba2416594453b
|
4
|
+
data.tar.gz: bccdd6cdc2a557b6522fbef733db9ef3edf7479379ec3a03f2d34180d06f3cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55544a968ccf829c4dde08063ad6d064031ad847323aa3ff52d3032d3df72266f37894e7c015bdc21ddc3a94d804c19d22b1b8a9e6650df7f7cafe3d1e4336f3
|
7
|
+
data.tar.gz: c94879c89baf2ac1f94ff36ebeb4ca174cf434a1765c5132a053995ff589994c042f2b2eacce629d500bba477d482c5c1e512aa029ab9f81dbdc29e138bc925e
|
data/bin/dnslookup
CHANGED
data/lib/dnslookup.rb
CHANGED
@@ -1,90 +1,79 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# DNSLookup is the main class.
|
4
|
-
class DNSLookup
|
5
|
-
|
6
|
-
# Initializes the core variables and calls the driver methods.
|
7
|
-
def initialize
|
8
|
-
@type = ''
|
9
|
-
|
10
|
-
parse_options
|
11
|
-
@domain = ARGV.shift
|
12
|
-
|
13
|
-
setup_query_servers
|
14
|
-
query_with_options
|
15
|
-
end
|
16
|
-
|
17
|
-
# Parses the options passed from command prompt.
|
18
|
-
def parse_options
|
19
|
-
OptionParser.new do |opt|
|
20
|
-
opt.banner = "Usage: dnslookup <domain name> [options]"
|
1
|
+
#frozen_string_literal: true
|
21
2
|
|
22
|
-
|
23
|
-
@type = 'mx'
|
24
|
-
end
|
25
|
-
|
26
|
-
opt.on("-a", "--aname", "Return A name records") do |v|
|
27
|
-
@type = 'a'
|
28
|
-
end
|
29
|
-
|
30
|
-
opt.on("-c", "--cname", "Return C name records") do |v|
|
31
|
-
@type = 'c'
|
32
|
-
end
|
3
|
+
require 'optparse'
|
33
4
|
|
34
|
-
|
35
|
-
|
36
|
-
|
5
|
+
# DNSLookup gem namespace.
|
6
|
+
module DNSLookup
|
7
|
+
# DNSLookup::Query class is the main.
|
8
|
+
class Query
|
9
|
+
|
10
|
+
# Initializes the core variables and calls the driver methods.
|
11
|
+
def initialize
|
12
|
+
@type = ''
|
13
|
+
|
14
|
+
# Parses the options passed from command prompt.
|
15
|
+
OptionParser.new do |opt|
|
16
|
+
opt.banner = "Usage: dnslookup <domain name> [options]"
|
17
|
+
opt.on("-m", "--mx", "Return MX records") { @type = 'mx' }
|
18
|
+
opt.on("-a", "--aname", "Return A name records") { @type = 'a' }
|
19
|
+
opt.on("-c", "--cname", "Return C name records") { @type = 'c' }
|
20
|
+
opt.on("-t", "--txt", "Return TXT records") { @type = 'txt' }
|
21
|
+
opt.on("-s", "--server=SERVER", "Specify specific name server to query") do |v|
|
22
|
+
@single_server = v
|
23
|
+
end
|
24
|
+
opt.on("-h", "--help", "Prints this help") do
|
25
|
+
puts opt
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
end.parse!
|
29
|
+
|
30
|
+
# Get domain from command line arguments.
|
31
|
+
@domain = ARGV.shift
|
32
|
+
|
33
|
+
setup_query_servers
|
34
|
+
query_with_options
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
# Sets up the DNS servers to query.
|
38
|
+
def setup_query_servers
|
39
|
+
@servers = []
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
if @single_server
|
42
|
+
@servers << @single_server
|
43
|
+
else
|
44
|
+
@servers = ['8.8.8.8', '8.8.4.4']
|
45
45
|
end
|
46
|
-
end.parse!
|
47
|
-
end
|
48
|
-
|
49
|
-
# Sets up the DNS servers to query.
|
50
|
-
def setup_query_servers
|
51
|
-
@servers = []
|
52
|
-
|
53
|
-
if @single_server
|
54
|
-
@servers << @single_server
|
55
|
-
else
|
56
|
-
@servers = ['8.8.8.8', '8.8.4.4']
|
57
46
|
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Query name servers for specific records or entire zone if @type is blank or unknown.
|
61
|
-
def query_with_options
|
62
|
-
case @type
|
63
|
-
when 'mx'
|
64
|
-
query_command('mx')
|
65
|
-
when 'a'
|
66
|
-
query_command('a')
|
67
|
-
when 'c'
|
68
|
-
query_command('c')
|
69
|
-
when 'txt'
|
70
|
-
query_command('txt')
|
71
|
-
else
|
72
|
-
query_command('any')
|
73
|
-
end
|
74
|
-
end
|
75
47
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
48
|
+
# Query name servers for specific records or entire zone if @type is blank or unknown.
|
49
|
+
def query_with_options
|
50
|
+
case @type
|
51
|
+
when 'mx'
|
52
|
+
query_command('mx')
|
53
|
+
when 'a'
|
54
|
+
query_command('a')
|
55
|
+
when 'c'
|
56
|
+
query_command('c')
|
57
|
+
when 'txt'
|
58
|
+
query_command('txt')
|
81
59
|
else
|
82
|
-
|
60
|
+
query_command('any')
|
83
61
|
end
|
62
|
+
end
|
84
63
|
|
85
|
-
|
86
|
-
|
87
|
-
|
64
|
+
# Query command to execute.
|
65
|
+
def query_command(type)
|
66
|
+
@servers.each do |server|
|
67
|
+
if type == 'any'
|
68
|
+
check = `dig @#{server} #{type} #{@domain}`
|
69
|
+
else
|
70
|
+
check = `dig @#{server} #{@domain} #{type} +short`
|
71
|
+
end
|
72
|
+
|
73
|
+
puts "Checking servers: #{server}"
|
74
|
+
puts check
|
75
|
+
puts
|
76
|
+
end
|
88
77
|
end
|
89
78
|
end
|
90
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnslookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor S. Keenan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: dnslookup is a DNS record query CLI gem written in Ruby. dnslookup automatically
|
14
14
|
queries multiple public DNS servers or allows you to query a specific DNS server.
|
@@ -20,28 +20,33 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- bin/dnslookup
|
22
22
|
- lib/dnslookup.rb
|
23
|
-
homepage:
|
23
|
+
homepage: https://www.victorkeenan.com/projects/dnslookup/
|
24
24
|
licenses:
|
25
25
|
- MIT
|
26
|
-
metadata:
|
27
|
-
|
26
|
+
metadata:
|
27
|
+
bug_tracker_uri: https://github.com/VictorSK/dnslookup/issues/
|
28
|
+
changelog_uri: https://github.com/VictorSK/dnslookup/blob/main/CHANGELOG.md
|
29
|
+
documentation_uri: https://github.com/VictorSK/dnslookup/blob/main/README.md
|
30
|
+
homepage_uri: https://www.victorkeenan.com/projects/dnslookup/
|
31
|
+
source_code_uri: https://github.com/VictorSK/dnslookup/
|
32
|
+
rubygems_mfa_required: 'true'
|
33
|
+
post_install_message:
|
28
34
|
rdoc_options: []
|
29
35
|
require_paths:
|
30
36
|
- lib
|
31
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
|
-
- - "
|
39
|
+
- - ">="
|
34
40
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
41
|
+
version: '3.0'
|
36
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: '0'
|
41
47
|
requirements: []
|
42
|
-
|
43
|
-
|
44
|
-
signing_key:
|
48
|
+
rubygems_version: 3.5.5
|
49
|
+
signing_key:
|
45
50
|
specification_version: 4
|
46
|
-
summary:
|
51
|
+
summary: DNS record query CLI gem written in Ruby.
|
47
52
|
test_files: []
|