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.



3037
3038
3039
3040
3041
# File 'lib/resolv.rb', line 3037

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

Instance Attribute Details

#params ⇒ Object (readonly)

The service parameters for the target host.



3059
3060
3061
# File 'lib/resolv.rb', line 3059

def params
  @params
end

#priority ⇒ Object (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.



3049
3050
3051
# File 'lib/resolv.rb', line 3049

def priority
  @priority
end

#target ⇒ Object (readonly)

The domain name of the target host.



3054
3055
3056
# File 'lib/resolv.rb', line 3054

def target
  @target
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:



3081
3082
3083
3084
3085
3086
# File 'lib/resolv.rb', line 3081

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)


3064
3065
3066
# File 'lib/resolv.rb', line 3064

def alias_mode?
  self.priority == 0
end

#encode_rdata(msg) ⇒ Object

:nodoc:



3075
3076
3077
3078
3079
# File 'lib/resolv.rb', line 3075

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)


3071
3072
3073
# File 'lib/resolv.rb', line 3071

def service_mode?
  !alias_mode?
end