Skip to content
Open
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
13 changes: 11 additions & 2 deletions lib/em-ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,17 @@ def logger(level = Logger::WARN)
# log.debug "**** channel: #{channel}"
# channel.request_pty(options[:pty] || {}) do |pty,suc|
def connect(host, user, opts = {}, &blk)
logger.debug("#{self}.connect(#{host}, #{user}, #{opts})")
options = { :host => host, :user => user, :port => DEFAULT_PORT }.merge(opts)
level = case opts[:verbose]
when :debug then Logger::DEBUG
when :info then Logger::INFO
when :warn then Logger::WARN
when :error then Logger::ERROR
when :fatal then Logger::FATAL
else Logger::WARN
end
@logger = ::Logger.new(STDERR).tap{ |l| l.level = level }
logger(level).debug("#{self}.connect(#{host}, #{user}, #{opts})")
options = { :host => host, :user => user, :port => DEFAULT_PORT, :logger => logger}.merge(opts)
EM.connect(options[:host], options[:port], Connection, options, &blk)
end
alias :start :connect
Expand Down
6 changes: 4 additions & 2 deletions lib/em-ssh/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def initialize(address, user, pass, opts = {}, &blk)
@user = user
@pass = pass
@options = opts
@connect_opts = {:password => pass, :port => 22, :auth_methods => ['publickey', 'password']}.merge(opts[:net_ssh] || {})
@port = opts[:port] || 22
@auth_methods = opts[:auth_methods] || ['publickey', 'password']
@verbose = opts[:verbose] || :warn
@connect_opts = {:password => pass, :port => @port, :auth_methods => @auth_methods, :verbose => @verbose}.merge(opts[:net_ssh] || {})
@connection = opts[:connection]
@parent = opts[:parent]
@children = []
Expand Down Expand Up @@ -260,7 +263,6 @@ def connect
connection.errback do |e|
e.set_backtrace(trace + Array(e.backtrace))
fire(:error, e)
f.resume(e)
end # err
end
return Fiber.yield
Expand Down