BotnetV2
A bot net to calculate intense tasks on remote machines. Outsource your tasks to your bots. While a worker bot is not executing a task, it is passively waiting.
Installation
Add this line to your application's Gemfile:
gem 'BotnetV2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install BotnetV2
Usage
First create a certificate and distribute the cert.pem. The private.pem is only for the master.
$ BotnetV2.create_certificate
Start a master server on any system. Whereas it does not require much calculation power a raspberrypi is also ok. Make sure your ruby program does not exit. Do not use hybrid_mode or no ssl, because it opens your bot net to anyone.
$ BotnetV2.create_master(ssl_port = 8008, no_ssl_port = 8009, ssl = true, hybrid_mode = false)
Create workers on any high performance computer that you can find with ruby. The more workers, the more tasks you can execute in parallel. Make sure your ruby program does not exit.
$ BotnetV2.create_worker(host, port = 8008, ssl = true)
Your local Machine, which delegates tasks.
$ client = BotnetV2.create_client(client_id, host, port = 8008, ssl = true)
$ client.execute (task_src, callback)
Contributing
- Fork it ( https://fuersts1.homeip.net/penguinmenac3/botnetv2 )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Sample
def test
unless File.exists? 'private.pem' and File.exists? 'cert.pem'
File.delete 'private.pem' if File.exists? 'private.pem'
File.delete 'cert.pem' if File.exists? 'cert.pem'
BotnetV2::BotnetV2.create_certificate
end
master = BotnetV2::BotnetV2.create_master 'your_password_goes_here'
worker = BotnetV2::BotnetV2.create_worker 'your_password_goes_here', 'localhost'
client = BotnetV2::BotnetV2.create_client 'your_password_goes_here', 1, 'localhost'
client.execute("1+1", Proc.new do |res| on_result(res) end)
sleep(0) until @done
client.exit!
worker.exit!
master.exit!
assert_equal(@result, 2, 'Wrong result')
end
def on_result(result)
@result = result
@done = true
end