Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Move worker config to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Claudius committed Dec 1, 2016
1 parent a70a86f commit a50c47e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bin/ssh_scan_worker
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ $:.unshift File.join(File.dirname(__FILE__), "../lib")

require 'ssh_scan'

opts = {
"server" => "192.168.10.37",
"port" => 8000
}
# Get the worker config from command-line or via an example location
config_file = ARGV[0] || File.join(File.dirname(__FILE__), "ssh_scan_worker_example_config.yml")

worker = SSHScan::Worker.new({:server => "192.168.10.37", :port => 8000})
worker = SSHScan::Worker.from_config_file(config_file)
worker.run!
2 changes: 2 additions & 0 deletions bin/ssh_scan_worker_example_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server: 127.0.0.1
port: 8000
5 changes: 5 additions & 0 deletions lib/ssh_scan/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def initialize(opts = {})
@verify_ssl = false
end

def self.from_config_file(file_string)
opts = YAML.load_file(file_string)
self.new(opts)
end

def run!
loop do
begin
Expand Down

0 comments on commit a50c47e

Please sign in to comment.