Client: remove useless reference to authd + add a mocked zone del function.
This commit is contained in:
		
							parent
							
								
									a78eb8c889
								
							
						
					
					
						commit
						e7d8e2aa99
					
				
					 1 changed files with 23 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -25,11 +25,12 @@ end
 | 
			
		|||
class Actions
 | 
			
		||||
	property the_call     = {} of String => Proc(Nil)
 | 
			
		||||
	property dnsmanagerd  : DNSManager::Client
 | 
			
		||||
	property authd        : AuthD::Client
 | 
			
		||||
	property authd_config : Baguette::Configuration::Auth
 | 
			
		||||
	#property authd        : AuthD::Client
 | 
			
		||||
	#property authd_config : Baguette::Configuration::Auth
 | 
			
		||||
	property authd_key    : String?
 | 
			
		||||
	property config       : Baguette::Configuration::DNSManager
 | 
			
		||||
 | 
			
		||||
	def initialize(@dnsmanagerd, @authd, @authd_config, @config)
 | 
			
		||||
	def initialize(@dnsmanagerd, @config, @authd_key)
 | 
			
		||||
		#
 | 
			
		||||
		# Admin section.
 | 
			
		||||
		#
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +38,7 @@ class Actions
 | 
			
		|||
		# Maintainance
 | 
			
		||||
		@the_call["admin-maintainance"] = ->admin_maintainance
 | 
			
		||||
		@the_call["user-zone-add"]      = ->user_zone_add
 | 
			
		||||
		@the_call["user-zone-del"]      = ->user_zone_del
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	def admin_maintainance
 | 
			
		||||
| 
						 | 
				
			
			@ -51,17 +53,15 @@ class Actions
 | 
			
		|||
					next
 | 
			
		||||
				end
 | 
			
		||||
 | 
			
		||||
				key = @authd_config.shared_key
 | 
			
		||||
 | 
			
		||||
				if past_is_verbosity
 | 
			
		||||
					sub   = DNSManager::Request::Maintainance::Subject::Verbosity
 | 
			
		||||
					value = subject.to_i
 | 
			
		||||
					pp! sub, value
 | 
			
		||||
					pp! @dnsmanagerd.admin_maintainance key, sub, value
 | 
			
		||||
					pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub, value
 | 
			
		||||
				else
 | 
			
		||||
					sub   = DNSManager::Request::Maintainance::Subject.parse(subject)
 | 
			
		||||
					pp! sub
 | 
			
		||||
					pp! @dnsmanagerd.admin_maintainance key, sub
 | 
			
		||||
					pp! @dnsmanagerd.admin_maintainance authd_key.not_nil!, sub
 | 
			
		||||
				end
 | 
			
		||||
			rescue e
 | 
			
		||||
				puts "error for admin_maintainance #{subject}: #{e.message}"
 | 
			
		||||
| 
						 | 
				
			
			@ -80,6 +80,19 @@ class Actions
 | 
			
		|||
			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
 | 
			
		||||
 | 
			
		||||
def main
 | 
			
		||||
| 
						 | 
				
			
			@ -133,8 +146,8 @@ def main
 | 
			
		|||
		dnsmanagerd.login token
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	authd = AuthD::Client.new
 | 
			
		||||
	actions = Actions.new dnsmanagerd, authd, authd_config, config
 | 
			
		||||
	#authd = AuthD::Client.new
 | 
			
		||||
	actions = Actions.new dnsmanagerd, config, authd_config.pass
 | 
			
		||||
 | 
			
		||||
	# Now we did read the intent, we should proceed doing what was asked.
 | 
			
		||||
	begin
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +158,7 @@ def main
 | 
			
		|||
 | 
			
		||||
	# dnsmanagerd disconnection
 | 
			
		||||
	dnsmanagerd.close
 | 
			
		||||
	authd.close
 | 
			
		||||
	#authd.close
 | 
			
		||||
rescue e
 | 
			
		||||
	Baguette::Log.info "Exception: #{e}"
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue