Add tool to write zone file (in JSON).
This commit is contained in:
parent
41828a3f91
commit
ad83a34437
35
tools/write-zone-file.cr
Normal file
35
tools/write-zone-file.cr
Normal file
@ -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.resources << DSZ::A.new "www", 600.to_u32, "10.0.0.1"
|
||||||
|
zone.resources << DSZ::A.new "www2", 600.to_u32, "10.0.0.2"
|
||||||
|
|
||||||
|
zone.resources << DSZ::SOA.new "#{domain}.", # name
|
||||||
|
60.to_u32, # TTL
|
||||||
|
"IN", # target (??)
|
||||||
|
"ns0.some-example.com.", # Master Name Server for the zone
|
||||||
|
"john\.doe.#{domain}" # admin email address
|
||||||
|
|
||||||
|
zone.resources << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns1.some-example.com."
|
||||||
|
zone.resources << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns0.some-example.com."
|
||||||
|
|
||||||
|
|
||||||
|
File.write("#{domain}.json", zone.to_json)
|
Loading…
Reference in New Issue
Block a user