Regenerate Bind9 zone files on any update.
parent
8d9f4051e6
commit
a51fd8b31b
|
@ -71,7 +71,7 @@ class DNSManager::Storage
|
|||
end
|
||||
end
|
||||
|
||||
def generate_zonefile_(domain : String) : Nil
|
||||
def generate_bind9_zonefile(domain : String) : Nil
|
||||
zone = zone_must_exist! domain
|
||||
|
||||
# Safe write.
|
||||
|
@ -89,7 +89,7 @@ class DNSManager::Storage
|
|||
|
||||
# Only an admin can access this function.
|
||||
def generate_zonefile(domain : String) : IPC::JSON
|
||||
generate_zonefile_ domain
|
||||
generate_bind9_zonefile domain
|
||||
Response::Success.new
|
||||
end
|
||||
|
||||
|
@ -97,7 +97,7 @@ class DNSManager::Storage
|
|||
def generate_all_zonefiles() : IPC::JSON
|
||||
Baguette::Log.info "writing all zone files in #{@zonefiledir}/"
|
||||
zones.each do |zone|
|
||||
generate_zonefile_ zone.domain
|
||||
generate_bind9_zonefile zone.domain
|
||||
end
|
||||
Response::Success.new
|
||||
end
|
||||
|
@ -248,6 +248,8 @@ class DNSManager::Storage
|
|||
# Add -or replace- the zone.
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
|
||||
generate_bind9_zonefile zone.domain
|
||||
|
||||
Response::Success.new
|
||||
end
|
||||
|
||||
|
@ -267,14 +269,19 @@ class DNSManager::Storage
|
|||
|
||||
update_zone zone
|
||||
|
||||
generate_bind9_zonefile zone.domain
|
||||
|
||||
Response::RRAdded.new zone.domain, rr
|
||||
end
|
||||
|
||||
# Any modification of the zone must be performed here.
|
||||
# This function updates the SOA serial before storing the modified zone.
|
||||
# Also, this function generate the Bind9 file.
|
||||
def update_zone(zone : Zone)
|
||||
zone.update_serial
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
|
||||
generate_bind9_zonefile zone.domain
|
||||
end
|
||||
|
||||
def update_rr(user_id : UserDataID, domain : String, rr : Zone::ResourceRecord) : IPC::JSON
|
||||
|
@ -319,6 +326,11 @@ class DNSManager::Storage
|
|||
Response::RRDeleted.new rrid
|
||||
end
|
||||
|
||||
# TODO
|
||||
def remove_bind9_zonefile(domain : String)
|
||||
Baguette::Log.info "Removing a Bind9 zone file."
|
||||
end
|
||||
|
||||
def delete_domain(user_id : UserDataID, domain_name : String) : IPC::JSON
|
||||
zone_must_exist! domain_name
|
||||
user_should_own! user_id, domain_name
|
||||
|
@ -343,6 +355,8 @@ class DNSManager::Storage
|
|||
# Remove this domain_name from the list of user's domains.
|
||||
domains_by_name.delete domain_name
|
||||
|
||||
remove_bind9_zonefile domain_name
|
||||
|
||||
Response::DomainDeleted.new domain_name
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue