2024-02-29 04:52:54 +01:00
|
|
|
require "../src/storage.cr"
|
2020-12-09 23:40:24 +01:00
|
|
|
|
|
|
|
alias DSZ = DNSManager::Storage::Zone
|
|
|
|
|
|
|
|
storage = DNSManager::Storage.new "STORAGE"
|
|
|
|
|
|
|
|
user_data = DNSManager::Storage::UserData.new 1004
|
|
|
|
storage.user_data << user_data rescue nil
|
|
|
|
|
2024-02-29 04:52:54 +01:00
|
|
|
domain = "test.example.com"
|
|
|
|
zone = DSZ.new domain
|
2020-12-09 23:40:24 +01:00
|
|
|
|
|
|
|
a_record = DSZ::A.new "www", 600.to_u32, "127.0.0.1"
|
|
|
|
aaaa_record = DSZ::AAAA.new "www", 600.to_u32, "::1"
|
|
|
|
mx_record = DSZ::MX.new "mail", 600.to_u32, "127.0.0.1", 5.to_u32
|
2024-02-29 04:52:54 +01:00
|
|
|
spf_record = DSZ::SPF.new "test.example.com.", 600.to_u32, "target", "spf2lol",
|
|
|
|
([] of DSZ::SPF::Mechanism), DSZ::SPF::Qualifier::SoftFail
|
2020-12-09 23:40:24 +01:00
|
|
|
|
|
|
|
zone.resources << a_record
|
|
|
|
zone.resources << aaaa_record
|
|
|
|
zone.resources << mx_record
|
2024-02-29 04:52:54 +01:00
|
|
|
zone.resources << spf_record
|
2020-12-09 23:40:24 +01:00
|
|
|
|
2024-02-29 04:52:54 +01:00
|
|
|
# Add the new domain to the user.
|
|
|
|
user_data.domains << domain
|
|
|
|
storage.update_user_data user_data
|
|
|
|
|
|
|
|
# Add the new zone in the database.
|
|
|
|
storage.zones_by_domain.update_or_create domain, zone
|
2020-12-09 23:40:24 +01:00
|
|
|
|
|
|
|
pp! storage.user_data
|
|
|
|
puts "Zones !!!"
|
|
|
|
pp! storage.zones
|
|
|
|
storage.zones.to_a.each do |z|
|
|
|
|
pp! z
|
|
|
|
end
|
|
|
|
|