Automatically update the SOA serial.
This commit is contained in:
parent
62199f27e3
commit
26d01a0b63
@ -221,8 +221,7 @@ class DNSManager::Storage
|
||||
|
||||
zone << rr
|
||||
|
||||
# Update the zone.
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
update_zone zone
|
||||
|
||||
Response::RRAdded.new zone.domain, rr
|
||||
rescue e
|
||||
@ -230,6 +229,13 @@ class DNSManager::Storage
|
||||
Response::Error.new "error while adding a resource record in domain #{domain}"
|
||||
end
|
||||
|
||||
# Any modification of the zone must be performed here.
|
||||
# This function updates the SOA serial before storing the modified zone.
|
||||
def update_zone(zone : Zone)
|
||||
zone.update_serial
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
end
|
||||
|
||||
def update_rr(user_id : Int32, domain : String, rr : Zone::ResourceRecord) : IPC::JSON
|
||||
# User must exist.
|
||||
user_data = user_data_by_uid.get? user_id.to_s
|
||||
@ -269,8 +275,7 @@ class DNSManager::Storage
|
||||
|
||||
zone.resources = zone.resources.map { |x| x.rrid == rr.rrid ? rr : x }
|
||||
|
||||
# Update the zone.
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
update_zone zone
|
||||
|
||||
Response::RRUpdated.new domain, rr
|
||||
rescue e
|
||||
@ -298,8 +303,7 @@ class DNSManager::Storage
|
||||
|
||||
zone.resources.select! { |x| x.rrid != rrid }
|
||||
|
||||
# Update the zone.
|
||||
zones_by_domain.update_or_create zone.domain, zone
|
||||
update_zone zone
|
||||
|
||||
Response::RRDeleted.new rrid
|
||||
rescue e
|
||||
|
@ -594,6 +594,15 @@ class DNSManager::Storage::Zone
|
||||
end
|
||||
end
|
||||
|
||||
def update_serial
|
||||
@resources.each do |rr|
|
||||
case rr
|
||||
when SOA
|
||||
rr.serial += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_errors? : Array(Error)?
|
||||
errors = [] of Error
|
||||
unless Zone.is_domain_valid? @domain
|
||||
|
Loading…
Reference in New Issue
Block a user