Can compile again.

This commit is contained in:
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::/, "" reqname = request.class.name.sub /^DNSManager::Request::/, ""
Baguette::Log.debug "<< #{reqname}" Baguette::Log.debug "<< #{reqname}"
response = DNSManager::Response::Error.new "generic error" response = begin
request.handle self, event
begin
response = request.handle self, event
rescue e : AuthorizationException rescue e : AuthorizationException
Baguette::Log.error "#{reqname} authorization error" Baguette::Log.error "#{reqname} authorization error"
response = DNSManager::Response::Error.new "authorization error" Response::Error.new "authorization error"
rescue e : AdminAuthorizationException rescue e : AdminAuthorizationException
Baguette::Log.error "#{reqname} no admin authorization" Baguette::Log.error "#{reqname} no admin authorization"
response = DNSManager::Response::Error.new "admin authorization error" Response::Error.new "admin authorization error"
rescue e : NotLoggedException rescue e : NotLoggedException
Baguette::Log.error "#{reqname} user not logged" Baguette::Log.error "#{reqname} user not logged"
response = DNSManager::Response::Error.new "user not logged" Response::Error.new "user not logged"
# Do not handle generic exception case: do not provide a response. rescue e # Generic case
# rescue e # Generic case Baguette::Log.error "#{reqname} generic error #{e}"
# Baguette::Log.error "#{reqname} generic error #{e}" DNSManager::Response::Error.new "generic error"
end end
# If clients sent requests with an “id” field, it is copied # If clients sent requests with an “id” field, it is copied

View File

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

View File

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

View File

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