Revision 0b67cab8
Added by Marc Dequènes over 13 years ago
- ID 0b67cab83c4ab4f6190a0f8955489efc02a60f0c
lib/cyborghood/cyborg.rb | ||
---|---|---|
#++
|
||
|
||
require 'cyborghood'
|
||
require 'socket'
|
||
require 'eventmachine'
|
||
require 'thread'
|
||
require 'cyborghood/cyborg/dsl'
|
||
... | ... | |
end
|
||
|
||
class Cyborg
|
||
include I18nTranslation
|
||
bindtextdomain("cyborghood", {:path => Config::L10N_DIR, :charset => "UTF-8"})
|
||
|
||
include TaskAspect
|
||
|
||
attr_reader :name, :services
|
||
attr_reader :name, :services, :host_name, :host_fqdn
|
||
|
||
def initialize(services = nil)
|
||
@services = services
|
||
|
||
@name = self.class.name.split("::").last
|
||
@host_name = Socket.gethostname
|
||
@host_fqdn = Socket.gethostbyname(Socket.gethostname).first
|
||
@name = "#{self.class.model}@#{@host_fqdn}"
|
||
|
||
@config = Config.instance
|
||
|
||
# setup logs
|
||
... | ... | |
logger.info "Bot '#{self.human_name}' loaded"
|
||
end
|
||
|
||
def self.model
|
||
self.human_name
|
||
end
|
||
|
||
def model
|
||
self.class.model
|
||
end
|
||
|
||
# #^.*/system$# categories are reserved
|
||
# but you may enhance or break the system as you wish
|
||
def get_channel(name)
|
lib/cyborghood/cyborg/botnet/backend/unix.rb | ||
---|---|---|
|
||
@pending_conversation_close = Set.new
|
||
|
||
@socket = peer_socket(@name)
|
||
@socket = peer_socket(self.model)
|
||
at_exit { remove_socket_file }
|
||
end
|
||
|
lib/cyborghood/cyborg/botnet/conversation.rb | ||
---|---|---|
MaxLineLength = 16*1024
|
||
|
||
EOD = "\033[0J"
|
||
BOT_NAME_PATTERN = "[A-Z][a-zA-Z0-9]+"
|
||
BOT_NAME_PATTERN = "[A-Z][a-zA-Z0-9]+@[A-Z][a-zA-Z0-9.-]+"
|
||
ACTION_WORD_PATTERN = "[a-zA-Z0-9]+"
|
||
ACTION_PATTERN = "^(#{BOT_NAME_PATTERN})-([0-9]{4})-([0-9]{4})([+]?) (#{ACTION_WORD_PATTERN}( #{ACTION_WORD_PATTERN})*)$"
|
||
MAXIMUM_ERROR_COUNT = 3
|
lib/cyborghood/cyborg/botnet/interface.rb | ||
---|---|---|
protected
|
||
|
||
def base_lpath
|
||
File.join(Config::LIB_DIR, 'cyborghood-' + @bot.name.downcase, 'interface')
|
||
File.join(Config::LIB_DIR, 'cyborghood-' + @bot.model.downcase, 'interface')
|
||
end
|
||
|
||
def lpath
|
Also available in: Unified diff
[evol] introduce Cyborg model and compute the name using the model and host fqdn