CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/service.rb
Views: 11766
1
# -*- coding: binary -*-
2
require 'rex'
3
4
module Rex
5
6
###
7
#
8
# The service module is used to extend classes that are passed into the
9
# service manager start routine. It provides extra methods, such as reference
10
# counting, that are used to track the service instances more uniformly.
11
#
12
###
13
module Service
14
include Ref
15
16
17
#
18
# Returns the hardcore, as in porno, alias for this service. This is used
19
# by the service manager to manage singleton services.
20
#
21
def self.hardcore_alias(*args)
22
return "__#{args}"
23
end
24
25
def deref
26
rv = super
27
28
# If there's only one reference, then it's the service managers.
29
if @_references == 1
30
Rex::ServiceManager.stop_service(self)
31
return true
32
end
33
34
rv
35
end
36
37
#
38
# Calls stop on the service once the ref count drops.
39
#
40
def cleanup
41
stop
42
end
43
44
attr_accessor :alias
45
46
end
47
48
end
49
50