Can compile again.

master
Philippe Pittoli 2023-05-07 17:28:11 +02:00
parent 6ae06ae839
commit bda2a08b4d
4 changed files with 13 additions and 11 deletions

View File

@ -69,22 +69,20 @@ class DNSManager::Service < IPC
reqname = request.class.name.sub /^DNSManager::Request::/, ""
Baguette::Log.debug "<< #{reqname}"
response = DNSManager::Response::Error.new "generic error"
begin
response = request.handle self, event
response = begin
request.handle self, event
rescue e : AuthorizationException
Baguette::Log.error "#{reqname} authorization error"
response = DNSManager::Response::Error.new "authorization error"
Response::Error.new "authorization error"
rescue e : AdminAuthorizationException
Baguette::Log.error "#{reqname} no admin authorization"
response = DNSManager::Response::Error.new "admin authorization error"
Response::Error.new "admin authorization error"
rescue e : NotLoggedException
Baguette::Log.error "#{reqname} user not logged"
response = DNSManager::Response::Error.new "user not logged"
# Do not handle generic exception case: do not provide a response.
# rescue e # Generic case
# Baguette::Log.error "#{reqname} generic error #{e}"
Response::Error.new "user not logged"
rescue e # Generic case
Baguette::Log.error "#{reqname} generic error #{e}"
DNSManager::Response::Error.new "generic error"
end
# If clients sent requests with an “id” field, it is copied

View File

@ -13,7 +13,7 @@ class DNSManager::Request
def initialize(@key, @subject)
end
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event)
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON+
# This request means serious business.
raise AdminAuthorizationException.new if key != dnsmanagerd.authd.key

View File

@ -1,3 +1,4 @@
require "ipc/json"
require "grok"
class DNSManager::Request
@ -9,6 +10,7 @@ class DNSManager::Request
end
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event)
return Response::Success.new
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
dnsmanagerd.storage.add_or_update_zone user.uid, zone
@ -23,6 +25,7 @@ class DNSManager::Request
end
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event)
return Response::Success.new
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
dnsmanagerd.storage.delete_domain user.uid, @domain

View File

@ -108,6 +108,7 @@ class DNSManager::Storage
#unless errors = Storage::Zone.is_domain_valid? domain
# return Response::InvalidZone.new errors
#end
Response::Success.new
rescue e
Baguette::Log.error "trying to delete a domain #{domain}: #{e}"
Response::Error.new "error while deleting the domain #{domain}"