Client: remove useless reference to authd + add a mocked zone del function.

This commit is contained in:
Philippe Pittoli 2023-05-04 03:15:32 +02:00
parent a78eb8c889
commit e7d8e2aa99

View File

@ -25,11 +25,12 @@ end
class Actions class Actions
property the_call = {} of String => Proc(Nil) property the_call = {} of String => Proc(Nil)
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 config : Baguette::Configuration::DNSManager property config : Baguette::Configuration::DNSManager
def initialize(@dnsmanagerd, @authd, @authd_config, @config) def initialize(@dnsmanagerd, @config, @authd_key)
# #
# Admin section. # Admin section.
# #
@ -37,6 +38,7 @@ class Actions
# Maintainance # Maintainance
@the_call["admin-maintainance"] = ->admin_maintainance @the_call["admin-maintainance"] = ->admin_maintainance
@the_call["user-zone-add"] = ->user_zone_add @the_call["user-zone-add"] = ->user_zone_add
@the_call["user-zone-del"] = ->user_zone_del
end end
def admin_maintainance def admin_maintainance
@ -51,17 +53,15 @@ class Actions
next next
end end
key = @authd_config.shared_key
if past_is_verbosity if past_is_verbosity
sub = DNSManager::Request::Maintainance::Subject::Verbosity sub = DNSManager::Request::Maintainance::Subject::Verbosity
value = subject.to_i value = subject.to_i
pp! sub, value pp! sub, value
pp! @dnsmanagerd.admin_maintainance key, sub, value pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub, value
else else
sub = DNSManager::Request::Maintainance::Subject.parse(subject) sub = DNSManager::Request::Maintainance::Subject.parse(subject)
pp! sub pp! sub
pp! @dnsmanagerd.admin_maintainance key, sub pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub
end end
rescue e rescue e
puts "error for admin_maintainance #{subject}: #{e.message}" puts "error for admin_maintainance #{subject}: #{e.message}"
@ -80,6 +80,19 @@ class Actions
end end
end end
end end
def user_zone_del
domains = Context.args.not_nil!
domains.each do |domain|
begin
pp! domain
#pp! @dnsmanagerd.user_zone_del domain
rescue e
puts "error for user_zone_del: #{e.message}"
end
end
end
end end
def main def main
@ -133,8 +146,8 @@ def main
dnsmanagerd.login token dnsmanagerd.login token
end end
authd = AuthD::Client.new #authd = AuthD::Client.new
actions = Actions.new dnsmanagerd, authd, authd_config, config actions = Actions.new dnsmanagerd, config, authd_config.pass
# 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
@ -145,7 +158,7 @@ def main
# dnsmanagerd disconnection # dnsmanagerd disconnection
dnsmanagerd.close dnsmanagerd.close
authd.close #authd.close
rescue e rescue e
Baguette::Log.info "Exception: #{e}" Baguette::Log.info "Exception: #{e}"
end end