class Net::DNS::RR::HINFO
System Information Record (HINFO
)¶ ↑
Class for DNS
HINFO
resource records.
Allows definition of the Hardware type and Operating System (OS) in use at a host. For security reasons these records are rarely used on public servers. If a space exists in the field it must be enclosed in quotes. Single space between CPU and OS parameters.
Attributes
cpu[R]
Gets the CPU value.
Returns a String.
os[R]
Gets the OS value.
Returns a String.
Public Instance Methods
to_a()
click to toggle source
Gets a list of all the attributes for this record.
Returns an Array of values.
# File lib/net/dns/rr/hinfo.rb, line 36 def to_a [nil, nil, cls.to_s, type.to_s, value] end
value()
click to toggle source
Gets the standardized value for this record, represented by the value of cpu
and os
.
Returns a String.
# File lib/net/dns/rr/hinfo.rb, line 29 def value %Q("#{cpu}" "#{os}") end
Private Instance Methods
build_pack()
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 83 def build_pack @hinfo_pack = "" @hinfo_pack += [cpu.size].pack("C") + cpu @hinfo_pack += [os.size].pack("C") + os @rdlength = @hinfo_pack.size end
check_hinfo(input)
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 75 def check_hinfo(input) if input.to_s.strip =~ /^(?:["']?(.*?)["']?)\s+(?:["']?(.*?)["']?)$/ [Regexp.last_match(1), Regexp.last_match(2)] else raise ArgumentError, "Invalid HINFO Section `#{input}'" end end
get_data()
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 90 def get_data @hinfo_pack end
get_inspect()
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 71 def get_inspect value end
set_type()
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 67 def set_type @type = Net::DNS::RR::Types.new("HINFO") end
subclass_new_from_binary(data, offset)
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 55 def subclass_new_from_binary(data, offset) len = data.unpack("@#{offset} C").first offset += 1 @cpu = data[offset..(offset + len)] offset += len len = data.unpack("@#{offset} C").first offset += 1 @os = data[offset..(offset + len)] offset += len end
subclass_new_from_hash(options)
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 42 def subclass_new_from_hash(options) if options.key?(:cpu) && options.key?(:os) @cpu = options[:cpu] @os = options[:os] else raise ArgumentError, ":cpu and :os fields are mandatory" end end
subclass_new_from_string(str)
click to toggle source
# File lib/net/dns/rr/hinfo.rb, line 51 def subclass_new_from_string(str) @cpu, @os = check_hinfo(str) end