s/Maintainance/Maintenance/ + secret auth key fixed (client).

master
Philippe Pittoli 2023-05-06 23:18:59 +02:00
parent e7d8e2aa99
commit 8c0257649d
4 changed files with 21 additions and 22 deletions

View File

@ -43,8 +43,8 @@ class DNSManager::Client < IPC
# Admin stuff.
#
def admin_maintainance(key : String, subject : DNSManager::Request::Maintainance::Subject, value : Int32? = nil)
request = DNSManager::Request::Maintainance.new(key,subject)
def admin_maintenance(key : String, subject : DNSManager::Request::Maintenance::Subject, value : Int32? = nil)
request = DNSManager::Request::Maintenance.new(key,subject)
if value
request.value = value
end

View File

@ -27,21 +27,21 @@ class Actions
property dnsmanagerd : DNSManager::Client
#property authd : AuthD::Client
#property authd_config : Baguette::Configuration::Auth
property authd_key : String?
property authd_key : String? = nil
property config : Baguette::Configuration::DNSManager
def initialize(@dnsmanagerd, @config, @authd_key)
def initialize(@dnsmanagerd, @config, @authd_key = nil)
#
# Admin section.
#
# Maintainance
@the_call["admin-maintainance"] = ->admin_maintainance
# Maintenance
@the_call["admin-maintenance"] = ->admin_maintenance
@the_call["user-zone-add"] = ->user_zone_add
@the_call["user-zone-del"] = ->user_zone_del
end
def admin_maintainance
def admin_maintenance
subjects = Context.args.not_nil!
past_is_verbosity = false
subjects.each do |subject|
@ -54,17 +54,16 @@ class Actions
end
if past_is_verbosity
sub = DNSManager::Request::Maintainance::Subject::Verbosity
sub = DNSManager::Request::Maintenance::Subject::Verbosity
value = subject.to_i
pp! sub, value
pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub, value
@dnsmanagerd.admin_maintenance authd_key.not_nil!, sub, value
else
sub = DNSManager::Request::Maintainance::Subject.parse(subject)
sub = DNSManager::Request::Maintenance::Subject.parse(subject)
pp! sub
pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub
pp! @dnsmanagerd.admin_maintenance authd_key.not_nil!, sub
end
rescue e
puts "error for admin_maintainance #{subject}: #{e.message}"
puts "error for admin_maintenance #{subject}: #{e.message}"
end
end
end
@ -147,7 +146,7 @@ def main
end
#authd = AuthD::Client.new
actions = Actions.new dnsmanagerd, config, authd_config.pass
actions = Actions.new dnsmanagerd, config, authd_config.shared_key
# Now we did read the intent, we should proceed doing what was asked.
begin

View File

@ -40,10 +40,10 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
puts parser
case Context.command
when /admin-maintainance/
when /admin-maintenance/
Baguette::Log.warning "should provide subjects to request"
Baguette::Log.warning "as in:"
DNSManager::Request::Maintainance::Subject.names.each do |n|
DNSManager::Request::Maintenance::Subject.names.each do |n|
Baguette::Log.warning "- #{n}"
end
end
@ -99,10 +99,10 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
opt_authd_admin.call parser, authd_config
# Maintenance.
parser.on("maintainance", "Maintainance operation of the website.") do
Baguette::Log.info "Maintainance operation of the website."
Context.command = "admin-maintainance"
parser.banner = "COMMAND: admin maintainance subject [value]"
parser.on("maintenance", "Maintenance operation of the website.") do
Baguette::Log.info "Maintenance operation of the website."
Context.command = "admin-maintenance"
parser.banner = "COMMAND: admin maintenance subject [value]"
unrecognized_args_to_context_args.call parser, nil, 1
end

View File

@ -1,7 +1,7 @@
class DNSManager::Request
# Periodic actions to perform as an administrator.
IPC::JSON.message Maintainance, 7 do
IPC::JSON.message Maintenance, 7 do
enum Subject
Verbosity # Change the verbosity of dnsmanagerd.
end
@ -28,5 +28,5 @@ class DNSManager::Request
end
end
end
DNSManager.requests << Maintainance
DNSManager.requests << Maintenance
end