From 316fa6a0b7e2418ef1c0d0a097ee60ceaa812ddb Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Wed, 28 Jun 2023 00:57:37 +0200 Subject: [PATCH] New tool: write a (basic) template zone. --- tools/write-template-zone-file.cr | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tools/write-template-zone-file.cr diff --git a/tools/write-template-zone-file.cr b/tools/write-template-zone-file.cr new file mode 100644 index 0000000..a050e79 --- /dev/null +++ b/tools/write-template-zone-file.cr @@ -0,0 +1,35 @@ +require "json" +require "../src/storage/zone.cr" + +alias DSZ = DNSManager::Storage::Zone + +# +# Create a zone file. +# + +if ARGV.size < 1 + puts "usage: domain" + exit 0 +end + +domain = ARGV[0] +zone = DSZ.new domain + +# +# Add some values. +# + +zone << DSZ::SOA.new "#{domain}.", # name + 3600.to_u32, # TTL + "ns0.arn-fai.net.", # Master Name Server for the zone + "dnsmaster.arn-fai.net.", # admin email address + 2023070100.to_u64, # serial + 3600.to_u64, # refresh + 600.to_u64, # retry + 2419200.to_u64, # expire + 600.to_u64 # minimum TTL + +zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns0.arn-fai.net." +zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "alsace.tetaneutral.net." + +File.write("#{domain}.json", zone.to_json)