Class: Msf::RPC::RpcJobStatusTracker

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/msf/core/rpc/v10/rpc_job_status_tracker.rb

Defined Under Namespace

Classes: ResultsMemoryStore

Instance Method Summary collapse

Constructor Details

#initializeRpcJobStatusTracker

Returns a new instance of RpcJobStatusTracker.


9
10
11
12
13
14
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 9

def initialize
  @ready = Set.new
  @running = Set.new
  # Can be expanded upon later to allow the option of a MemCacheStore being backed by redis for example
  @results = ResultsMemoryStore.new
end

Instance Method Details

#completed(id, result, mod) ⇒ Object


25
26
27
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 25

def completed(id, result, mod)
  add_result(id, { result: result }, mod)
end

#dataObject


68
69
70
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 68

def data
  results.data
end

#delete(id) ⇒ Object Also known as: ack


52
53
54
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 52

def delete(id)
  results.delete(id)
end

#failed(id, error, mod) ⇒ Object


29
30
31
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 29

def failed(id, error, mod)
  add_result(id, { error: error.to_s }, mod)
end

#finished?(id) ⇒ Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 41

def finished?(id)
  results.exist? id
end

#result(id) ⇒ Object


45
46
47
48
49
50
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 45

def result(id)
  result = results.fetch(id)
  return unless result

  ::JSON.parse(result).with_indifferent_access
end

#result_idsObject


56
57
58
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 56

def result_ids
  results.keys
end

#running?(id) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 33

def running?(id)
  running.include? id
end

#running_idsObject


64
65
66
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 64

def running_ids
  running.to_a
end

#start(id) ⇒ Object


20
21
22
23
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 20

def start(id)
  running << id
  ready.delete(id)
end

#waiting(id) ⇒ Object


16
17
18
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 16

def waiting(id)
  ready << id
end

#waiting?(id) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 37

def waiting?(id)
  ready.include? id
end

#waiting_idsObject


60
61
62
# File 'lib/msf/core/rpc/v10/rpc_job_status_tracker.rb', line 60

def waiting_ids
  ready.to_a
end