Properly handle multiple lines targets (TXT, DKIM).
This commit is contained in:
parent
8bef46803e
commit
407cfc874a
@ -212,6 +212,15 @@ class DNSManager::Storage::Zone
|
|||||||
|
|
||||||
errors
|
errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s(io : IO)
|
||||||
|
io << "(#{ "%4d" % @rrid }) "
|
||||||
|
io << "#{ "%30s" % @name} #{ "%6d" % @ttl} #{ "%10s" % @rrtype } #{quoted_string @target}\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_bind9(io : IO)
|
||||||
|
io << "#{@name} #{@ttl} IN #{@rrtype} #{split_line @target}\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class PTR < ResourceRecord
|
class PTR < ResourceRecord
|
||||||
@ -523,17 +532,11 @@ class DNSManager::Storage::Zone
|
|||||||
|
|
||||||
def to_s(io : IO)
|
def to_s(io : IO)
|
||||||
io << "(#{ "%4d" % @rrid }) "
|
io << "(#{ "%4d" % @rrid }) "
|
||||||
io << "#{ "%30s" % @name} #{ "%6d" % @ttl} DKIM "
|
io << "#{ "%30s" % @name} #{ "%6d" % @ttl} DKIM #{split_line dkim.to_s}\n"
|
||||||
io << "( "
|
|
||||||
io << split_line dkim.to_s
|
|
||||||
io << " )\n"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_bind9(io : IO)
|
def to_bind9(io : IO)
|
||||||
io << "#{@name} #{@ttl} IN TXT "
|
io << "#{@name} #{@ttl} IN TXT #{split_line dkim.to_s}\n"
|
||||||
io << "( "
|
|
||||||
io << split_line dkim.to_s
|
|
||||||
io << " )\n"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -832,16 +835,30 @@ def qualifier_to_string(qualifier : DNSManager::Storage::Zone::SPF::Qualifier) :
|
|||||||
end
|
end
|
||||||
|
|
||||||
def split_line(line : String) : String
|
def split_line(line : String) : String
|
||||||
|
max_char_per_line = 50
|
||||||
|
|
||||||
iostr = IO::Memory.new line
|
iostr = IO::Memory.new line
|
||||||
slice = Bytes.new(50)
|
slice = Bytes.new(max_char_per_line)
|
||||||
lines = ""
|
lines = ""
|
||||||
|
first_time = true
|
||||||
while rbytes = iostr.read slice
|
while rbytes = iostr.read slice
|
||||||
break if rbytes == 0
|
break if rbytes == 0
|
||||||
lines += '"'
|
if first_time
|
||||||
lines += String.new slice[0..rbytes -1]
|
first_time = false
|
||||||
lines += '"'
|
else
|
||||||
lines += "\n\t"
|
lines += "\n\t"
|
||||||
end
|
end
|
||||||
|
lines += quoted_string (String.new slice[0..rbytes -1])
|
||||||
|
end
|
||||||
|
|
||||||
|
lines = "( #{lines} )" if lines.size > max_char_per_line
|
||||||
lines
|
lines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quoted_string(value : String) : String
|
||||||
|
String.build do |io|
|
||||||
|
io << '"'
|
||||||
|
io << value
|
||||||
|
io << '"'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user