diff --git a/src/storage/zone.cr b/src/storage/zone.cr index 7af19f7..4a6ef10 100644 --- a/src/storage/zone.cr +++ b/src/storage/zone.cr @@ -52,6 +52,7 @@ class DNSManager::Storage::Zone NS: NS, CNAME: CNAME, MX: MX, + CAA: CAA, SRV: SRV, # Special resource records, which actually are TXT records. @@ -721,6 +722,64 @@ class DNSManager::Storage::Zone end end + class CAA < ResourceRecord + def_clone + + enum Tag + ISSUE + ISSUEWILD + IODEF + CONTACTEMAIL + CONTACTPHONE + end + + class CAAProperties + include JSON::Serializable + + property flag : UInt8 = 0 + property tag : Tag = Tag::ISSUE + property value : String = "" + + def_clone + + def initialize(@flag, @tag, @value) + end + end + + property caa : CAAProperties + + def initialize(@name, @ttl, @target, flag, tag, value) + @rrtype = "CAA" + @caa = CAAProperties.new flag, tag, value + end + + def to_s(io : IO) + io << "(#{ "%4d" % @rrid }) " + io << "#{ "%30s" % @name} #{ "%6d" % @ttl} CAA " + io << "#{ "%3s" % @caa.flag} #{ "%15s" % @caa.tag} #{@caa.value}\n" + end + + def to_bind9(io : IO) + io << "#{@name} #{@ttl} IN CAA #{@caa.flag} #{@caa.tag.to_s.downcase} #{@caa.value}\n" + end + + def get_errors : Array(Error) + errors = [] of Error + + unless Zone.is_subdomain_valid? @name + errors << "CAA invalid subdomain: #{@name}" + end + + if @ttl < Zone.ttl_limit_min + errors << "CAA invalid ttl: #{@ttl}, shouldn't be less than #{Zone.ttl_limit_min}" + end + + # TODO: rest of the errors. + + errors + end + end + class MX < ResourceRecord def_clone property priority : UInt32 = 10