RRs now have an id.
parent
346d979e03
commit
05aa4421b3
|
@ -6,6 +6,7 @@ class DNSManager::Storage::Zone
|
|||
|
||||
property domain : String
|
||||
property resources = [] of DNSManager::Storage::Zone::ResourceRecord
|
||||
property current_rrid : UInt32 = 0
|
||||
|
||||
# We don't want to accept less than 30 seconds TTL.
|
||||
class_property ttl_limit_min = 30
|
||||
|
@ -34,6 +35,7 @@ class DNSManager::Storage::Zone
|
|||
# Used to discriminate between classes.
|
||||
property rrtype : String = ""
|
||||
|
||||
property rrid : UInt32 = 0
|
||||
property name : String
|
||||
property ttl : UInt32
|
||||
property target : String
|
||||
|
@ -275,6 +277,12 @@ class DNSManager::Storage::Zone
|
|||
end
|
||||
end
|
||||
|
||||
def <<(rr : ResourceRecord)
|
||||
rr.rrid = current_rrid
|
||||
@resources << rr
|
||||
@current_rrid += 1
|
||||
end
|
||||
|
||||
def to_s(io : IO)
|
||||
io << "domain: #{@domain}\n"
|
||||
@resources.each do |rr|
|
||||
|
|
|
@ -19,23 +19,23 @@ zone = DSZ.new domain
|
|||
# Add some values.
|
||||
#
|
||||
|
||||
zone.resources << DSZ::SOA.new "#{domain}.", # name
|
||||
zone << 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::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::A.new "mail", 300.to_u32, "10.0.0.10"
|
||||
zone << DSZ::A.new "www", 600.to_u32, "10.0.0.1"
|
||||
zone << DSZ::A.new "www2", 600.to_u32, "10.0.0.2"
|
||||
zone << DSZ::A.new "mail", 300.to_u32, "10.0.0.10"
|
||||
|
||||
zone.resources << DSZ::CNAME.new "mail2", 600.to_u32, "www"
|
||||
zone << DSZ::CNAME.new "mail2", 600.to_u32, "www"
|
||||
|
||||
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."
|
||||
zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns1.some-example.com."
|
||||
zone << DSZ::NS.new "#{domain}.", 3600.to_u32, "ns0.some-example.com."
|
||||
|
||||
zone.resources << DSZ::MX.new "mail", 300.to_u32, "mail", 10
|
||||
zone.resources << DSZ::MX.new "mail", 300.to_u32, "mail2", 5
|
||||
zone << DSZ::MX.new "mail", 300.to_u32, "mail", 10
|
||||
zone << DSZ::MX.new "mail", 300.to_u32, "mail2", 5
|
||||
|
||||
|
||||
File.write("#{domain}.json", zone.to_json)
|
||||
|
|
Loading…
Reference in New Issue