nslookupot 0.0.12 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c9de045df30e3e73273f0da9950c06e2e716ced7dee7fbbf55589c8c57067ee
4
- data.tar.gz: ce164bc5a05df2681fd6afda4848262e4bcad328818a81941b53a4f777c6bc4f
3
+ metadata.gz: 001bc23694a542dcd94ce1e95bafe0bf33ab59c4691637587aabfbbb8f969677
4
+ data.tar.gz: ddf23225145dfd448346e87e983689a0aef7fadef4bf4757749ecad533338122
5
5
  SHA512:
6
- metadata.gz: 9d836124c778fb60d8107d92ca53676af6e1a701881808894215ea435a7d3d33ad6138f260255c1b9bb202b25bef2588c97ed352e70a6f3739343d7ce098e7cd
7
- data.tar.gz: acf065bdad8c0dfa20f7d6bb5a6a1efb6f040434baed88578f98fba07afeca222c5be540062f5650d7ba2349b3fdf054bb77435d1c636d270e4bf8f427b6512e
6
+ metadata.gz: f1b614fc0bca485d8c03e52cd5c6a41030140f9bf0bde225343974ac88d9f85e0eb3fa897f4da879d71d7fd36d07d7d3c5e777f3b02e9e46ba59c353b014e58b
7
+ data.tar.gz: 6eed687c0fe4334edaa8a2865fcfb27f80a034fa4dd567c0db93f29b4498064dabe4e15bd6782a6fb7a2d507adf2b733907eb3c1168dc543a64d6f662faf0eed
@@ -3,7 +3,7 @@ name: CI
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - master
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: ['2.7.x', '3.0.x', '3.1.x']
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 'caa_rr_patch'
5
+ gem 'base64'
6
6
  gem 'openssl'
7
- gem 'rake'
8
- gem 'svcb_rr_patch'
7
+ gem 'resolv', '~> 0.4.0'
9
8
 
10
9
  group :test do
11
10
  gem 'byebug'
12
- gem 'rspec', '3.8.0'
13
- gem 'rubocop', '0.78.0'
11
+ gem 'rake'
12
+ gem 'rspec'
13
+ gem 'rubocop', '1.62.0'
14
14
  end
15
15
 
16
16
  gemspec
data/exe/nslookupot CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH << __dir__ + '/../lib'
4
+ $LOAD_PATH << "#{__dir__}/../lib"
5
5
 
6
6
  require 'nslookupot'
7
7
 
@@ -3,6 +3,8 @@
3
3
  require 'optparse'
4
4
 
5
5
  module Nslookupot
6
+ using Refinements
7
+
6
8
  # rubocop: disable Metrics/ClassLength
7
9
  class CLI
8
10
  # rubocop: disable Metrics/AbcSize
@@ -72,7 +74,7 @@ module Nslookupot
72
74
  begin
73
75
  args = op.parse(argv)
74
76
  rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
75
- warn op.to_s
77
+ warn op
76
78
  warn "** #{e.message}"
77
79
  exit 1
78
80
  end
@@ -90,7 +92,7 @@ module Nslookupot
90
92
  end
91
93
 
92
94
  if args.size != 1
93
- warn op.to_s
95
+ warn op
94
96
  warn '** `name` argument is not specified'
95
97
  exit 1
96
98
  end
@@ -102,7 +104,8 @@ module Nslookupot
102
104
 
103
105
  def s2typeclass(s)
104
106
  rr = Resolv::DNS::Resource::IN.const_get(s.upcase)
105
- raise NameError unless rr < Resolv::DNS::Resource
107
+ raise NameError unless rr < Resolv::DNS::Resource ||
108
+ rr < Resolv::DNS::Resource::IN::ServiceBinding
106
109
 
107
110
  rr
108
111
  end
@@ -110,7 +113,8 @@ module Nslookupot
110
113
  def types
111
114
  Resolv::DNS::Resource::IN.constants.filter do |const|
112
115
  c = Resolv::DNS::Resource::IN.const_get(const)
113
- c < Resolv::DNS::Resource
116
+ c < Resolv::DNS::Resource ||
117
+ c < Resolv::DNS::Resource::IN::ServiceBinding
114
118
  rescue ArgumentError
115
119
  false
116
120
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nslookupot
4
- VERSION = '0.0.12'
4
+ VERSION = '0.0.13'
5
5
  end
data/lib/nslookupot.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'resolv'
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 'caa_rr_patch'
25
+ spec.add_dependency 'base64'
26
26
  spec.add_dependency 'openssl'
27
- spec.add_dependency 'svcb_rr_patch'
27
+ spec.add_dependency 'resolv', '~> 0.4.0'
28
28
  end
@@ -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.12
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: 2023-02-19 00:00:00.000000000 Z
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: caa_rr_patch
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: svcb_rr_patch
56
+ name: resolv
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
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: '0'
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.4.6
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