2023-06-28 00:57:37 +02:00
|
|
|
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
|
2023-06-28 01:28:05 +02:00
|
|
|
"ns0.#{domain}.", # Master Name Server for the zone
|
|
|
|
"dnsmaster.#{domain}.", # admin email address
|
2024-11-25 05:13:31 +01:00
|
|
|
2024112500.to_u64, # serial
|
2023-06-28 00:57:37 +02:00
|
|
|
3600.to_u64, # refresh
|
|
|
|
600.to_u64, # retry
|
|
|
|
2419200.to_u64, # expire
|
|
|
|
600.to_u64 # minimum TTL
|
|
|
|
|
2023-06-28 01:28:05 +02:00
|
|
|
# NS: name ttl target
|
2024-11-25 05:13:31 +01:00
|
|
|
zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns0.karchnu.fr."
|
|
|
|
zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns1.karchnu.fr."
|
2023-06-28 00:57:37 +02:00
|
|
|
|
2023-06-28 02:25:43 +02:00
|
|
|
# All default values are read-only (by default).
|
|
|
|
# Still, some dedicated messages can change some of these values, but the default behavior is to protect my SANITY.
|
|
|
|
# DO NOT ALLOW USERS TO MESS WITH IMPORTANT VALUES UNLESS YOU CHECK IT INTENSIVELY.
|
|
|
|
zone.resources.each do |rr|
|
|
|
|
rr.readonly = true
|
|
|
|
end
|
|
|
|
|
2023-06-28 00:57:37 +02:00
|
|
|
File.write("#{domain}.json", zone.to_json)
|