dnslookup 0.1.6 → 0.3.0
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/lib/dnslookup/version.rb +5 -0
- data/lib/dnslookup.rb +43 -40
- metadata +13 -16
- data/bin/dnslookup +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0d06c69c8b59a03c0364decfbc5c00074d8e82c5afff6c7545d0197d644be2b
|
4
|
+
data.tar.gz: 48d9dada4cdeb4942575d84ebe08479604696441023cf89da16c3f4ffaadf6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59fe0315a56859625de4c1b478c9ffee7196b00fc85e41e7880c36f55ce6ef780c086959cab958a92b275996443198463656d331ea58d1a128d607d4ce3b8ad4
|
7
|
+
data.tar.gz: d8c44bc8ffea2304b420bbefe0a62e35daf947a0ca5065b80f33f759754456d1d32f49031e3b5800828dc550a981c4df71f45f6e7618c4b7070c92441b6fd72c
|
data/lib/dnslookup.rb
CHANGED
@@ -1,78 +1,81 @@
|
|
1
|
-
#frozen_string_literal: true
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "dnslookup/version"
|
3
4
|
require 'optparse'
|
4
5
|
|
5
|
-
# DNSLookup gem namespace.
|
6
6
|
module DNSLookup
|
7
|
-
|
7
|
+
class Error < StandardError; end
|
8
8
|
class Query
|
9
|
+
DEFAULT_SERVERS = ['8.8.8.8', '8.8.4.4'].freeze
|
9
10
|
|
10
|
-
# Initializes the core variables and calls the driver methods.
|
11
11
|
def initialize
|
12
|
-
@type =
|
12
|
+
@type = []
|
13
|
+
@single_server = nil
|
14
|
+
@domain = ARGV.shift
|
15
|
+
|
16
|
+
if @domain.nil? || @domain.start_with?('-')
|
17
|
+
puts "Error: You must specify a domain name.\n\n"
|
18
|
+
puts "Usage: dnslookup <domain name> [options]"
|
19
|
+
exit 1
|
20
|
+
end
|
13
21
|
|
14
|
-
|
22
|
+
parse_options
|
23
|
+
setup_query_servers
|
24
|
+
query_with_options
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_options
|
15
28
|
OptionParser.new do |opt|
|
16
|
-
opt.banner =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
opt.on("-
|
29
|
+
opt.banner = <<~BANNER
|
30
|
+
Usage: dnslookup <domain name> [options]
|
31
|
+
Example: dnslookup example.com -a -m -s8.8.8.8
|
32
|
+
BANNER
|
33
|
+
opt.on("-m", "--mx", "Return MX records") { @type << 'mx' }
|
34
|
+
opt.on("-a", "--aname", "Return A name records") { @type << 'a' }
|
35
|
+
opt.on("-c", "--cname", "Return C name records") { @type << 'c' }
|
36
|
+
opt.on("-t", "--txt", "Return TXT records") { @type << 'txt' }
|
21
37
|
opt.on("-s", "--server=SERVER", "Specify specific name server to query") do |v|
|
22
38
|
@single_server = v
|
23
39
|
end
|
40
|
+
opt.on("-A", "--all", "Return all record types") { @type = %w[a mx c txt] }
|
24
41
|
opt.on("-h", "--help", "Prints this help") do
|
25
42
|
puts opt
|
26
43
|
exit
|
27
44
|
end
|
45
|
+
opt.on("-v", "--version", "Prints version") do
|
46
|
+
puts DNSLookup::VERSION
|
47
|
+
exit
|
48
|
+
end
|
28
49
|
end.parse!
|
29
|
-
|
30
|
-
# Get domain from command line arguments.
|
31
|
-
@domain = ARGV.shift
|
32
|
-
|
33
|
-
setup_query_servers
|
34
|
-
query_with_options
|
35
50
|
end
|
36
51
|
|
37
|
-
# Sets up the DNS servers to query.
|
38
52
|
def setup_query_servers
|
39
53
|
@servers = []
|
40
54
|
|
41
55
|
if @single_server
|
42
56
|
@servers << @single_server
|
43
57
|
else
|
44
|
-
@servers =
|
58
|
+
@servers = DEFAULT_SERVERS
|
45
59
|
end
|
46
60
|
end
|
47
61
|
|
48
|
-
# Query name servers for specific records or entire zone if @type is blank or unknown.
|
49
62
|
def query_with_options
|
50
|
-
|
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')
|
59
|
-
else
|
63
|
+
if @type.empty?
|
60
64
|
query_command('any')
|
65
|
+
else
|
66
|
+
query_command(@type)
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
64
|
-
|
65
|
-
def query_command(type)
|
70
|
+
def query_command(types)
|
66
71
|
@servers.each do |server|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
72
|
+
Array(types).each do |type|
|
73
|
+
record_type = type == 'any' ? '' : type.upcase
|
74
|
+
check = `dig @#{server} #{@domain} #{record_type} +short`
|
75
|
+
puts "Checking server: #{server} for #{record_type.empty? ? 'ALL' : record_type} records"
|
76
|
+
puts check.empty? ? "(no records found)" : check
|
77
|
+
puts
|
71
78
|
end
|
72
|
-
|
73
|
-
puts "Checking servers: #{server}"
|
74
|
-
puts check
|
75
|
-
puts
|
76
79
|
end
|
77
80
|
end
|
78
81
|
end
|
metadata
CHANGED
@@ -1,36 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnslookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor S. Keenan
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-12 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
email:
|
16
|
-
|
17
|
-
|
12
|
+
description: A Ruby CLI tool to query DNS records from multiple public or custom name
|
13
|
+
servers, providing fast and flexible DNS lookups.
|
14
|
+
email:
|
15
|
+
- me@victorkeenan.com
|
16
|
+
executables: []
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
21
|
-
- bin/dnslookup
|
22
20
|
- lib/dnslookup.rb
|
21
|
+
- lib/dnslookup/version.rb
|
23
22
|
homepage: https://www.victorkeenan.com/projects/dnslookup/
|
24
23
|
licenses:
|
25
24
|
- MIT
|
26
25
|
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
26
|
homepage_uri: https://www.victorkeenan.com/projects/dnslookup/
|
31
27
|
source_code_uri: https://github.com/VictorSK/dnslookup/
|
28
|
+
changelog_uri: https://github.com/VictorSK/dnslookup/blob/main/CHANGELOG.md
|
29
|
+
bug_tracker_uri: https://github.com/VictorSK/dnslookup/issues/
|
30
|
+
documentation_uri: https://github.com/VictorSK/dnslookup/blob/main/README.md
|
32
31
|
rubygems_mfa_required: 'true'
|
33
|
-
post_install_message:
|
34
32
|
rdoc_options: []
|
35
33
|
require_paths:
|
36
34
|
- lib
|
@@ -45,8 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
43
|
- !ruby/object:Gem::Version
|
46
44
|
version: '0'
|
47
45
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
49
|
-
signing_key:
|
46
|
+
rubygems_version: 3.6.3
|
50
47
|
specification_version: 4
|
51
|
-
summary:
|
48
|
+
summary: A simple Ruby CLI tool for querying DNS records.
|
52
49
|
test_files: []
|