Can compile again.
parent
6ae06ae839
commit
bda2a08b4d
18
src/main.cr
18
src/main.cr
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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}"
|
||||||
|
|
Loading…
Reference in New Issue