nslookupot 0.0.11 → 0.0.13
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/.github/workflows/ci.yml +2 -2
- data/Gemfile +5 -5
- data/README.md +8 -0
- data/exe/nslookupot +1 -1
- data/lib/nslookupot/cli.rb +33 -4
- data/lib/nslookupot/utils.rb +65 -0
- data/lib/nslookupot/version.rb +1 -1
- data/lib/nslookupot.rb +4 -4
- data/nslookupot.gemspec +2 -2
- data/spec/utisl_spec.rb +83 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 001bc23694a542dcd94ce1e95bafe0bf33ab59c4691637587aabfbbb8f969677
|
4
|
+
data.tar.gz: ddf23225145dfd448346e87e983689a0aef7fadef4bf4757749ecad533338122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b614fc0bca485d8c03e52cd5c6a41030140f9bf0bde225343974ac88d9f85e0eb3fa897f4da879d71d7fd36d07d7d3c5e777f3b02e9e46ba59c353b014e58b
|
7
|
+
data.tar.gz: 6eed687c0fe4334edaa8a2865fcfb27f80a034fa4dd567c0db93f29b4498064dabe4e15bd6782a6fb7a2d507adf2b733907eb3c1168dc543a64d6f662faf0eed
|
data/.github/workflows/ci.yml
CHANGED
@@ -3,7 +3,7 @@ name: CI
|
|
3
3
|
on:
|
4
4
|
push:
|
5
5
|
branches:
|
6
|
-
-
|
6
|
+
- main
|
7
7
|
pull_request:
|
8
8
|
branches:
|
9
9
|
- '*'
|
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version: ['
|
16
|
+
ruby-version: ['3.1.x', '3.2.x', '3.3.x']
|
17
17
|
steps:
|
18
18
|
- name: Set up Ruby
|
19
19
|
uses: actions/setup-ruby@v1
|
data/Gemfile
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem '
|
5
|
+
gem 'base64'
|
6
6
|
gem 'openssl'
|
7
|
-
gem '
|
8
|
-
gem 'svcb_rr_patch'
|
7
|
+
gem 'resolv', '~> 0.4.0'
|
9
8
|
|
10
9
|
group :test do
|
11
10
|
gem 'byebug'
|
12
|
-
gem '
|
13
|
-
gem '
|
11
|
+
gem 'rake'
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'rubocop', '1.62.0'
|
14
14
|
end
|
15
15
|
|
16
16
|
gemspec
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ Usage: nslookupot [options] name
|
|
28
28
|
-h, --hostname VALUE the name server hostname (default cloudflare-dns.com)
|
29
29
|
-n, --no-check-sni no check SNI (default false)
|
30
30
|
-t, --type VALUE the type of the information query (default A)
|
31
|
+
--types print the list of query types
|
31
32
|
```
|
32
33
|
|
33
34
|
You can run it the following:
|
@@ -82,6 +83,13 @@ Ttl: 100
|
|
82
83
|
|
83
84
|
```
|
84
85
|
|
86
|
+
Supported query types are:
|
87
|
+
|
88
|
+
```sh-session
|
89
|
+
$ nslookupot --types
|
90
|
+
** A, AAAA, CAA, CNAME, HINFO, HTTPS, LOC, MINFO, MX, NS, PTR, SOA, SRV, SVCB, TXT, WKS
|
91
|
+
```
|
92
|
+
|
85
93
|
|
86
94
|
## License
|
87
95
|
|
data/exe/nslookupot
CHANGED
data/lib/nslookupot/cli.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
|
5
5
|
module Nslookupot
|
6
|
+
using Refinements
|
7
|
+
|
8
|
+
# rubocop: disable Metrics/ClassLength
|
6
9
|
class CLI
|
7
10
|
# rubocop: disable Metrics/AbcSize
|
8
11
|
# rubocop: disable Metrics/MethodLength
|
@@ -17,6 +20,7 @@ module Nslookupot
|
|
17
20
|
check_sni: true
|
18
21
|
}
|
19
22
|
type = 'A'
|
23
|
+
print_types = false
|
20
24
|
|
21
25
|
op.on(
|
22
26
|
'-s',
|
@@ -58,15 +62,28 @@ module Nslookupot
|
|
58
62
|
type = v
|
59
63
|
end
|
60
64
|
|
65
|
+
op.on(
|
66
|
+
'',
|
67
|
+
'--types',
|
68
|
+
'print the list of query types'
|
69
|
+
) do |v|
|
70
|
+
print_types = v
|
71
|
+
end
|
72
|
+
|
61
73
|
op.banner += ' name'
|
62
74
|
begin
|
63
75
|
args = op.parse(argv)
|
64
|
-
rescue OptionParser::InvalidOption => e
|
65
|
-
warn op
|
76
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
77
|
+
warn op
|
66
78
|
warn "** #{e.message}"
|
67
79
|
exit 1
|
68
80
|
end
|
69
81
|
|
82
|
+
if print_types
|
83
|
+
warn "** #{types.sort.join(', ')}"
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
70
87
|
begin
|
71
88
|
type = s2typeclass(type)
|
72
89
|
rescue NameError
|
@@ -75,7 +92,7 @@ module Nslookupot
|
|
75
92
|
end
|
76
93
|
|
77
94
|
if args.size != 1
|
78
|
-
warn op
|
95
|
+
warn op
|
79
96
|
warn '** `name` argument is not specified'
|
80
97
|
exit 1
|
81
98
|
end
|
@@ -87,11 +104,22 @@ module Nslookupot
|
|
87
104
|
|
88
105
|
def s2typeclass(s)
|
89
106
|
rr = Resolv::DNS::Resource::IN.const_get(s.upcase)
|
90
|
-
raise NameError unless rr < Resolv::DNS::Resource
|
107
|
+
raise NameError unless rr < Resolv::DNS::Resource ||
|
108
|
+
rr < Resolv::DNS::Resource::IN::ServiceBinding
|
91
109
|
|
92
110
|
rr
|
93
111
|
end
|
94
112
|
|
113
|
+
def types
|
114
|
+
Resolv::DNS::Resource::IN.constants.filter do |const|
|
115
|
+
c = Resolv::DNS::Resource::IN.const_get(const)
|
116
|
+
c < Resolv::DNS::Resource ||
|
117
|
+
c < Resolv::DNS::Resource::IN::ServiceBinding
|
118
|
+
rescue ArgumentError
|
119
|
+
false
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
95
123
|
# rubocop: disable Metrics/AbcSize
|
96
124
|
def run
|
97
125
|
opts, name, type = parse_options
|
@@ -126,4 +154,5 @@ module Nslookupot
|
|
126
154
|
end
|
127
155
|
# rubocop: enable Metrics/AbcSize
|
128
156
|
end
|
157
|
+
# rubocop: enable Metrics/ClassLength
|
129
158
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nslookupot
|
4
|
+
PARAMETER_REGISTRY = lambda {
|
5
|
+
registry = %w[
|
6
|
+
mandatory
|
7
|
+
alpn
|
8
|
+
no-default-alpn
|
9
|
+
port
|
10
|
+
ipv4hint
|
11
|
+
ech
|
12
|
+
ipv6hint
|
13
|
+
dohpath
|
14
|
+
]
|
15
|
+
# rubocop:disable Security/Eval
|
16
|
+
(8...65280).each do |nnnn|
|
17
|
+
eval "registry[nnnn] = \"undefine#{nnnn}\"", binding, __FILE__, __LINE__
|
18
|
+
end
|
19
|
+
(65280...65535).each do |nnnn|
|
20
|
+
eval "registry[nnnn] = \"key#{nnnn}\"", binding, __FILE__, __LINE__
|
21
|
+
end
|
22
|
+
# rubocop:enable Security/Eval
|
23
|
+
registry
|
24
|
+
}.call.freeze
|
25
|
+
|
26
|
+
module Refinements
|
27
|
+
refine Resolv::DNS::SvcParams do
|
28
|
+
unless method_defined?(:ocsp_uris)
|
29
|
+
# rubocop: disable Metrics/CyclomaticComplexity
|
30
|
+
# rubocop: disable Metrics/PerceivedComplexity
|
31
|
+
define_method(:to_s) do
|
32
|
+
@params.map do |k, v|
|
33
|
+
key = PARAMETER_REGISTRY[k]
|
34
|
+
value = case v
|
35
|
+
in Resolv::DNS::SvcParam::Mandatory
|
36
|
+
v.keys.map { |i| PARAMETER_REGISTRY[i] }.join(',')
|
37
|
+
in Resolv::DNS::SvcParam::ALPN
|
38
|
+
v.protocol_ids.join(',')
|
39
|
+
# NOTE: no-default-alpn is not supported
|
40
|
+
# https://github.com/ruby/resolv/blob/v0.4.0/lib/resolv.rb#L1942
|
41
|
+
in Resolv::DNS::SvcParam::IPv4Hint
|
42
|
+
v.addresses.join(',')
|
43
|
+
in Resolv::DNS::SvcParam::Port
|
44
|
+
v.port.to_s
|
45
|
+
in Resolv::DNS::SvcParam::Generic \
|
46
|
+
if Resolv::DNS::SvcParam::Generic.const_get(:Key5) &&
|
47
|
+
v.is_a?(Resolv::DNS::SvcParam::Generic::Key5)
|
48
|
+
# ech
|
49
|
+
Base64.strict_encode64(v.value)
|
50
|
+
in Resolv::DNS::SvcParam::IPv6Hint
|
51
|
+
v.addresses.join(',')
|
52
|
+
in Resolv::DNS::SvcParam::DoHPath
|
53
|
+
v.template.encode('utf-8')
|
54
|
+
else
|
55
|
+
v.to_s
|
56
|
+
end
|
57
|
+
"#{key}=#{value}"
|
58
|
+
end.join(' ')
|
59
|
+
end
|
60
|
+
# rubocop: enable Metrics/CyclomaticComplexity
|
61
|
+
# rubocop: enable Metrics/PerceivedComplexity
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/nslookupot/version.rb
CHANGED
data/lib/nslookupot.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'caa_rr_patch'
|
5
|
-
require 'svcb_rr_patch'
|
6
|
-
require 'socket'
|
3
|
+
require 'base64'
|
7
4
|
require 'openssl'
|
8
5
|
require 'optparse'
|
6
|
+
require 'resolv'
|
7
|
+
require 'socket'
|
9
8
|
|
10
9
|
require 'nslookupot/version'
|
11
10
|
require 'nslookupot/error'
|
12
11
|
require 'nslookupot/resolver'
|
12
|
+
require 'nslookupot/utils'
|
13
13
|
require 'nslookupot/cli'
|
data/nslookupot.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = ['nslookupot']
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_dependency '
|
25
|
+
spec.add_dependency 'base64'
|
26
26
|
spec.add_dependency 'openssl'
|
27
|
-
spec.add_dependency '
|
27
|
+
spec.add_dependency 'resolv', '~> 0.4.0'
|
28
28
|
end
|
data/spec/utisl_spec.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
# rubocop: disable Metrics/BlockLength
|
6
|
+
RSpec.describe Nslookupot::Refinements do
|
7
|
+
using Nslookupot::Refinements
|
8
|
+
|
9
|
+
context 'SvcParams#to_s' do
|
10
|
+
let(:mandatory) do
|
11
|
+
Resolv::DNS::SvcParams.new(
|
12
|
+
[
|
13
|
+
Resolv::DNS::SvcParam::Mandatory.new([5, 6, 8, 65534])
|
14
|
+
]
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'could to_s' do
|
19
|
+
expect(mandatory.to_s).to eq 'mandatory=ech,ipv6hint,undefine8,key65534'
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:alpn) do
|
23
|
+
Resolv::DNS::SvcParams.new(
|
24
|
+
[
|
25
|
+
Resolv::DNS::SvcParam::ALPN.new(%w[h2 h3])
|
26
|
+
]
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'could to_s' do
|
31
|
+
expect(alpn.to_s).to eq 'alpn=h2,h3'
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:port) do
|
35
|
+
Resolv::DNS::SvcParams.new(
|
36
|
+
[
|
37
|
+
Resolv::DNS::SvcParam::Port.new(80)
|
38
|
+
]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'could to_s' do
|
43
|
+
expect(port.to_s).to eq 'port=80'
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:ipv4hint) do
|
47
|
+
Resolv::DNS::SvcParams.new(
|
48
|
+
[
|
49
|
+
Resolv::DNS::SvcParam::IPv4Hint.new(%w[192.168.0.1])
|
50
|
+
]
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'could to_s' do
|
55
|
+
expect(ipv4hint.to_s).to eq 'ipv4hint=192.168.0.1'
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:ipv6hint) do
|
59
|
+
Resolv::DNS::SvcParams.new(
|
60
|
+
[
|
61
|
+
Resolv::DNS::SvcParam::IPv6Hint.new(%w[2001:db8::1])
|
62
|
+
]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'could to_s' do
|
67
|
+
expect(ipv6hint.to_s).to eq 'ipv6hint=2001:db8::1'
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:dohpath) do
|
71
|
+
Resolv::DNS::SvcParams.new(
|
72
|
+
[
|
73
|
+
Resolv::DNS::SvcParam::DoHPath.new('/dns-query{?dns}')
|
74
|
+
]
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'could to_s' do
|
79
|
+
expect(dohpath.to_s).to eq 'dohpath=/dns-query{?dns}'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
# rubocop: enable Metrics/BlockLength
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nslookupot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: base64
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: resolv
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.4.0
|
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: 0.4.0
|
69
69
|
description: nslookup over TLS
|
70
70
|
email:
|
71
71
|
- thekuwayama@gmail.com
|
@@ -86,11 +86,13 @@ files:
|
|
86
86
|
- lib/nslookupot/cli.rb
|
87
87
|
- lib/nslookupot/error.rb
|
88
88
|
- lib/nslookupot/resolver.rb
|
89
|
+
- lib/nslookupot/utils.rb
|
89
90
|
- lib/nslookupot/version.rb
|
90
91
|
- nslookupot.gemspec
|
91
92
|
- spec/cli_spec.rb
|
92
93
|
- spec/resolver_spec.rb
|
93
94
|
- spec/spec_helper.rb
|
95
|
+
- spec/utisl_spec.rb
|
94
96
|
homepage: https://github.com/thekuwayama/nslookupot
|
95
97
|
licenses:
|
96
98
|
- MIT
|
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
112
|
- !ruby/object:Gem::Version
|
111
113
|
version: '0'
|
112
114
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.3.7
|
114
116
|
signing_key:
|
115
117
|
specification_version: 4
|
116
118
|
summary: nslookup over TLS
|
@@ -118,3 +120,4 @@ test_files:
|
|
118
120
|
- spec/cli_spec.rb
|
119
121
|
- spec/resolver_spec.rb
|
120
122
|
- spec/spec_helper.rb
|
123
|
+
- spec/utisl_spec.rb
|