SRV protocols aren't just plain text anymore.

This commit is contained in:
Philippe Pittoli 2024-11-09 16:37:08 +01:00
parent 38da24fe66
commit 009928a8ee

View File

@ -828,11 +828,17 @@ class DNSManager::Storage::Zone
class SRV < ResourceRecord
def_clone
enum Protocol
TCP
UDP
end
property port : UInt16
property protocol : String = "tcp"
property protocol : Protocol
property priority : UInt32 = 10
property weight : UInt32 = 10
def initialize(@name, @ttl, @target, @port, @protocol = "tcp", @priority = 10, @weight = 10)
def initialize(@name, @ttl, @target, @port, @protocol = Protocol::TCP, @priority = 10, @weight = 10)
@rrtype = "SRV"
end
@ -855,7 +861,7 @@ class DNSManager::Storage::Zone
def to_s(io : IO)
io << "(#{ "%4d" % @rrid }) "
io << "_#{@name.downcase}._#{@protocol.downcase} "
io << "_#{@name.downcase}._#{@protocol.to_s.downcase} "
io << "#{ "%6d" % @ttl} SRV "
io << "#{ "%3d" % @priority} "
io << "#{ "%3d" % @weight} "
@ -864,7 +870,7 @@ class DNSManager::Storage::Zone
end
def to_bind9(io : IO)
io << "_#{@name.downcase}._#{@protocol.downcase} "
io << "_#{@name.downcase}._#{@protocol.to_s.downcase} "
io << "#{@ttl} IN SRV #{@priority} #{@weight} #{@port} #{@target}\n"
end
end