Class: Dnsruby::RR::CAA

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

Overview

Class for CAA resource records. RFC 6844

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::CAA

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

#flagObject



41
42
43
# File 'lib/dnsruby/resource/CAA.rb', line 41

def flag
  @flag.to_i
end

#property_tagObject

The property tag for the record (issue|issuewild|iodef)



25
26
27
# File 'lib/dnsruby/resource/CAA.rb', line 25

def property_tag
  @property_tag
end

#property_valueObject

The value for the property_tag



27
28
29
# File 'lib/dnsruby/resource/CAA.rb', line 27

def property_value
  @property_value
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



63
64
65
66
67
68
69
# File 'lib/dnsruby/resource/CAA.rb', line 63

def self.decode_rdata(msg) #:nodoc: all
  flag, = msg.get_unpack('C')
  property_tag = msg.get_string
  # The final string has no length byte - its length is implicit as the remainder of the packet length
  property_value = msg.get_bytes
  return self.new("#{flag} #{property_tag} \"#{property_value}\"")
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



56
57
58
59
60
61
# File 'lib/dnsruby/resource/CAA.rb', line 56

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_pack('C', flag)
  msg.put_string(@property_tag)
  # We don't put a length byte on the final string.
  msg.put_bytes(@property_value)
end

#from_data(data) ⇒ Object

:nodoc: all



37
38
39
# File 'lib/dnsruby/resource/CAA.rb', line 37

def from_data(data) #:nodoc: all
  @flag, @property_tag, @property_value = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



31
32
33
34
35
# File 'lib/dnsruby/resource/CAA.rb', line 31

def from_hash(hash) #:nodoc: all
  @property_tag = hash[:property_tag]
  @property_value = hash[:property_value]
  @flag = hash[:flag]
end

#from_string(input) ⇒ Object

:nodoc: all



45
46
47
48
49
50
# File 'lib/dnsruby/resource/CAA.rb', line 45

def from_string(input) #:nodoc: all
  matches = (/(\d+) (issuewild|issue|iodef|contactemail|contactphone) "(.+)"$/).match(input)
  @flag = matches[1]
  @property_tag = matches[2]
  @property_value = matches[3]
end

#rdata_to_stringObject

:nodoc: all



52
53
54
# File 'lib/dnsruby/resource/CAA.rb', line 52

def rdata_to_string #:nodoc: all
  "#{flag} #{@property_tag} \"#{@property_value}\""
end