Module: Rex::Service

Includes:
Ref
Included in:
Rex::Services::LocalRelay
Defined in:
lib/rex/service.rb

Overview

The service module is used to extend classes that are passed into the service manager start routine. It provides extra methods, such as reference counting, that are used to track the service instances more uniformly.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



44
45
46
# File 'lib/rex/service.rb', line 44

def alias
  @alias
end

Class Method Details

.hardcore_alias(*args) ⇒ Object

Returns the hardcore, as in porno, alias for this service. This is used by the service manager to manage singleton services.



21
22
23
# File 'lib/rex/service.rb', line 21

def self.hardcore_alias(*args)
  return "__#{args}"
end

Instance Method Details

#cleanupObject

Calls stop on the service once the ref count drops.



40
41
42
# File 'lib/rex/service.rb', line 40

def cleanup
  stop
end

#derefObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rex/service.rb', line 25

def deref
  rv = super

  # If there's only one reference, then it's the service managers.
  if @_references == 1
    Rex::ServiceManager.stop_service(self)
    return true
  end

  rv
end