From 009928a8eea0867283a14f76f11981cd053362e2 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 9 Nov 2024 16:37:08 +0100 Subject: [PATCH] SRV protocols aren't just plain text anymore. --- src/storage/zone.cr | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/storage/zone.cr b/src/storage/zone.cr index f44f9ab..35876b3 100644 --- a/src/storage/zone.cr +++ b/src/storage/zone.cr @@ -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