Class: Resolv::DNS::Resource::IN::SVCB

Inherits:
Resolv::DNS::Resource
  • Object
show all
Defined in:
lib/svcb_rr_patch/svcb.rb

Overview

The SVCB(contraction of “service binding”) DNS Resource Record

Direct Known Subclasses

HTTPS

Constant Summary collapse

TypeValue =

rubocop: disable Naming/ConstantName

64
ClassValue =
IN::ClassValue

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(svc_priority, target_name, svc_params) ⇒ SVCB

rubocop: disable Lint/MissingSuper

Parameters:

  • svc_priority (Integer)
  • target_name (String)
  • svc_params (Hash)


15
16
17
18
19
20
# File 'lib/svcb_rr_patch/svcb.rb', line 15

def initialize(svc_priority, target_name, svc_params)
  # https://www.ietf.org/archive/id/draft-ietf-dnsop-svcb-https-06.html
  @svc_priority = svc_priority
  @target_name = target_name
  @svc_params = svc_params
end

Instance Attribute Details

#svc_paramsObject (readonly)

SvcPriority



26
27
28
# File 'lib/svcb_rr_patch/svcb.rb', line 26

def svc_params
  @svc_params
end

#svc_priorityObject (readonly)

SvcPriority



26
27
28
# File 'lib/svcb_rr_patch/svcb.rb', line 26

def svc_priority
  @svc_priority
end

#target_nameObject (readonly)

SvcPriority



26
27
28
# File 'lib/svcb_rr_patch/svcb.rb', line 26

def target_name
  @target_name
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:



43
44
45
46
47
48
49
50
51
# File 'lib/svcb_rr_patch/svcb.rb', line 43

def decode_rdata(msg)
  svc_priority = msg.get_bytes(2).unpack1('n')
  target_name = msg.get_string
  return new(svc_priority, target_name, {}) if svc_priority.zero?

  # the SvcParams, consuming the remainder of the record
  svc_params = ::SvcbRrPatch::SvcParams::Hash.decode(msg.get_bytes)
  new(svc_priority, target_name, svc_params)
end

Instance Method Details

#encode_rdata(msg) ⇒ Object

:nodoc:



35
36
37
38
39
# File 'lib/svcb_rr_patch/svcb.rb', line 35

def encode_rdata(msg)
  msg.put_bytes([@svc_priority].pack('n'))
  msg.put_string(@target_name)
  msg.put_string(@svc_params.encode)
end