Skip to content

Commit

Permalink
fix yard, refactor/remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Oct 19, 2023
1 parent af60ee2 commit 299b237
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
12 changes: 5 additions & 7 deletions lib/msf/ui/console/command_dispatcher/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2614,15 +2614,13 @@ def verify_session(session_id, quiet = false)
# Custom error code to handle timeout errors
#
# @param message [String] The message to be printed when a timeout error is hit

# @return [Proc] proc function that prints the specified error when the error types match
def log_on_timeout_error(message)
proc do |e|
handled = false
if e.is_a?(Rex::TimeoutError) || e.is_a?(Timeout::Error)
elog(e)
print_error(message)
:handled
end
next unless e.is_a?(Rex::TimeoutError) || e.is_a?(Timeout::Error)
elog(e)
print_error(message)
:handled
end
end

Expand Down
27 changes: 14 additions & 13 deletions lib/rex/post/meterpreter/ui/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,20 @@ def run_command(dispatcher, method, arguments)
begin
super
rescue Exception => e
unless self.client.on_error_proc && self.client.on_error_proc.call(e) == :handled
case e
when Rex::TimeoutError, Rex::InvalidDestination
log_error(e.message)
when Timeout::Error
log_error('Operation timed out.')
when RequestError
log_error(e.to_s)
when ::Errno::EPIPE, ::OpenSSL::SSL::SSLError, ::IOError
self.client.kill
when ::Exception
log_error("Error running command #{method}: #{e.class} #{e}")
end
is_error_handled = self.client.on_error_proc && self.client.on_error_proc.call(e) == :handled
return if is_error_handled
case e
when Rex::TimeoutError, Rex::InvalidDestination
log_error(e.message)
when Timeout::Error
log_error('Operation timed out.')
when RequestError
log_error(e.to_s)
when ::Errno::EPIPE, ::OpenSSL::SSL::SSLError, ::IOError
self.client.kill
when ::Exception
log_error("Error running command #{method}: #{e.class} #{e}")
elog(e)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rex/ui/interactive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def detach
#
# A function to be run when the session hits an error
#

# @return [Proc,nil] A function to be run when the session hits an error
attr_accessor :on_error_proc

protected
Expand Down

0 comments on commit 299b237

Please sign in to comment.