svcb_rr_patch 0.0.3 → 0.0.4

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: 503344cf96161251cbd1d4757b83f88c801cc2dd759a65c565d6ced4ee5c7821
4
- data.tar.gz: a7c0ed560ab69ce745d24488c0a9d9cf05cafb022daa4bda9ac02e0aa3f9bc23
3
+ metadata.gz: 607172ae2b63afd7c66a3cfe87456873eb1f436c28f0380a52edeeb31d9f3902
4
+ data.tar.gz: b8a3b83f4820b78fb3efcb27b675a3cf07a58f360fe7d3c3a93fdd7161ced077
5
5
  SHA512:
6
- metadata.gz: 65d4ae23c0a139f3572330d4b7965209c25c1842fd0af6ea9fd404748359ab3f24f632ca873e63469728bf7d3c6ade8b21dbf57a2c3387fdb69ef85157d73965
7
- data.tar.gz: 127393d4ceb5f7afc7e1ec48baefb850c6cad8eca6c26f7baef1818ba1dcfdb01c8dd6fdc7f23f3aefb7ca1aa5edfb3b7ae5b2d11674785051d8c189dc4b611f
6
+ metadata.gz: 7125f6c9205f872a12574801bf5026073cd4d028640afbaefdf2a2ee69f11cc832167d4612341c475605306705af0742bb724fc241f482c85af8fe1e8a4f61d1
7
+ data.tar.gz: 9217eca73420740086db7877bd5ff05e024ece6f6ecda1ad0d6b30e50cb1966da733b32f3daab8518a1180d25c6a0de1a8c7dab4105e132e186ae21a956e419b
data/README.md CHANGED
@@ -36,16 +36,7 @@ irb(main):004:1* Resolv::DNS::Resource::IN::HTTPS
36
36
  irb(main):005:0> )
37
37
  =>
38
38
  [#<Resolv::DNS::Resource::IN::HTTPS:0x0000000000000001
39
- @svc_params=
40
- {"alpn"=>
41
- #<SvcbRrPatch::SvcParams::Alpn:0x0000000000000002
42
- @protocols=["h3", "h3-29", "h3-28", "h3-27", "h2"]>,
43
- "ipv4hint"=>
44
- #<SvcbRrPatch::SvcParams::Ipv4hint:0x0000000000000003
45
- @addresses=[#<Resolv::IPv4 104.18.26.46>, #<Resolv::IPv4 104.18.27.46>]>,
46
- "ipv6hint"=>
47
- #<SvcbRrPatch::SvcParams::Ipv6hint:0x0000000000000004
48
- @addresses=[#<Resolv::IPv6 2606:4700::6812:1a2e>, #<Resolv::IPv6 2606:4700::6812:1b2e>]>},
39
+ @svc_params={"alpn"=>h3,h3-29,h3-28,h3-27,h2, "ipv4hint"=>104.18.26.46,104.18.27.46, "ipv6hint"=>2606:4700::6812:1a2e,2606:4700::6812:1b2e},
49
40
  @svc_priority=1,
50
41
  @target_name="",
51
42
  @ttl=300>]
@@ -35,4 +35,9 @@ class SvcbRrPatch::SvcParams::Alpn
35
35
  protocols = decode_protocols(octet)
36
36
  new(protocols)
37
37
  end
38
+
39
+ # :nodoc:
40
+ def inspect
41
+ @protocols.join(',')
42
+ end
38
43
  end
@@ -18,4 +18,9 @@ class SvcbRrPatch::SvcParams::Ipv4hint
18
18
  addresses = octet.scan(/.{1,4}/).map { |s| Resolv::IPv4.new(s) }
19
19
  new(addresses)
20
20
  end
21
+
22
+ # :nodoc:
23
+ def inspect
24
+ @addresses.join(',')
25
+ end
21
26
  end
@@ -18,4 +18,9 @@ class SvcbRrPatch::SvcParams::Ipv6hint
18
18
  addresses = octet.scan(/.{1,16}/).map { |s| Resolv::IPv6.new(s) }
19
19
  new(addresses)
20
20
  end
21
+
22
+ # :nodoc:
23
+ def inspect
24
+ @addresses.join(',')
25
+ end
21
26
  end
@@ -15,7 +15,20 @@ class SvcbRrPatch::SvcParams::Mandatory
15
15
 
16
16
  # :nodoc:
17
17
  def self.decode(octet)
18
- keys = octet.scan(/.{1,2}/).map { |s| s.unpack1('n') }
18
+ keys = octet.scan(/.{1,2}/)
19
+ .map { |s| s.unpack1('n') }
20
+ .filter { |i| i < 7 || i >= 65280 && i < 65535 }
19
21
  new(keys)
20
22
  end
23
+
24
+ # :nodoc:
25
+ def inspect
26
+ @keys.map do |i|
27
+ if i < 7 || i >= 65280 && i < 65535
28
+ SvcbRrPatch::SvcParams::PARAMETER_REGISTRY[i]
29
+ else
30
+ ''
31
+ end
32
+ end.join(',')
33
+ end
21
34
  end
@@ -18,4 +18,9 @@ class SvcbRrPatch::SvcParams::Port
18
18
  port = octet.unpack1('n')
19
19
  new(port)
20
20
  end
21
+
22
+ # :nodoc:
23
+ def inspect
24
+ @port.to_s
25
+ end
21
26
  end
@@ -12,7 +12,7 @@ module SvcbRrPatch::SvcParams
12
12
  ipv6hint
13
13
  ]
14
14
  # rubocop:disable Security/Eval
15
- (65280..65535).each do |nnnn|
15
+ (65280...65535).each do |nnnn|
16
16
  eval "registry[nnnn] = \"key#{nnnn}\"", binding, __FILE__, __LINE__
17
17
  end
18
18
  # rubocop:enable Security/Eval
@@ -74,8 +74,8 @@ module SvcbRrPatch::SvcParams
74
74
  # rubocop:disable Metrics/CyclomaticComplexity
75
75
  def self.decode_svc_params(key, octet)
76
76
  case key
77
- when 'no name'
78
- NoName.decode(octet)
77
+ when 'mandatory'
78
+ Mandatory.decode(octet)
79
79
  when 'alpn'
80
80
  Alpn.decode(octet)
81
81
  when 'no-default-alpn'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SvcbRrPatch
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
data/spec/alpn_spec.rb CHANGED
@@ -25,6 +25,7 @@ RSpec.describe SvcbRrPatch::SvcParams::Alpn do
25
25
 
26
26
  it 'could encode' do
27
27
  expect(alpn.encode).to eq octet
28
+ expect(alpn.inspect).to eq 'h3-29,h3-28,h3-27,h2'
28
29
  end
29
30
  end
30
31
  end
@@ -5,7 +5,7 @@ require_relative 'spec_helper'
5
5
 
6
6
  RSpec.describe SvcbRrPatch::SvcParams::Ipv4hint do
7
7
  let(:octet) do
8
- "\xc0\xa8\x00\x01\xc0\xa8\x00\x02"
8
+ "\xc0\x00\x02\x01\xc0\x00\x02\x02"
9
9
  end
10
10
 
11
11
  context '#decode' do
@@ -15,8 +15,8 @@ RSpec.describe SvcbRrPatch::SvcParams::Ipv4hint do
15
15
 
16
16
  it 'could decode' do
17
17
  expect(ipv4hint.addresses).to eq [
18
- Resolv::IPv4.create('192.168.0.1'),
19
- Resolv::IPv4.create('192.168.0.2')
18
+ Resolv::IPv4.create('192.0.2.1'),
19
+ Resolv::IPv4.create('192.0.2.2')
20
20
  ]
21
21
  end
22
22
  end
@@ -25,14 +25,15 @@ RSpec.describe SvcbRrPatch::SvcParams::Ipv4hint do
25
25
  let(:ipv4hint) do
26
26
  SvcbRrPatch::SvcParams::Ipv4hint.new(
27
27
  [
28
- Resolv::IPv4.create('192.168.0.1'),
29
- Resolv::IPv4.create('192.168.0.2')
28
+ Resolv::IPv4.create('192.0.2.1'),
29
+ Resolv::IPv4.create('192.0.2.2')
30
30
  ]
31
31
  )
32
32
  end
33
33
 
34
34
  it 'could encode' do
35
35
  expect(ipv4hint.encode).to eq octet
36
+ expect(ipv4hint.inspect).to eq '192.0.2.1,192.0.2.2'
36
37
  end
37
38
  end
38
39
  end
@@ -5,7 +5,10 @@ require_relative 'spec_helper'
5
5
 
6
6
  RSpec.describe SvcbRrPatch::SvcParams::Ipv6hint do
7
7
  let(:octet) do
8
- "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
8
+ <<-BIN.split.map(&:hex).map(&:chr).join
9
+ 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01
10
+ 20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 02
11
+ BIN
9
12
  end
10
13
 
11
14
  context '#decode' do
@@ -14,20 +17,26 @@ RSpec.describe SvcbRrPatch::SvcParams::Ipv6hint do
14
17
  end
15
18
 
16
19
  it 'could decode' do
17
- expect(ipv6hint.addresses)
18
- .to eq [Resolv::IPv6.create('101:101:101:101:101:101:101:101')]
20
+ expect(ipv6hint.addresses).to eq [
21
+ Resolv::IPv6.create('2001:db8::1'),
22
+ Resolv::IPv6.create('2001:db8::2')
23
+ ]
19
24
  end
20
25
  end
21
26
 
22
27
  context '#encode' do
23
28
  let(:ipv6hint) do
24
29
  SvcbRrPatch::SvcParams::Ipv6hint.new(
25
- [Resolv::IPv6.create('101:101:101:101:101:101:101:101')]
30
+ [
31
+ Resolv::IPv6.create('2001:db8::1'),
32
+ Resolv::IPv6.create('2001:db8::2')
33
+ ]
26
34
  )
27
35
  end
28
36
 
29
37
  it 'could encode' do
30
38
  expect(ipv6hint.encode).to eq octet
39
+ expect(ipv6hint.inspect).to eq '2001:db8::1,2001:db8::2'
31
40
  end
32
41
  end
33
42
  end
@@ -5,7 +5,7 @@ require_relative 'spec_helper'
5
5
 
6
6
  RSpec.describe SvcbRrPatch::SvcParams::Mandatory do
7
7
  let(:octet) do
8
- "\x00\x05\xff\xa4"
8
+ "\x00\x05\x00\x06\xff\xa4"
9
9
  end
10
10
 
11
11
  let(:keys) do
@@ -14,7 +14,7 @@ RSpec.describe SvcbRrPatch::SvcParams::Mandatory do
14
14
  .zip(SvcbRrPatch::SvcParams::PARAMETER_REGISTRY)
15
15
  ].invert
16
16
 
17
- [h['ech'], h['key65444']]
17
+ [h['ech'], h['ipv6hint'], h['key65444']]
18
18
  end
19
19
 
20
20
  context '#decode' do
@@ -34,6 +34,7 @@ RSpec.describe SvcbRrPatch::SvcParams::Mandatory do
34
34
 
35
35
  it 'could encode' do
36
36
  expect(mandatory.encode).to eq octet
37
+ expect(mandatory.inspect).to eq 'ech,ipv6hint,key65444'
37
38
  end
38
39
  end
39
40
  end
@@ -30,6 +30,7 @@ RSpec.describe SvcbRrPatch::SvcParams::NoDefaultAlpn do
30
30
  expect(no_default_alpn)
31
31
  .to be_a(SvcbRrPatch::SvcParams::NoDefaultAlpn)
32
32
  expect(no_default_alpn.encode).to eq octet
33
+ expect(no_default_alpn.inspect).to eq 'h3-29,h3-28,h3-27,h2'
33
34
  end
34
35
  end
35
36
  end
data/spec/port_spec.rb CHANGED
@@ -25,6 +25,7 @@ RSpec.describe SvcbRrPatch::SvcParams::Port do
25
25
 
26
26
  it 'could encode' do
27
27
  expect(port.encode).to eq octet
28
+ expect(port.inspect).to eq '443'
28
29
  end
29
30
  end
30
31
  end
@@ -8,8 +8,8 @@ RSpec.describe SvcbRrPatch::SvcParams do
8
8
  <<-BIN.split.map(&:hex).map(&:chr).join
9
9
  00 01 00 15 05 68 33 2d 32 39 05 68 33 2d 32 38
10
10
  05 68 33 2d 32 37 02 68 32 00 04 00 08 c0 a8 00
11
- 01 c0 a8 00 02 00 06 00 10 01 01 01 01 01 01 01
12
- 01 01 01 01 01 01 01 01 01 ff 35 00 03 01 02 03
11
+ 01 c0 a8 00 02 00 06 00 10 20 01 0d b8 00 00 00
12
+ 00 00 00 00 00 00 00 00 01 ff 35 00 03 01 02 03
13
13
  BIN
14
14
  end
15
15
 
@@ -28,7 +28,7 @@ RSpec.describe SvcbRrPatch::SvcParams do
28
28
 
29
29
  let(:ipv6hint) do
30
30
  SvcbRrPatch::SvcParams::Ipv6hint.new(
31
- [Resolv::IPv6.create('101:101:101:101:101:101:101:101')]
31
+ [Resolv::IPv6.create('2001:db8::1')]
32
32
  )
33
33
  end
34
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svcb_rr_patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekuwayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler