CAA entries.

dev
Philippe PITTOLI 2024-06-08 03:55:52 +02:00
parent 5cbcbdaa8f
commit b53b31b584
1 changed files with 59 additions and 0 deletions

View File

@ -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