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

This commit is contained in:
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. # Admin stuff.
# #
def admin_maintainance(key : String, subject : DNSManager::Request::Maintainance::Subject, value : Int32? = nil) def admin_maintenance(key : String, subject : DNSManager::Request::Maintenance::Subject, value : Int32? = nil)
request = DNSManager::Request::Maintainance.new(key,subject) request = DNSManager::Request::Maintenance.new(key,subject)
if value if value
request.value = value request.value = value
end end

View File

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

View File

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

View File

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