2014-11-13 20:08:26 +00:00
|
|
|
# Wraps {Msf::Framework} so that {Msf::Framework#threads} is only created on the first call to {#spawn} by
|
2016-04-20 18:02:15 +00:00
|
|
|
# Rex::ThreadFactory#spawn, which allows the threads used by {Msf::ThreadManager} to be created lazily.
|
2014-11-13 20:08:26 +00:00
|
|
|
#
|
|
|
|
# @example Setting Rex::ThreadFactory.provider and spawning threads
|
|
|
|
# Rex::ThreadFactory.provider = Metasploit::Framework::ThreadFactoryProvider.new(framework: framework)
|
|
|
|
# # framework.threads created here
|
|
|
|
# Rex::ThreadFactory.spawn("name", false) { ... }
|
|
|
|
#
|
|
|
|
class Metasploit::Framework::ThreadFactoryProvider < Metasploit::Model::Base
|
|
|
|
#
|
|
|
|
# Attributes
|
|
|
|
#
|
|
|
|
|
|
|
|
# @!attribute framework
|
|
|
|
# The framework managing the spawned threads.
|
|
|
|
#
|
|
|
|
# @return [Msf::Framework]
|
|
|
|
attr_accessor :framework
|
|
|
|
|
|
|
|
# Spawns a thread monitored by {Msf::ThreadManager} in {Msf::Framework#threads}.
|
|
|
|
#
|
|
|
|
# (see Msf::ThreadManager#spawn)
|
|
|
|
def spawn(name, critical, *args, &block)
|
|
|
|
framework.threads.spawn(name, critical, *args, &block)
|
|
|
|
end
|
2016-04-20 18:02:15 +00:00
|
|
|
end
|