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

Move worker config to config file #268

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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