Class: Dnsruby::RR::SSHFP

Inherits:
Dnsruby::RR show all
Defined in:
lib/dnsruby/resource/SSHFP.rb

Defined Under Namespace

Classes: Algorithms, FpTypes

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::SSHFP

Constants inherited from Dnsruby::RR

ClassInsensitiveTypes

Instance Attribute Summary collapse

Attributes inherited from Dnsruby::RR

#klass, #name, #rdata, #ttl, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dnsruby::RR

#<=>, #==, #clone, create, #eql?, find_class, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s

Instance Attribute Details

#algObject

Returns the value of attribute alg.



22
23
24
# File 'lib/dnsruby/resource/SSHFP.rb', line 22

def alg
  @alg
end

#fpObject

Returns the value of attribute fp.



24
25
26
# File 'lib/dnsruby/resource/SSHFP.rb', line 24

def fp
  @fp
end

#fptypeObject

Returns the value of attribute fptype.



23
24
25
# File 'lib/dnsruby/resource/SSHFP.rb', line 23

def fptype
  @fptype
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



88
89
90
91
92
# File 'lib/dnsruby/resource/SSHFP.rb', line 88

def self.decode_rdata(msg) #:nodoc: all
  alg, fptype = msg.get_unpack("cc")
  fp = msg.get_bytes
  return self.new([alg, fptype, fp])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



82
83
84
85
86
# File 'lib/dnsruby/resource/SSHFP.rb', line 82

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_pack("c", @alg.code)
  msg.put_pack("c", @fptype.code)
  msg.put_bytes(@fp)
end

#from_data(data) ⇒ Object

:nodoc: all



37
38
39
40
41
# File 'lib/dnsruby/resource/SSHFP.rb', line 37

def from_data(data) #:nodoc: all
  alg, fptype, @fp = data
  @alg = Algorithms.new(alg)
  @fptype = FpTypes.new(fptype)
end

#from_hash(hash) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dnsruby/resource/SSHFP.rb', line 43

def from_hash(hash)
  if hash[:alg]
    @alg = Algorithms.new(hash[:alg])
  end
  if hash[:fptype]
    @fptype = FpTypes.new(hash[:fptype])
  end
  if hash[:fp]
    @fp = hash[:fp]
  end
end

#from_string(input) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/dnsruby/resource/SSHFP.rb', line 55

def from_string(input)
  if (input.length > 0)
    names = input.split(" ")
    begin
      @alg = Algorithms.new(names[0].to_i)
    rescue ArgumentError
      @alg = Algorithms.new(names[0])
    end
    begin
      @fptype = FpTypes.new(names[1].to_i)
    rescue ArgumentError
      @fptype = FpTypes.new(names[1])
    end
    remaining = ""
    for i in 2..(names.length + 1)
      remaining += names[i].to_s
    end
    @fp = [remaining].pack("H*")
  end
end

#rdata_to_stringObject



76
77
78
79
80
# File 'lib/dnsruby/resource/SSHFP.rb', line 76

def rdata_to_string
  ret = "#{@alg.code} #{@fptype.code} "
  ret += @fp.unpack("H*")[0]
  return ret
end