RRUpdated + RRReadOnly.
This commit is contained in:
parent
9be374b492
commit
203c6aed54
@ -86,5 +86,21 @@ class DNSManager::Response
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
DNSManager.responses << InvalidRR
|
DNSManager.responses << InvalidRR
|
||||||
|
|
||||||
|
IPC::JSON.message RRUpdated, 21 do
|
||||||
|
property domain : String
|
||||||
|
property rr : Storage::Zone::ResourceRecord
|
||||||
|
def initialize(@domain, @rr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
DNSManager.responses << RRUpdated
|
||||||
|
|
||||||
|
IPC::JSON.message RRReadOnly, 22 do
|
||||||
|
property domain : String
|
||||||
|
property rr : Storage::Zone::ResourceRecord
|
||||||
|
def initialize(@domain, @rr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
DNSManager.responses << RRReadOnly
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -205,19 +205,23 @@ class DNSManager::Storage
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: verify that this rr.rrid isn't ReadOnly.
|
stored_rrs = zone.resources.select { |x| x.rrid == rr.rrid }
|
||||||
stored_rr = zone.resources.select { |x| x.rrid == rr.rrid }
|
unless stored_rrs.size > 0
|
||||||
unless stored_rr.size > 0
|
|
||||||
Baguette::Log.warning "modifying a RR that doesn't exist (#{rr.rrid}) in domain #{domain}"
|
Baguette::Log.warning "modifying a RR that doesn't exist (#{rr.rrid}) in domain #{domain}"
|
||||||
return Response::RRNotFound.new
|
return Response::RRNotFound.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Verify that this resource isn't ReadOnly.
|
||||||
|
stored_rrs.each do |stored_rr|
|
||||||
|
return Response::RRReadOnly.new domain, rr if stored_rr.readonly
|
||||||
|
end
|
||||||
|
|
||||||
zone.resources = zone.resources.map { |x| x.rrid == rr.rrid ? rr : x }
|
zone.resources = zone.resources.map { |x| x.rrid == rr.rrid ? rr : x }
|
||||||
|
|
||||||
# Update the zone.
|
# Update the zone.
|
||||||
zones_by_domain.update_or_create zone.domain, zone
|
zones_by_domain.update_or_create zone.domain, zone
|
||||||
|
|
||||||
Response::Success.new
|
Response::RRUpdated.new domain, rr
|
||||||
rescue e
|
rescue e
|
||||||
Baguette::Log.error "trying to replace a resource record in domain #{domain}: #{e}"
|
Baguette::Log.error "trying to replace a resource record in domain #{domain}: #{e}"
|
||||||
Response::Error.new "error while replacing a resource record in domain #{domain}"
|
Response::Error.new "error while replacing a resource record in domain #{domain}"
|
||||||
|
Loading…
Reference in New Issue
Block a user