Skip to content

Commit

Permalink
Reduce time between attempts, fix style, unless/if
Browse files Browse the repository at this point in the history
In order to avoid wasting too much time sleeping between attempts, just
sleep 0.1 seconds and retry 300 times.

Also fixed a style bug on line 2565, use `return false unless mod`
instead of `return false if mod.nil?`

[See rapid7#4340] [See rapid7#4615]
  • Loading branch information
Tod Beardsley committed Mar 24, 2015
1 parent 642efb5 commit 452d8cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/msf/ui/console/command_dispatcher/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class Core
DISCLOSURE_DATE_FORMAT = "%Y-%m-%d"

# Sleep time in seconds between module use retries (see #4340)
CMD_USE_TIMEOUT = 1
CMD_USE_TIMEOUT = 0.1

# Total retry attempts before giving up on using a module (see #4340)
CMD_USE_ATTEMPTS = 30
CMD_USE_ATTEMPTS = 300

# Returns the list of commands supported by this command dispatcher
def commands
Expand Down Expand Up @@ -2544,9 +2544,9 @@ def cmd_use(*args)

# Try to create an instance of the supplied module name
mod_name = args[0]
mod = nil

begin
mod = nil
CMD_USE_ATTEMPTS.times do
mod = framework.modules.create(mod_name)
break if mod
Expand All @@ -2562,7 +2562,7 @@ def cmd_use(*args)
log_error("The supplied module name is ambiguous: #{$!}.")
end

return false if (mod == nil)
return false unless mod

# Enstack the command dispatcher for this module type
dispatcher = nil
Expand Down

0 comments on commit 452d8cb

Please sign in to comment.