Project

General

Profile

« Previous | Next » 

Revision c712f2db

Added by Marc Dequènes almost 14 years ago

  • ID c712f2db1dcfc7f8273da879a5bf27924c72963b

[evol] connect_peer: made most of the code generic to all backends

View differences:

lib/cyborghood/cyborg/botnet.rb
end
def contact_peer(peer, &block)
super(peer, block) do |callback|
EventMachine.connect_unix_domain(peer_socket(peer), Conversation, self, callback)
end
end
end
module BotNet
attr_reader :interface
def self.included(base)
case Config.instance.botnet.connection_type
when 'unix_socket'
return base.class_eval("include BotNetClientUNIXSocket")
else
raise CyberError.new(:unrecoverable, "config", "Unknown botnet connection type")
end
end
def setup
super
@comm_list = {}
@comm_list_attempt = {}
end
def contact_peer(peer, block)
if @comm_list.has_key? peer
block.call @comm_list[peer]
else
......
end
end
begin
EventMachine.connect_unix_domain(peer_socket(peer), Conversation, self, callback)
yield(callback)
rescue
# TODO: retry (wait_timer + recursive call + counter)
block.call false
......
end
end
end
end
module BotNet
attr_reader :interface
def self.included(base)
case Config.instance.botnet.connection_type
when 'unix_socket'
return base.class_eval("include BotNetClientUNIXSocket")
else
raise CyberError.new(:unrecoverable, "config", "Unknown botnet connection type")
end
end
def setup
super
@comm_list = {}
@comm_list_attempt = {}
end
# used to quit properly and later to reuse communication channels
def register_communication(peer, conversation)

Also available in: Unified diff