Class: Resolv::DNS::Resource::IN::ServiceBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/resolv.rb

Overview

Common implementation for SVCB-compatible resource records.

Direct Known Subclasses

HTTPS, SVCB

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(priority, target, params = []) ⇒ ServiceBinding

Create a service binding resource record.



2851
2852
2853
2854
2855
# File 'lib/resolv.rb', line 2851

def initialize(priority, target, params = [])
  @priority = priority.to_int
  @target = Name.create(target)
  @params = SvcParams.new(params)
end

Instance Attribute Details

#paramsObject (readonly)

The service parameters for the target host.



2873
2874
2875
# File 'lib/resolv.rb', line 2873

def params
  @params
end

#priorityObject (readonly)

The priority of this target host.

The range is 0-65535. If set to 0, this RR is in AliasMode. Otherwise, it is in ServiceMode.



2863
2864
2865
# File 'lib/resolv.rb', line 2863

def priority
  @priority
end

#targetObject (readonly)

The domain name of the target host.



2868
2869
2870
# File 'lib/resolv.rb', line 2868

def target
  @target
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:



2895
2896
2897
2898
2899
2900
# File 'lib/resolv.rb', line 2895

def self.decode_rdata(msg) # :nodoc:
  priority, = msg.get_unpack("n")
  target    = msg.get_name
  params    = SvcParams.decode(msg)
  return self.new(priority, target, params)
end

Instance Method Details

#alias_mode?Boolean

Whether this RR is in AliasMode.

Returns:

  • (Boolean)


2878
2879
2880
# File 'lib/resolv.rb', line 2878

def alias_mode?
  self.priority == 0
end

#encode_rdata(msg) ⇒ Object

:nodoc:



2889
2890
2891
2892
2893
# File 'lib/resolv.rb', line 2889

def encode_rdata(msg) # :nodoc:
  msg.put_pack("n", @priority)
  msg.put_name(@target, compress: false)
  @params.encode(msg)
end

#service_mode?Boolean

Whether this RR is in ServiceMode.

Returns:

  • (Boolean)


2885
2886
2887
# File 'lib/resolv.rb', line 2885

def service_mode?
  !alias_mode?
end