dnslookup 0.1.6 → 0.2.0

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: 8c301630601684995c07ec014d4b8dfc49658edf92db6caf229ba2416594453b
4
- data.tar.gz: bccdd6cdc2a557b6522fbef733db9ef3edf7479379ec3a03f2d34180d06f3cec
3
+ metadata.gz: a19d9fbc3a55a3817461a6fb42356fb983c3c8d4409fc3b06539c78e644117c6
4
+ data.tar.gz: 4e5d9c585eb57936e0f7d93b47cfec771c9b00cd5921098af69811d7c0236ff5
5
5
  SHA512:
6
- metadata.gz: 55544a968ccf829c4dde08063ad6d064031ad847323aa3ff52d3032d3df72266f37894e7c015bdc21ddc3a94d804c19d22b1b8a9e6650df7f7cafe3d1e4336f3
7
- data.tar.gz: c94879c89baf2ac1f94ff36ebeb4ca174cf434a1765c5132a053995ff589994c042f2b2eacce629d500bba477d482c5c1e512aa029ab9f81dbdc29e138bc925e
6
+ metadata.gz: d7d006b4306b0bdacf41ffdebcc878c8d8fac2d72d4df6769e1f9010b87996f2b5179105a5116a2a58ed11f6cf74ce5f58ffbbc828971a8c4cdd860ddd7d8ef7
7
+ data.tar.gz: 219c16da76a578bb236985cf4e83383cd9b15c960de105d771818e30b45d34ebf240916150e5f92773cc9480ee142e15d813ad3776376c78c531171837497859
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # CHANGELOG
2
+
3
+ The noteworthy updates for each dnslookup version are included here. For a complete changelog, see the git history.
4
+
5
+ ## [0.2.0] - February 08, 2023
6
+
7
+ ### New Features
8
+
9
+ - Added ability to check multiple record types at once.
10
+ - Updated core gem Ruby code and general code improvements.
11
+ - Updated tests.
12
+
13
+ ## [0.1.6] - February 06, 2023
14
+
15
+ ### Changes
16
+
17
+ - Added Ruby 3.0 to required versions.
18
+ - Spec bumps and general code improvements.
19
+
20
+ ## [0.1.0] - February 01, 2016
21
+
22
+ ### New Features
23
+
24
+ - Initial release
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ - Using welcoming and inclusive language
12
+ - Being respectful of differing viewpoints and experiences
13
+ - Gracefully accepting constructive criticism
14
+ - Focusing on what is best for the community
15
+ - Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ - The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ - Trolling, insulting/derogatory comments, and personal or political attacks
21
+ - Public or private harassment
22
+ - Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the main project maintainer [Victor S. Keenan](https://twitter.com/victorsk). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 - 2024 Victor S. Keenan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # dnslookup
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/dnslookup.svg)](https://badge.fury.io/rb/dnslookup)
4
+
5
+ dnslookup is a DNS record query CLI gem written in Ruby. dnslookup automatically queries multiple public DNS servers or allows you to query a specific DNS server.
6
+
7
+ Please use [GitHub Issues](https://github.com/VictorSK/dnslookup/issues) to report bugs.
8
+
9
+ ## Installation
10
+
11
+ To add dnslookup to an existing project, add this line to your projects's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'dnslookup'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ bundle install
21
+ ```
22
+
23
+ Or to install locally:
24
+
25
+ ```bash
26
+ gem install dnslookup
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Lookup DNS records:
32
+
33
+ ```bash
34
+ dnslookup <domain name> [options]
35
+ ```
36
+
37
+ ### Options
38
+
39
+ `-m` or `--mx` will return only MX records.
40
+
41
+ `-a` or `--aname` will return only A name records.
42
+
43
+ `-c` or `--cname` will return only C name records.
44
+
45
+ `-t` or `--txt` will return only TXT records.
46
+
47
+ `-s` or `--server=IP` will query specific name server IP.
48
+
49
+ `-h` or `--help` will output this help in your shell.
50
+
51
+ Help with usage and options:
52
+
53
+ ```bash
54
+ dnslookup -h
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/VictorSK/dnslookup). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the terms specified in the [CODE OF CONDUCT](CODE_OF_CONDUCT). It's code, lets be safe and have fun!
60
+
61
+ ## License
62
+
63
+ dnslookup is copyright © 2016-2024 Victor S. Keenan. It is free software and may be redistributed under the terms specified in the [LICENSE](LICENSE) file.
64
+
65
+ ## Coded With Love
66
+
67
+ Coded crafted by me, [Victor S. Keenan](https://www.victorkeenan.com). Find me on Twitter [@VictorSK](https://twitter.com/victorsk) or [hire me](https://www.inspyre.com) to design, develop, and grow your product or service.
data/dnslookup.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/dnslookup/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'dnslookup'
7
+ spec.version = DNSLookup::VERSION
8
+ spec.author = 'Victor S. Keenan'
9
+ spec.email = 'me@victorkeenan.com'
10
+ spec.summary = "DNS record query CLI gem written in Ruby."
11
+ spec.homepage = 'https://www.victorkeenan.com/projects/dnslookup/'
12
+ spec.required_ruby_version = '>= 3.0'
13
+ spec.license = 'MIT'
14
+ spec.description = "dnslookup is a DNS record query CLI gem written in Ruby. dnslookup automatically queries multiple public DNS servers or allows you to query a specific DNS server."
15
+ spec.executables = 'dnslookup'
16
+ spec.require_paths = ["lib"]
17
+ spec.metadata = {
18
+ 'homepage_uri' => 'https://www.victorkeenan.com/projects/dnslookup/',
19
+ 'bug_tracker_uri' => 'https://github.com/VictorSK/dnslookup/issues/',
20
+ 'changelog_uri' => 'https://github.com/VictorSK/dnslookup/blob/main/CHANGELOG.md',
21
+ 'documentation_uri' => 'https://github.com/VictorSK/dnslookup/blob/main/README.md',
22
+ 'source_code_uri' => 'https://github.com/VictorSK/dnslookup/',
23
+ 'rubygems_mfa_required' => 'true'
24
+ }
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (File.expand_path(f) == __FILE__) ||
28
+ f.start_with?(*%w[bin/ test/ .git Rakefile Gemfile])
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DNSLookup
4
+ VERSION = "0.2.0"
5
+ end
data/lib/dnslookup.rb CHANGED
@@ -1,23 +1,30 @@
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
- # DNSLookup::Query class is the main.
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
+ parse_options
17
+ setup_query_servers
18
+ query_with_options
19
+ end
13
20
 
14
- # Parses the options passed from command prompt.
21
+ def parse_options
15
22
  OptionParser.new do |opt|
16
23
  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' }
24
+ opt.on("-m", "--mx", "Return MX records") { @type << 'mx' }
25
+ opt.on("-a", "--aname", "Return A name records") { @type << 'a' }
26
+ opt.on("-c", "--cname", "Return C name records") { @type << 'c' }
27
+ opt.on("-t", "--txt", "Return TXT records") { @type << 'txt' }
21
28
  opt.on("-s", "--server=SERVER", "Specify specific name server to query") do |v|
22
29
  @single_server = v
23
30
  end
@@ -25,54 +32,48 @@ module DNSLookup
25
32
  puts opt
26
33
  exit
27
34
  end
35
+ opt.on("-v", "--version", "Prints version") do
36
+ puts DNSLookup::VERSION
37
+ exit
38
+ end
28
39
  end.parse!
29
-
30
- # Get domain from command line arguments.
31
- @domain = ARGV.shift
32
-
33
- setup_query_servers
34
- query_with_options
35
40
  end
36
41
 
37
- # Sets up the DNS servers to query.
38
42
  def setup_query_servers
39
43
  @servers = []
40
44
 
41
45
  if @single_server
42
46
  @servers << @single_server
43
47
  else
44
- @servers = ['8.8.8.8', '8.8.4.4']
48
+ @servers = DEFAULT_SERVERS
45
49
  end
46
50
  end
47
51
 
48
- # Query name servers for specific records or entire zone if @type is blank or unknown.
49
52
  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')
59
- else
53
+ if @type.empty?
60
54
  query_command('any')
55
+ else
56
+ query_command(@type)
61
57
  end
62
58
  end
63
59
 
64
- # Query command to execute.
65
60
  def query_command(type)
66
61
  @servers.each do |server|
67
62
  if type == 'any'
68
63
  check = `dig @#{server} #{type} #{@domain}`
64
+
65
+ puts "Checking servers: #{server} root domain records"
66
+ puts check
67
+ puts
69
68
  else
70
- check = `dig @#{server} #{@domain} #{type} +short`
71
- end
69
+ @type.each do |type|
70
+ check = `dig @#{server} #{@domain} #{type.upcase} +short`
72
71
 
73
- puts "Checking servers: #{server}"
74
- puts check
75
- puts
72
+ puts "Checking servers: #{server} for #{type.upcase} records"
73
+ puts check
74
+ puts
75
+ end
76
+ end
76
77
  end
77
78
  end
78
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.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor S. Keenan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-02-08 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.
@@ -18,16 +18,22 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - LICENSE.txt
24
+ - README.md
21
25
  - bin/dnslookup
26
+ - dnslookup.gemspec
22
27
  - lib/dnslookup.rb
28
+ - lib/dnslookup/version.rb
23
29
  homepage: https://www.victorkeenan.com/projects/dnslookup/
24
30
  licenses:
25
31
  - MIT
26
32
  metadata:
33
+ homepage_uri: https://www.victorkeenan.com/projects/dnslookup/
27
34
  bug_tracker_uri: https://github.com/VictorSK/dnslookup/issues/
28
35
  changelog_uri: https://github.com/VictorSK/dnslookup/blob/main/CHANGELOG.md
29
36
  documentation_uri: https://github.com/VictorSK/dnslookup/blob/main/README.md
30
- homepage_uri: https://www.victorkeenan.com/projects/dnslookup/
31
37
  source_code_uri: https://github.com/VictorSK/dnslookup/
32
38
  rubygems_mfa_required: 'true'
33
39
  post_install_message: