Class: SvcbRrPatch::SvcParams::Ech

Inherits:
Object
  • Object
show all
Defined in:
lib/svcb_rr_patch/svc_params/ech.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(echconfiglist) ⇒ Ech



7
8
9
# File 'lib/svcb_rr_patch/svc_params/ech.rb', line 7

def initialize(echconfiglist)
  @echconfiglist = echconfiglist
end

Instance Attribute Details

#echconfiglistObject (readonly)

Returns the value of attribute echconfiglist.



4
5
6
# File 'lib/svcb_rr_patch/svc_params/ech.rb', line 4

def echconfiglist
  @echconfiglist
end

Class Method Details

.decode(octet) ⇒ Object

:nodoc:

Raises:

  • (::Resolv::DNS::DecodeError)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/svcb_rr_patch/svc_params/ech.rb', line 17

def self.decode(octet)
  raise ::Resolv::DNS::DecodeError \
    unless octet.length == octet.slice(0, 2).unpack1('n') + 2

  begin
    echconfiglist = ::ECHConfig.decode_vectors(octet.slice(2..))
  rescue ::ECHConfig::Error
    raise ::Resolv::DNS::DecodeError
  end

  new(echconfiglist)
end

Instance Method Details

#encodeString



12
13
14
# File 'lib/svcb_rr_patch/svc_params/ech.rb', line 12

def encode
  @echconfiglist.map(&:encode).join.then { |s| [s.length].pack('n') + s }
end

#to_sObject

www.ietf.org/archive/id/draft-ietf-dnsop-svcb-https-06.html#section-9 In presentation format, the value is a single ECHConfigList encoded in Base64.



33
34
35
# File 'lib/svcb_rr_patch/svc_params/ech.rb', line 33

def to_s
  Base64.strict_encode64(encode)
end