Project

General

Profile

« Previous | Next » 

Revision 9dfb2047

Added by Marc Dequènes over 13 years ago

  • ID 9dfb20472588827dc7c43f3d253a09a0822fd036

[fix] Protocol: check node existence asynchronously for CALL

View differences:

bin/test_client
ask "MapMaker", :info1, "/_cyborg_"
ask "Librarian", :info2, "/_cyborg_"
ask "MapMaker", :zones, "/DNS/Zones"
#ask "MapMaker", :wanted_failure, "/prout"
ask "MapMaker", :zone_mp, "/DNS/Zones/milkypond.org"
know? "MapMaker", :k1, "/DNS/Zones"
know? "MapMaker", :k2, "/prout"
lib/cyborghood/cyborg/botnet/protocol.rb
def receive_request_call(message)
if message.action_parameters.nil?
return send_error_action(message, "missing parameters")
end
unless @conversation.bot.interface._is_node?(message.conv_thread.session, message.action_parameters[:node])
return send_error_action(message, "bad node")
return send_error_action(message, {
:category => 'API',
:severity => :unrecoverable,
:message => "missing parameters"
})
end
send_reply_ack(message)
@conversation.bot.schedule_task(@@request_callback) do
result = {
:reply_message => message
}
begin
result[:action_result] = @conversation.bot.interface._call(message.conv_thread.session,
message.action_parameters[:node],
message.action_parameters[:parameters])
rescue CyberError => e
result[:error] = {
:category => e.category,
:severity => e.severity,
:message => e.message
}
rescue
if @conversation.bot.interface._is_node?(message.conv_thread.session, message.action_parameters[:node])
begin
result[:action_result] = @conversation.bot.interface._call(message.conv_thread.session,
message.action_parameters[:node],
message.action_parameters[:parameters])
rescue CyberError => e
result[:error] = {
:category => e.category,
:severity => e.severity,
:message => e.message
}
rescue
result[:error] = {
:category => 'unknown',
:severity => :unrecoverable,
:message => $!.to_s
}
end
else
result[:error] = {
:category => 'unknown',
:category => 'API',
:severity => :unrecoverable,
:message => $!.to_s
:message => "bad node"
}
end
result
end
end
def receive_request_exists(message)
if message.action_parameters.nil?
return send_error_action(message, "missing parameters")
return send_error_action(message, {
:category => 'API',
:severity => :unrecoverable,
:message => "missing parameters"
})
end
send_reply_ack(message)
@conversation.bot.schedule_task(@@request_callback) do

Also available in: Unified diff