dns_zone_cli 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f3f873fbf628bc88538e0c2bd1065f9d30d239772ffab2bc65c6c05871604d68
4
+ data.tar.gz: 9b9655edb35e7274b1463e05a007f95c60372272f6b21e12b30457dad7d01a48
5
+ SHA512:
6
+ metadata.gz: 3625c937f155345bb17cc815f31f5baf7777d240ddd1e9e644c0f6558298ee0c1c3f57d8b475cb1f8bff4627ff0ec51585fadfa4beec4d80c78fe35edbfaae5e
7
+ data.tar.gz: bca61325701763ee4a980f9c7a41ca0797facdda433d428d641637489f75c0af774649bb8983521a929229e1c90b453eeb29b615326f190f46b31f499ad3bc01
@@ -0,0 +1,17 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4
+
5
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6
+ ARG NODE_VERSION="none"
7
+ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8
+
9
+ # [Optional] Uncomment this section to install additional OS packages.
10
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
12
+
13
+ # [Optional] Uncomment this line to install additional gems.
14
+ # RUN gem install <your-gem-names-here>
15
+
16
+ # [Optional] Uncomment this line to install global node packages.
17
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,43 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM ruby:${VARIANT}
4
+
5
+ # Copy library scripts to execute
6
+ COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
7
+
8
+ # [Option] Install zsh
9
+ ARG INSTALL_ZSH="true"
10
+ # [Option] Upgrade OS packages to their latest versions
11
+ ARG UPGRADE_PACKAGES="true"
12
+ # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
13
+ ARG USERNAME=vscode
14
+ ARG USER_UID=1000
15
+ ARG USER_GID=$USER_UID
16
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
17
+ # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
18
+ && apt-get purge -y imagemagick imagemagick-6-common \
19
+ # Install common packages, non-root user, rvm, core build tools
20
+ && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
21
+ && bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
22
+ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
23
+
24
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
25
+ ARG NODE_VERSION="none"
26
+ ENV NVM_DIR=/usr/local/share/nvm
27
+ ENV NVM_SYMLINK_CURRENT=true \
28
+ PATH=${NVM_DIR}/current/bin:${PATH}
29
+ RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
30
+ && apt-get clean -y && rm -rf /var/lib/apt/lists/*
31
+
32
+ # Remove library scripts for final image
33
+ RUN rm -rf /tmp/library-scripts
34
+
35
+ # [Optional] Uncomment this section to install additional OS packages.
36
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
37
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
38
+
39
+ # [Optional] Uncomment this line to install additional gems.
40
+ # RUN gem install <your-gem-names-here>
41
+
42
+ # [Optional] Uncomment this line to install global node packages.
43
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,38 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "build": {
6
+ "dockerfile": "Dockerfile",
7
+ "args": {
8
+ // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
9
+ // Append -bullseye or -buster to pin to an OS version.
10
+ // Use -bullseye variants on local on arm64/Apple Silicon.
11
+ "VARIANT": "3-bullseye",
12
+ // Options
13
+ "NODE_VERSION": "lts/*"
14
+ }
15
+ },
16
+
17
+ // Set *default* container specific settings.json values on container create.
18
+ "settings": {},
19
+
20
+ // Add the IDs of extensions you want installed when the container is created.
21
+ "extensions": [
22
+ "rebornix.Ruby"
23
+ ],
24
+
25
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
26
+ // "forwardPorts": [],
27
+
28
+ // Use 'postCreateCommand' to run commands after the container is created.
29
+ // "postCreateCommand": "ruby --version",
30
+
31
+ // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32
+ "remoteUser": "vscode",
33
+ "features": {
34
+ "git": "latest",
35
+ "github-cli": "latest"
36
+ }
37
+
38
+ }
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-01-31
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in dns_zone_cli.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem 'thor'
11
+
12
+ gem "rspec", "~> 3.0"
13
+
14
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dns_zone_cli (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ parallel (1.21.0)
12
+ parser (3.1.0.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.1.1)
15
+ rake (13.0.6)
16
+ regexp_parser (2.2.0)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.2)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.2)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.3)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.3)
31
+ rubocop (1.25.0)
32
+ parallel (~> 1.10)
33
+ parser (>= 3.1.0.0)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.15.1, < 2.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.15.1)
41
+ parser (>= 3.0.1.1)
42
+ ruby-progressbar (1.11.0)
43
+ thor (1.2.1)
44
+ unicode-display_width (2.1.0)
45
+
46
+ PLATFORMS
47
+ aarch64-linux
48
+
49
+ DEPENDENCIES
50
+ dns_zone_cli!
51
+ rake (~> 13.0)
52
+ rspec (~> 3.0)
53
+ rubocop (~> 1.21)
54
+ thor
55
+
56
+ BUNDLED WITH
57
+ 2.3.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 TODO: Write your name
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # DnsZoneCli
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dns_zone_cli`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'dns_zone_cli'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dns_zone_cli
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dns_zone_cli.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+ # dns_zone_cli
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/dns_zone_cli ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "dns_zone_cli"
4
+
5
+ DnsZoneCli::CLI.start
@@ -0,0 +1,101 @@
1
+ require "dns_zone_cli"
2
+ require 'resolv'
3
+ require "thor"
4
+
5
+ module DnsZoneCli
6
+ class CLI < Thor
7
+ desc 'quick dns checker', 'This is CLI domain DNS Check Tool'
8
+
9
+ @@domain_regex = /^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$/
10
+ @@ipv4_regex = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/
11
+ @@ipv6_regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/
12
+
13
+ some_host_name = ['', 'www.', 'ftp.', 'pop.', 'smtp.', 'imap.', 'mail.', 'mx.', 'localhost.']
14
+ host_name_none = ['']
15
+
16
+ @@recoad_type_and_host_neme = {
17
+ NS: host_name_none,
18
+ A: some_host_name,
19
+ CNAME: some_host_name,
20
+ MX: ['', 'mail.', 'mx.'],
21
+ TXT: host_name_none
22
+ }
23
+
24
+ def check
25
+ say "***Hi, this is CLI domain\'s DNS zone chekcer***", :green
26
+ @domain = ask "Please type (domain name) and press (enter)\r\n", :green
27
+
28
+ while @domain.nil? || !@domain.match(@@domain_regex)
29
+ say "***Null or it's not FQDN. Please try again***", :red
30
+ @domain = ask 'Please retype (domain name) and press (enter)', :red
31
+ end
32
+
33
+ say 'By default, Google Public DNS(8.8.8.8) DNS is used, is there any problem?', :green
34
+
35
+ if yes? "If OK, please press (y) and (enter).\r\nIf you want to use another DNS, please press (enter)", :green
36
+ query_dns('8.8.8.8')
37
+ else
38
+ assign_dns = ask "Please input DNS server name and (enter)\r\n", :green
39
+
40
+ valid_dns_host = [@@domain_regex, @@ipv4_regex, @@ipv6_regex]
41
+
42
+ while assign_dns.nil? || !assign_dns.match(Regexp.union(valid_dns_host))
43
+ say "***Null or it's not dns_server. Please try again***", :red
44
+ assign_dns = ask "(Please retype dns server name and press enter key)\r\nex:dns.google\r\nex:1.1.1.1\r\n", :red
45
+ end
46
+
47
+ # DNS server find?
48
+ begin
49
+ Resolv.getaddress(assign_dns)
50
+ rescue StandardError
51
+ say "I can\'t DNS host name, so... I use Google Public DNS", :red
52
+ query_dns('8.8.8.8')
53
+ else
54
+ query_dns(assign_dns)
55
+ end
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def query_dns(dns_server)
62
+ puts '========================================================='
63
+ puts "Answerd DNS server is #{dns_server}"
64
+ puts '========================================================='
65
+
66
+ is_dns = Resolv::DNS.new(nameserver: dns_server)
67
+
68
+ @@recoad_type_and_host_neme.each do |recoad_type, host_name|
69
+ puts "----------------#{recoad_type} Recoad--------------------"
70
+ host_name.each do |host|
71
+ fqdn = host + @domain
72
+
73
+ case recoad_type
74
+ when :NS
75
+ is_dns.each_resource(fqdn, Resolv::DNS::Resource::IN::NS) do |resource|
76
+ puts "#{fqdn}\t#{resource.ttl}\tIN\t#{recoad_type}\t#{resource.name}"
77
+ end
78
+ when :A
79
+ is_dns.each_resource(fqdn, Resolv::DNS::Resource::IN::A) do |resource|
80
+ puts "#{fqdn}\t#{resource.ttl}\tIN\t#{recoad_type}\t#{resource.address}"
81
+ end
82
+ when :CNAME
83
+ is_dns.each_resource(fqdn, Resolv::DNS::Resource::IN::CNAME) do |resource|
84
+ puts "#{fqdn}\t#{resource.ttl}\tIN\t#{recoad_type}\t#{resource.name}"
85
+ end
86
+ when :MX
87
+ is_dns.each_resource(fqdn, Resolv::DNS::Resource::IN::MX) do |resource|
88
+ puts "#{fqdn}\t#{resource.ttl}\tIN\t#{recoad_type}\t#{resource.preference}\t#{resource.exchange}"
89
+ end
90
+ when :TXT
91
+ is_dns.each_resource(fqdn, Resolv::DNS::Resource::IN::TXT) do |resource|
92
+ txt_value = resource.strings.pop
93
+ puts "#{fqdn}\t#{resource.ttl}\tIN\t#{recoad_type}\t\"#{txt_value}\""
94
+ end
95
+ end
96
+ end
97
+ puts '---------------------------------------------------------'
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DnsZoneCli
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dns_zone_cli/version"
4
+ require_relative "dns_zone_cli/cli.rb"
5
+
6
+ module DnsZoneCli
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,4 @@
1
+ module DnsZoneCli
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dns_zone_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - norix_tokyo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "This app interactively gets the DNS zone of the domain in bulk. \r\nAll
14
+ standard host names have already been set, so you can easily check them all at once."
15
+ email:
16
+ - norifumiyukawa@me.com
17
+ executables:
18
+ - dns_zone_cli
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".devcontainer/Dockerfile"
23
+ - ".devcontainer/base.Dockerfile"
24
+ - ".devcontainer/devcontainer.json"
25
+ - ".rspec"
26
+ - ".rubocop.yml"
27
+ - CHANGELOG.md
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - LICENSE.txt
31
+ - README.md
32
+ - Rakefile
33
+ - exe/dns_zone_cli
34
+ - lib/dns_zone_cli.rb
35
+ - lib/dns_zone_cli/cli.rb
36
+ - lib/dns_zone_cli/version.rb
37
+ - sig/dns_zone_cli.rbs
38
+ homepage: https://github.com/NorifumiYukawa/dns_zone_cli
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ homepage_uri: https://github.com/NorifumiYukawa/dns_zone_cli
43
+ source_code_uri: https://github.com/NorifumiYukawa/dns_zone_cli
44
+ changelog_uri: https://github.com/NorifumiYukawa/cs_bank
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.0.3.1
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: CLI tool to check domain dns zone so easily
64
+ test_files: []